Commit 97625378 by patrick.lambert

### new temprature effect

parent c8e7b6ca
 /** * 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 . */ package temperatureEffect; /** * Svirezhev, Yu. M., Krysanova, V. P. & Voinov, A. A. (1984) Mathematical modelling of a fish pond ecosystem. * Ecological Modelling 21, 315–337. */ public class ModifiedLehman implements TemperatureEffect { /** * * @unit */ private static final long serialVersionUID = -5673558595613160001L; /** * 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 lover than exp(-4.6) = 1% * * @unit °C */ private double Tmax; private transient double alpha_low; private transient double alpha_high; @Override public double getTemperatureEffect(double temperature) { if (temperature < Topt) { double delta = (Topt - temperature) * (Topt - temperature); return Math.exp(alpha_low * delta * delta); } else { double delta = (temperature - Topt) * (temperature - Topt); return Math.exp(alpha_high * delta * delta); } } public ModifiedLehman(double tmin, double topt, double tmax) { super(); this.Tmin = tmin; this.Topt = topt; this.Tmax = tmax; // to avoid the slow math.pow(, 4) double delta = (Topt - Tmin) * (Topt - Tmin); alpha_low = -4.6 / (delta * delta); delta = (Tmax - Topt) * (Tmax - Topt); alpha_high = -4.6 / (delta * delta); } public static void main(String[] args) { ModifiedLehman test = new ModifiedLehman(10., 20., 30.); for (double temperature = 0; temperature < 40.; temperature++) { System.out.println(temperature + " -> " + test.getTemperatureEffect(temperature)); } } }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!