Commit 63c5d978 authored by Poulet Camille's avatar Poulet Camille
Browse files

Merge branch 'develop' of gitlab-ssh.irstea.fr:SimAquaLife/GR3D into exploration_GR3D_process

parents 86efa21a 95ee5985
...@@ -320,8 +320,14 @@ ...@@ -320,8 +320,14 @@
<species.SurviveAfterReproduction> <species.SurviveAfterReproduction>
<synchronisationMode>ASYNCHRONOUS</synchronisationMode> <synchronisationMode>ASYNCHRONOUS</synchronisationMode>
<afterReproductionSeason>SPRING</afterReproductionSeason> <afterReproductionSeason>SUMMER</afterReproductionSeason>
<survivalRateAfterReproduction>0.1</survivalRateAfterReproduction> <maximalSurvivalRate>0.1</maximalSurvivalRate>
<!-- <temperatureEffectSurvivalAfterReproduction class="temperatureEffect.LogitEffect"> -->
<!-- <Tref>22</Tref> -->
<!-- <alpha>-.1</alpha> -->
<!-- </temperatureEffectSurvivalAfterReproduction> -->
<temperatureEffectSurvivalAfterReproduction class="temperatureEffect.NoEffect">
</temperatureEffectSurvivalAfterReproduction>
</species.SurviveAfterReproduction> </species.SurviveAfterReproduction>
<species.MigrateFromRiverToInshore> <species.MigrateFromRiverToInshore>
......
...@@ -18,8 +18,8 @@ import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientPara ...@@ -18,8 +18,8 @@ import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientPara
import fr.cemagref.simaqualife.pilot.Pilot; import fr.cemagref.simaqualife.pilot.Pilot;
import miscellaneous.BinomialForSuperIndividualGen; import miscellaneous.BinomialForSuperIndividualGen;
import species.DiadromousFish.SpawnerOrigin; import species.DiadromousFish.SpawnerOrigin;
import umontreal.iro.lecuyer.probdist.NormalDist; import temperatureEffect.LogitEffect;
import umontreal.iro.lecuyer.randvar.NormalGen; import temperatureEffect.TemperatureEffect;
@ServiceProvider(service = AquaNismsGroupProcess.class) @ServiceProvider(service = AquaNismsGroupProcess.class)
...@@ -27,9 +27,14 @@ public class SurviveAfterReproduction extends AquaNismsGroupProcess<DiadromousFi ...@@ -27,9 +27,14 @@ public class SurviveAfterReproduction extends AquaNismsGroupProcess<DiadromousFi
private Season afterReproductionSeason = Season.SUMMER; private Season afterReproductionSeason = Season.SUMMER;
private double survivalRateAfterReproduction = 0.1; /**
* maximum suvival od spawnser after reproduction
*
* @unit -
*/
private double maximalSurvivalRate = 0.1;
private transient NormalGen genNormal; private TemperatureEffect temperatureEffectSurvivalAfterReproduction;
/** /**
* the random numbers generator for binomial draws * the random numbers generator for binomial draws
...@@ -39,7 +44,9 @@ public class SurviveAfterReproduction extends AquaNismsGroupProcess<DiadromousFi ...@@ -39,7 +44,9 @@ public class SurviveAfterReproduction extends AquaNismsGroupProcess<DiadromousFi
private transient BinomialForSuperIndividualGen aleaGen; private transient BinomialForSuperIndividualGen aleaGen;
public static void main(String[] args) { public static void main(String[] args) {
System.out.println((new XStream(new DomDriver())).toXML(new SurviveAfterReproduction())); SurviveAfterReproduction surviveAfterReproduction = new SurviveAfterReproduction();
surviveAfterReproduction.temperatureEffectSurvivalAfterReproduction = new LogitEffect(22, -0.1);
System.out.println((new XStream(new DomDriver())).toXML(surviveAfterReproduction));
} }
...@@ -47,7 +54,6 @@ public class SurviveAfterReproduction extends AquaNismsGroupProcess<DiadromousFi ...@@ -47,7 +54,6 @@ public class SurviveAfterReproduction extends AquaNismsGroupProcess<DiadromousFi
@InitTransientParameters @InitTransientParameters
public void initTransientParameters(Pilot pilot) { public void initTransientParameters(Pilot pilot) {
super.initTransientParameters(pilot); super.initTransientParameters(pilot);
genNormal = new NormalGen(pilot.getRandomStream(), new NormalDist(0., 1.));
aleaGen = new BinomialForSuperIndividualGen(pilot.getRandomStream()); aleaGen = new BinomialForSuperIndividualGen(pilot.getRandomStream());
...@@ -77,20 +83,25 @@ public class SurviveAfterReproduction extends AquaNismsGroupProcess<DiadromousFi ...@@ -77,20 +83,25 @@ public class SurviveAfterReproduction extends AquaNismsGroupProcess<DiadromousFi
totalInputFluxes.get(origin).put("biomass", 0.); totalInputFluxes.get(origin).put("biomass", 0.);
} }
// temperature effect in the riverBasin
double currentTemperature = riverBasin.getCurrentTemperature(group.getPilot());
double tempEffect = temperatureEffectSurvivalAfterReproduction.getTemperatureEffect(currentTemperature);
double survivalProbability = maximalSurvivalRate * tempEffect;
// iterate on the fish // iterate on the fish
ListIterator<DiadromousFish> fishIterator = fishInBasin.listIterator(); ListIterator<DiadromousFish> fishIterator = fishInBasin.listIterator();
while (fishIterator.hasNext()) { while (fishIterator.hasNext()) {
DiadromousFish fish = fishIterator.next(); DiadromousFish fish = fishIterator.next();
// only on spawners
if (fish.isMature()) { if (fish.isMature()) {
// origin of the spwaner // origin of the spwaner
SpawnerOrigin spawnerOrigin = (fish.getBirthBasin() == riverBasin ? SpawnerOrigin.AUTOCHTONOUS SpawnerOrigin spawnerOrigin = (fish.getBirthBasin() == riverBasin ? SpawnerOrigin.AUTOCHTONOUS
: SpawnerOrigin.ALLOCHTONOUS); : SpawnerOrigin.ALLOCHTONOUS);
// survival amount of fish // survival amount of fish
double biomass = 0.; double biomass = 0.;
survivalAmount = aleaGen.getSuccessNumber(fish.getAmount(), survivalRateAfterReproduction); survivalAmount = aleaGen.getSuccessNumber(fish.getAmount(), survivalProbability);
// at least one fish in the SI survive, the other die // at least one fish in the SI survive, the other die
if (survivalAmount > 0) { if (survivalAmount > 0) {
......
/**
* patrick
* @author Patrick Lambert
* @copyright Copyright (c) 2020, INRAE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package temperatureEffect;
/**
*
*/
public class LogitEffect implements TemperatureEffect {
/**
*
* @unit
*/
private static final long serialVersionUID = 3756752294442116413L;
/**
* temperature reference used to calculate the effect
*
* @unit °C
*/
private double Tref = 20.;
/**
* parameter used to calculate the effect
*
* @unit °C
*/
private double alpha = 0.1;
@Override
public double getTemperatureEffect(double temperature) {
return 1. / (1. + Math.exp(-alpha * (temperature - Tref)));
}
public LogitEffect(double Tref, double alpha) {
super();
this.Tref = Tref;
this.alpha = alpha;
}
}
/**
* patrick
* @author Patrick Lambert
* @copyright Copyright (c) 2020, INRAE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package temperatureEffect;
/**
*
*/
public class NoEffect implements TemperatureEffect {
/**
*
* @unit
*/
private static final long serialVersionUID = -7686765011254676763L;
@Override
public double getTemperatureEffect(double temperature) {
return 1.;
}
public NoEffect(double Tref, double alpha) {
super();
}
}
/**
* patrick
* @author Patrick Lambert
* @copyright Copyright (c) 2020, INRAE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package temperatureEffect;
/**
*
*/
public class RectangularTemperatureEffect implements TemperatureEffect {
/**
*
* @unit
*/
private static final long serialVersionUID = -611999636717694259L;
/**
* minimal temperature . Below this value, the temperature effect is 0
*
* @unit °C
*/
private double Tmin;
/**
* maximal temperature. Above this value, the temperature effect is 0
*
* @unit °C
*/
private double Tmax;
@Override
public double getTemperatureEffect(double temperature) {
if (temperature <= Tmin || temperature >= Tmax) {
return 0;
} else {
return 1;
}
}
public RectangularTemperatureEffect(double tmin, double tmax) {
super();
this.Tmin = tmin;
this.Tmax = tmax;
}
}
/**
* patrick
* @author Patrick Lambert
* @copyright Copyright (c) 2020, INRAE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package temperatureEffect;
/**
*
*/
public class Rosso implements TemperatureEffect {
/**
*
* @unit
*/
private static final long serialVersionUID = -2646246167644233819L;
/**
* minimal temperature . Below this value, the temperature effect is 0
*
* @unit °C
*/
private double Tmin;
/**
* optimal temperature. At this value, the temperature effect is 1
*
* @unit °C
*/
private double Topt;
/**
* maximal temperature. Above this value, the temperature effect is 0
*
* @unit °C
*/
private double Tmax;
@Override
public double getTemperatureEffect(double temperature) {
if (temperature <= Tmin || temperature >= Tmax) {
return 0;
} else {
return (temperature - Tmin) * (temperature - Tmax)
/ ((temperature - Tmin) * (temperature - Tmax) - ((temperature - Topt) * (temperature - Topt)));
}
}
public Rosso(double tmin, double topt, double tmax) {
super();
this.Tmin = tmin;
this.Topt = topt;
this.Tmax = tmax;
}
}
/**
* patrick
* @author Patrick Lambert
* @copyright Copyright (c) 2020, INRAE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package temperatureEffect;
import java.io.Serializable;
/**
*
*/
public interface TemperatureEffect extends Serializable {
public double getTemperatureEffect(double temperature);
}
/**
* patrick
* @author Patrick Lambert
* @copyright Copyright (c) 2020, INRAE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
*
*/
package temperatureEffect;
\ No newline at end of file
Markdown is supported
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