Commit 57f1b180 authored by Lambert Patrick's avatar Lambert Patrick
Browse files

bux fix in Kopt and commentting

Showing with 66 additions and 34 deletions
+66 -34
...@@ -23,11 +23,36 @@ import umontreal.iro.lecuyer.randvar.NormalGen; ...@@ -23,11 +23,36 @@ import umontreal.iro.lecuyer.randvar.NormalGen;
@ServiceProvider(service = AquaNismsGroupProcess.class) @ServiceProvider(service = AquaNismsGroupProcess.class)
public class Grow extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGroup> { public class Grow extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGroup> {
/**
* temperature minimum for growth
* @unit °C
*/
private double tempMinGrow = 3.; private double tempMinGrow = 3.;
/**
* temperature maximum for growth
* @unit °C
*/
private double tempMaxGrow = 26.; private double tempMaxGrow = 26.;
/**
* temperature optimal for growth
* @unit °C
*/
private double tempOptGrow = 17.; private double tempOptGrow = 17.;
/**
* K, Brody growth rate at optimal temperature
* L = Linf *(1-exp(-K*(t-t0))
* @unit year -1
*/
private double kOpt = 0.3; private double kOpt = 0.3;
private double sigmaDeltaLVonBert = 0.2; // random value... has to be fixed with literature
/**
* standart deviation for the lognormal random draw of growth increment
* @unit cm
*/
private double sigmaDeltaLVonBert = 0.2;
private transient NormalGen genNormal; private transient NormalGen genNormal;
...@@ -37,45 +62,52 @@ public class Grow extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGr ...@@ -37,45 +62,52 @@ public class Grow extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGr
@Override @Override
@InitTransientParameters @InitTransientParameters
public void initTransientParameters(Pilot pilot) { public void initTransientParameters(Pilot pilot) {
super.initTransientParameters(pilot); super.initTransientParameters(pilot);
genNormal = new NormalGen( pilot.getRandomStream(), genNormal = new NormalGen( pilot.getRandomStream(),
new NormalDist(0., 1.)); new NormalDist(0., 1.));
} }
@Override @Override
public void doProcess(DiadromousFishGroup group) { public void doProcess(DiadromousFishGroup group) {
for(Basin basin : group.getEnvironment().getBasins()){ for(Basin basin : group.getEnvironment().getBasins()){
if (basin.getFishs(group)!=null) for(DiadromousFish fish : basin.getFishs(group)){ if (basin.getFishs(group)!=null)
double muDeltaLVonBert = 0.; for(DiadromousFish fish : basin.getFishs(group)){
double kVonBert = 0.; double muDeltaLVonBert = 0.;
double growthIncrement = 0.; double kVonBert = 0.;
//Grow double growthIncrement = 0.;
// 1) We calculate the kVonBert
// 1) calculate the kVonBert (from the grow process or forn Diadromousgroup
if (group.getKOpt()==Double.NaN){ // when Brody coeff comes from calibration output
kVonBert = kOpt * if (Double.isNaN(group.getKOpt())){
Miscellaneous.temperatureEffect(fish.getPosition().getCurrentTemperature(group.getPilot()), tempMinGrow, tempOptGrow, tempMaxGrow); kVonBert = kOpt *
} else { Miscellaneous.temperatureEffect(fish.getPosition().getCurrentTemperature(group.getPilot()), tempMinGrow, tempOptGrow, tempMaxGrow);
kVonBert = group.getKOpt() * } else {
Miscellaneous.temperatureEffect(fish.getPosition().getCurrentTemperature(group.getPilot()), tempMinGrow, tempOptGrow, tempMaxGrow); kVonBert = group.getKOpt() *
} Miscellaneous.temperatureEffect(fish.getPosition().getCurrentTemperature(group.getPilot()), tempMinGrow, tempOptGrow, tempMaxGrow);
}
// 2) We update the size of the fish
if (fish.getLength() < group.getLinfVonBert()){ // 2) Update the fish length with a lognormal normal draw of increment
muDeltaLVonBert = Math.log((group.getLinfVonBert() - fish.getLength()) * (1 - Math.exp(-kVonBert * Time.getSeasonDuration()))) - (sigmaDeltaLVonBert*sigmaDeltaLVonBert)/2; // limit the fish length to Linf
growthIncrement = Math.exp(genNormal.nextDouble()*sigmaDeltaLVonBert + muDeltaLVonBert); if (fish.getLength() < group.getLinfVonBert()){
fish.setLength(Math.min(group.getLinfVonBert(), fish.getLength() + growthIncrement)); muDeltaLVonBert = Math.log((group.getLinfVonBert() - fish.getLength()) * (1 - Math.exp(-kVonBert * Time.getSeasonDuration()))) - (sigmaDeltaLVonBert*sigmaDeltaLVonBert)/2;
}else{ growthIncrement = Math.exp(genNormal.nextDouble()*sigmaDeltaLVonBert + muDeltaLVonBert);
fish.setLength(group.getLinfVonBert());
}
fish.setLength(Math.min(group.getLinfVonBert(), fish.getLength() + growthIncrement));
if (fish.getStage() == Stage.IMMATURE){ }
if (fish.getLength() > group.getlFirstMaturity()){ else {
fish.setStage(Stage.MATURE); fish.setLength(group.getLinfVonBert());
}
//System.out.println(fish.getAge() + " -> "+ fish.getLength() + " ("+fish.getStage()+"): "+ growthIncrement);
// test if fish become mature
if (fish.getStage() == Stage.IMMATURE){
if (fish.getLength() > group.getlFirstMaturity()){
fish.setStage(Stage.MATURE);
}
}
//System.out.println("la temp�rature du lieu de vie du poisson est :" + fish.getPosition().getCurrentTemperature() + ", la saison est :" + Time.getSeason() + " et sa nouvelle taille est :" + fish.getLength());
} }
} }
//System.out.println("la temp�rature du lieu de vie du poisson est :" + fish.getPosition().getCurrentTemperature() + ", la saison est :" + Time.getSeason() + " et sa nouvelle taille est :" + fish.getLength());
}
}
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment