Commit 1ef3f6cd authored by Laura Meier's avatar Laura Meier
Browse files

Initial commit for publication

parents
.metadata/
.project
.classpath
bin/
This diff is collapsed.
/*
* Main for run application
*/
package application;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.image.Image;
//import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
/**
*
* @author Laura Meier
* @version 05.07.21
*/
public class Main extends Application {
private Stage primaryStage;
private AnchorPane rootLayout;
public static int varPar1;
public static double varPar2;
@Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("Mastiff Modell");
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("Icon_Mastiff2.png")));
initRootLayout();
}
/**
* Initializes the root layout.
*/
public void initRootLayout() {
try {
// Load root layout from fxml file.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("view/MainLayout.fxml"));
rootLayout = loader.load();
// Show the scene containing the root layout.
Scene scene = new Scene(rootLayout);
primaryStage.setScene(scene);
primaryStage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
if(args.length != 0) {
varPar1 = Integer.valueOf(args[0]);
varPar2 = Double.valueOf(args[1]);
}
launch(args);
}
}
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
\ No newline at end of file
package application.view;
/**
*
* @author Laura Meier
* @version 05.07.21
*/
public class MySegment {
private int segID;
private String LUT;
private double shade;
private double epsi;
private double mu;
private double delta;
private double nut;
private double beta1;
private double Binit;
private int limpet1;
private int limpet2;
private int mayfly;
private int chironomid;
private int stonefly1;
private int stonefly2;
private int stonefly3;
private double herbi;
private double insect;
public MySegment(int segID, String LUT, double shade , double epsi, double mu, double delta, double nut, double beta1, double Binit, int limpet1, int limpet2, int mayfly, int chironomid, int stonefly1, int stonefly2, int stonefly3, double herbi, double insect) {
this.segID = segID;
this.LUT = LUT;
this.shade = shade;
this.epsi = epsi;
this.mu = mu;
this.delta = delta;
this.nut = nut;
this.beta1 = beta1;
this.Binit = Binit;
this.limpet1 = limpet1;
this.limpet2 = limpet2;
this.mayfly = mayfly;
this.chironomid = chironomid;
this.stonefly1 = stonefly1;
this.stonefly2 = stonefly2;
this.stonefly3 = stonefly3;
this.herbi = herbi;
this.insect = insect;
}
// ******** Getter and Setter methods *********
public double getBeta1() {
return beta1;
}
public void setBeta1(double beta1) {
this.beta1 = beta1;
}
public double getNut() {
return nut;
}
public void setNut(double nut) {
this.nut = nut;
}
public double getHerbi() {
return herbi;
}
public void setHerbi(double herbi) {
this.herbi = herbi;
}
public double getInsect() {
return insect;
}
public void setInsect(double insect) {
this.insect = insect;
}
public int getSegID() {
return segID;
}
public void setSegID(int segID) {
this.segID = segID;
}
public String getLUT() {
return LUT;
}
public void setLUT(String LUT) {
this.LUT = LUT;
}
public double getShade() {
return shade;
}
public void setShade(double shade) {
this.shade = shade;
}
public double getEpsi() {
return epsi;
}
public void setEpsi(double epsi) {
this.epsi = epsi;
}
public double getMu() {
return mu;
}
public void setMu(double mu) {
this.mu = mu;
}
public double getDelta() {
return delta;
}
public void setDelta(double delta) {
this.delta = delta;
}
public double getBinit() {
return Binit;
}
public void setBinit(double binit) {
Binit = binit;
}
public int getLimpet1() {
return limpet1;
}
public void setLimpet1(int limpet1) {
this.limpet1 = limpet1;
}
public int getLimpet2() {
return limpet2;
}
public void setLimpet2(int limpet2) {
this.limpet2 = limpet2;
}
public int getMayfly() {
return mayfly;
}
public void setMayfly(int mayfly) {
this.mayfly = mayfly;
}
public int getChironomid() {
return chironomid;
}
public void setChironomid(int chironomid) {
this.chironomid = chironomid;
}
public int getStonefly1() {
return stonefly1;
}
public void setStonefly1(int stonefly1) {
this.stonefly1 = stonefly1;
}
public int getStonefly2() {
return stonefly2;
}
public void setStonefly2(int stonefly2) {
this.stonefly2 = stonefly2;
}
public int getStonefly3() {
return stonefly3;
}
public void setStonefly3(int stonefly3) {
this.stonefly3 = stonefly3;
}
}
/*
* Species based on chironomid life cycle
*/
package rivermodel;
/**
*
* @author Laura Meier
* @version 05.07.21
*/
public class Chironomid{
public static int codeSpecies = 3;
public static int ovipositionM;
public static int hatchingM;
public static int adultM;
public static int deathM;
public static double offspring; // = 25;
public static double mortalityRate; // = 0.28;//0.24; //0.2; //increased without predator //0.24
public static double quality = 1;
public static double bodymass;
public static double IGmax = 42.89;
public static double Tref = 14.5;
public static double sensitivity = 1;
public static double compS;
public static double probstay; // = 0.15;
public static double probup; // = 0.6;
public static double probdown; // = 1- probup;
public static double distmeanup; // = 3;
public static double distmeandown; // = 2;
public static double[] tempThres = {13.0,-0.005,1.065}; //threshold,m,b
//Chironomid specific parameters
static int[] ovipositionMC = {10,4,6,8}; //{2,4,6,8,10};
static int[] adultMC = {4,6,8,10}; // {4,6,8,10,2};
static int[] deathMC = {5,7,9,2}; //{5,7,9,11,3};
static int hatchingT = 1;
/**
* Set parameter adultT, maxLife, ovipositionM by bornTS
*/
public static void setParam() {
int bornTS = setChironomidBornTs();
if (bornTS%12 == ovipositionMC[0]) {
hatchingM = (bornTS + 5) %12;
adultM = adultMC[0];
deathM = deathMC[0];
ovipositionM = ovipositionMC[1];
} else
if (bornTS%12 == ovipositionMC[1]) {
hatchingM = (bornTS + hatchingT) %12;
adultM = adultMC[1];
deathM = deathMC[1];
ovipositionM = ovipositionMC[2];
} else
if (bornTS%12 == ovipositionMC[2]) {
hatchingM = (bornTS + hatchingT) %12;
adultM = adultMC[2];
deathM = deathMC[2];
ovipositionM = ovipositionMC[3];
} else
if (bornTS%12 == ovipositionMC[3]) {
hatchingM = (bornTS + hatchingT) %12;
adultM = adultMC[3];
deathM = deathMC[3];
ovipositionM = ovipositionMC[0];
} else {
System.out.println("Chironomid does not fit to regular oviposition dates!");
System.out.println(SimulationMain.month + " "+ bornTS + " ");
}
}
/**
* Look for bornts for chironomid cohort
* @return time step in which the chironomid is born
*/
public static int setChironomidBornTs() {
int ovipositionlast = 0;
if(SimulationMain.month %12 >= 4 && SimulationMain.month %12 < 6) {
ovipositionlast = 4;
}else if(SimulationMain.month %12 >= 6 && SimulationMain.month %12 < 8) {
ovipositionlast = 6;
}else if(SimulationMain.month %12 >= 8 && SimulationMain.month %12 < 10) {
ovipositionlast = 8;
}else if(SimulationMain.month %12 >= 10 || SimulationMain.month %12 < 4) {
ovipositionlast = 10;
}else System.out.println("Something went wrong setChironomidBornTS: "+ SimulationMain.month%12);
return ovipositionlast;
}
/**
* Set bodymass - growth
* @return new bodymass
*/
public static double setBodymass() {
switch ((SimulationMain.week + 48 - (hatchingM*4)) %48) {
case -1:
case 0: bodymass = 0.051; break;
case 1: bodymass = 0.22; break;
case 2: bodymass = 0.39; break;
case 3: bodymass = 0.56; break;
case 4: bodymass = 0.74; break;
default: bodymass = 0.74;
}
return bodymass;
}
/**
* Exponential decreasing disperal distance (upstream)
* @param x segment
* @return probability to start in segment x to fly upstream and land in current segment
*/
private static double fup(double x) {
return 1/distmeanup*Math.exp(x/distmeanup);
}
/**
* Exponential decreasing disperal distance (downstream)
* @param x segment
* @return probability to start in segment x to fly downstream and land in current segment
*/
private static double fdown(double x) {
return 1/distmeandown*Math.exp(-x/distmeandown);
}
/**
* Species distribution kernel for disperal of imagines
* @param Seg start segment of imagines
* @return probability to land in current segment
*/
public static double d(double Seg) {
if(Seg > 0) return (1-probstay)*probdown*fdown(Seg);
else if(Seg < 0) return (1-probstay)*probup*fup(Seg);
else return probstay; //k == i --> Seg = 0
}
/**
* Set mortality rate
* @param newMort new mortality rate
*/
public static void setMort(double newMort) {
mortalityRate = newMort;
}
/**
* Set probability to stay in the same segment
* @param v probability to stay
*/
public static void setProbStay(double v) {
probstay = v;
}
/**
* Set probability to fly upstream
* @param v probability to fly upstream
*/
public static void setProbUp(double v) {
probup = v;
}
/**
* Set probability to fly downstream
* @param v probability to fly downstream
*/
public static void setProbDown(double v) {
probdown = v;
}
/**
* Set mean distance for upstream flight
* @param v mean distance
*/
public static void setDistUp(double v) {
distmeanup = v;
}
/**
* Set mean distance for downstream dlight
* @param v mean distance
*/
public static void setDistDown(double v) {
distmeandown = v;
}
/**
* Set offspring
* @param off amount offspring
*/
public static void setOffspring(double off) {
offspring = off;
}
}
/*
* Species based on limpet life cycle
*/
package rivermodel;
/**
*
* @author Laura Meier
* @version 05.07.21
*/
public class Limpet {
public static int codeSpecies = 1;
public static int ovipositionM = 4;
public static int hatchingM = 6;
public static int adultM = 4;
public static int deathM = 6;//7;
public static double offspring;// = 50;
public static double mortalityRate;// = 0.04;
public static double quality = 2;
public static double[] bodymass = new double[2];
public static double IGmax = 3.27; //3.44;
public static double Tref = 15.5;
public static double sensitivity = 0.0;
public static double compS;
public static double delta = 1.0;
public static double[] tempThres = {18.0,-0.055,1.09}; //threshold,m,b
/**
* Set bodymass - growth
* @param year 1st or 2nd year limpet
* @return new bodymass
*/
public static double setBodymass(int year) {
double bodylength;
if(year == 0) {
switch ((SimulationMain.week + 48 - (hatchingM*4)) %48) {
case 0: bodylength = 1.0; break;
case 1: bodylength = 1.025; break;
case 2: bodylength = 1.05; break;
case 3: bodylength = 1.075; break;
case 4: bodylength = 1.1; break;
case 5: bodylength = 1.25; break;
case 6: bodylength = 1.4; break;
case 7: bodylength = 1.55; break;
case 8: bodylength = 1.7; break;
case 9: bodylength = 1.775; break;
case 10: bodylength = 1.85; break;
case 11: bodylength = 1.925; break;
case 12: bodylength = 2.0; break;
case 13: bodylength = 2.05; break;
case 14: bodylength = 2.1; break;
case 15: bodylength = 2.15; break;
case 16: bodylength = 2.2; break;
case 17: bodylength = 2.275; break;
case 18: bodylength = 2.350; break;
case 19: bodylength = 2.425; break;
case 20: bodylength = 2.5; break;
case 21: bodylength = 2.525; break;
case 22: bodylength = 2.55; break;
case 23: