Commit 0f52a527 authored by patrick.lambert's avatar patrick.lambert
Browse files

with a package dedicated to temperature effect

parent c697a18b
...@@ -18,6 +18,8 @@ import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientPara ...@@ -18,6 +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 temperatureEffect.Rosso;
import temperatureEffect.TemperatureEffect;
import umontreal.iro.lecuyer.probdist.NormalDist; import umontreal.iro.lecuyer.probdist.NormalDist;
import umontreal.iro.lecuyer.randvar.NormalGen; import umontreal.iro.lecuyer.randvar.NormalGen;
...@@ -29,6 +31,8 @@ public class SurviveAfterReproduction extends AquaNismsGroupProcess<DiadromousFi ...@@ -29,6 +31,8 @@ public class SurviveAfterReproduction extends AquaNismsGroupProcess<DiadromousFi
private double survivalRateAfterReproduction = 0.1; private double survivalRateAfterReproduction = 0.1;
private TemperatureEffect temperatureEffect;
private transient NormalGen genNormal; private transient NormalGen genNormal;
/** /**
...@@ -39,7 +43,9 @@ public class SurviveAfterReproduction extends AquaNismsGroupProcess<DiadromousFi ...@@ -39,7 +43,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.temperatureEffect = new Rosso(0., 15., 22.);
System.out.println((new XStream(new DomDriver())).toXML(surviveAfterReproduction));
} }
......
/**
* 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