From b05a5d85af994b404b495d5bcfddcd49bc2d4b1b Mon Sep 17 00:00:00 2001
From: Poulet Camille <camille.poulet@irstea.priv>
Date: Fri, 19 Apr 2019 09:53:17 +0200
Subject: [PATCH] FishNutrient Influx(N,P) for death before reproduction, death
 after reproduction and survival after reproduction

---
 src/main/java/species/FishNutrient.java | 151 ++++++++++++++++++++----
 1 file changed, 125 insertions(+), 26 deletions(-)

diff --git a/src/main/java/species/FishNutrient.java b/src/main/java/species/FishNutrient.java
index 44340a7..87ce18a 100644
--- a/src/main/java/species/FishNutrient.java
+++ b/src/main/java/species/FishNutrient.java
@@ -35,27 +35,37 @@ public class FishNutrient {
 	private double GSImalePre =.07;
 
 	// Si on ne possède pas wT post reproduction 
-	
-		private double aLWfemalePost = 0.; // paramīŋŊtre "a" de la relation taille/poids avec Lt en cm
-		private double bLWfemalePost  = 0.; // paramīŋŊtre "b" de la relation taille/poids
-		private double GSIfemalePost=0.10;	
-		private double aLWmalePost = 0.; // paramīŋŊtre "a" de la relation taille/poids avec Lt en cm
-		private double bLWmalePost = 0.; // paramīŋŊtre "b" de la relation taille/poids
-		private double GSImalePost =.07;
-		
-	
-	
+
+	/**
+	 *  paramīŋŊtre "a" de la relation taille/poids avec Lt en cm
+	 */
+	private double aLWfemalePost = 0.; // paramīŋŊtre "a" de la relation taille/poids avec Lt en cm
+	private double bLWfemalePost  = 0.; // paramīŋŊtre "b" de la relation taille/poids
+	private double GSIfemalePost=0.10;	
+	private double aLWmalePost = 0.; // paramīŋŊtre "a" de la relation taille/poids avec Lt en cm
+	private double bLWmalePost = 0.; // paramīŋŊtre "b" de la relation taille/poids
+	private double GSImalePost =.07;
+
+	//Si on possede WT post reproduction 
+
+	private double CoeffLossWeight = 0.; 
+
 	//Valeurs de Haskell pour A. sapidissima -- A rechercher pour Alosa alosa
-	
-		private double compoNpreMale = 2.921; 
-		private double compoPpreMale = 0.662;
-		private double compoNpreFemale = 2.917;
-		private double compoPpreFemale = 0.725;
-		
-		private double compoNpostMale = 2.790 ;
-		private double compoPpostMale = 0.961;
-		private double compoNpostFemale = 3.216 ;
-		private double compoPpostFemale = 0.997;
+
+	private double compoNpreMale = 2.921; 
+	private double compoPpreMale = 0.662;
+	private double compoNpreFemale = 2.917;
+	private double compoPpreFemale = 0.725;
+
+	private double compoNpostMale = 2.790 ;
+	private double compoPpostMale = 0.961;
+	private double compoNpostFemale = 3.216 ;
+	private double compoPpostFemale = 0.997;
+
+	private double compoNoocyte =0.0;
+	private double compoNsperm =0.0;
+	private double compoPoocyte =0.0;
+	private double compoPsperm =0.0;
 
 
 	/**
@@ -65,25 +75,114 @@ public class FishNutrient {
 		// TODO Auto-generated constructor stub
 	}
 
-	public void computeNP(DiadromousFish fish) {
+	/**
+	 * compute the N and P fluxes for a single fish (in the super individual)
+	 *  that dies after spawning (gametes expelling) 
+	 * @param fish
+	 */
+
+	public double[] computeInportNPforDeathBeforeSpawning(DiadromousFish fish) {
+		double totalWeightPre; 
+
+		double [] inportNP = new double[2]; 
+		inportNP[0] = 0; 
+		inportNP[1] = 0; 
+
+		if (fish.getStage()== Stage.MATURE) {
+			if(fish.getGender()== Gender.FEMALE) {
+				totalWeightPre = aLWfemalePre * Math.pow(fish.getLength(), bLWfemalePre);
+				//totalWeightPost = totalWeightPre * (1-GSIfemalePost)+ totalWeightPost * GSIfemalePost * CoeffLossWeight
+				inportNP[0] = totalWeightPre * compoNpreFemale;
+				inportNP[1] = totalWeightPre * compoPpreFemale;
+			}
+			else if (fish.getGender()== Gender.MALE) {
+				totalWeightPre = aLWmalePre * Math.pow(fish.getLength(), bLWmalePre);
+				//totalWeightPost = totalWeightPre * (1-GSImalePost)+ totalWeightPost * GSImalePost * CoeffLossWeight
+				inportNP[0] = totalWeightPre * compoNpreMale; 
+				inportNP[1] = totalWeightPre * compoPpreMale; 	
+			}
+			else {
+				totalWeightPre= Double.NaN; 
+				inportNP[0] = 0.; 
+				inportNP[1] = 0; 
+			}
+		}
+		return inportNP;
+
+	}
+
+	public double[] computeInportNPforDeathAfterSpawning(DiadromousFish fish) {
 		double totalWeightPre, totalWeightPost;
-		
+
+		double[] inportNP = new double[2]; //Pour faire un tableau ā deux colonnes, N et P 
+		inportNP[0] = 0.;
+		inportNP[1] = 0.;
+
 		if (fish.getStage() == Stage.MATURE) {
 			if (fish.getGender() == Gender.FEMALE ) {
 				totalWeightPre = aLWfemalePre * Math.pow(fish.getLength(), bLWfemalePre);
 				totalWeightPost = aLWfemalePost * Math.pow(fish.getLength(), bLWfemalePost);
-				// totalWeightPost = totalWeightPre * GSIfemalePre;
+				//totalWeightPost = totalWeightPre * (1-GSIfemalePost)+ totalWeightPost * GSIfemalePost * CoeffLossWeight
+				inportNP[0] = totalWeightPost * compoNpostFemale + (totalWeightPre - totalWeightPost) * compoNoocyte;
+				inportNP[1] = totalWeightPost * compoPpostFemale + (totalWeightPre - totalWeightPost) * compoPoocyte;
 			}
 			else if (fish.getGender() == Gender.MALE) {
 				totalWeightPre = aLWmalePre * Math.pow(fish.getLength(), bLWmalePre);
 				totalWeightPost = aLWmalePost * Math.pow(fish.getLength(), bLWmalePost);
-				// totalWeightPost =  totalWeightPre * GSImalePre;
+				//totalWeightPost = totalWeightPre * (1-GSImalePost)+ totalWeightPost * GSImalePost * CoeffLossWeight
+				inportNP[0] = totalWeightPost * compoNpostMale + (totalWeightPre - totalWeightPost) * compoNsperm;
+				inportNP[1] = totalWeightPost * compoPpostMale + (totalWeightPre - totalWeightPost) * compoPsperm;
 			}
 			else {
 				totalWeightPre = Double.NaN;
 				totalWeightPost = 0.;
+				inportNP[0]=0.;
+				inportNP[1]=0.;
+			}
+		}
+
+		return inportNP;	
+	}
+
+	public double [] computeInportNPforSurvivalAfterSpawning(DiadromousFish fish) {
+		double totalWeightPre, totalWeightPost;
+
+		double[]inportNP = new double [2]; 
+		inportNP[0]= 0;
+		inportNP[1] = 0; 
+
+		if (fish.getStage()== Stage.MATURE) {
+			if (fish.getGender()==Gender.FEMALE){
+				totalWeightPre = aLWfemalePre * Math.pow(fish.getLength(), bLWfemalePre);
+				totalWeightPost = aLWfemalePost * Math.pow(fish.getLength(), bLWfemalePost);
+				//totalWeightPost = totalWeightPre * (1-GSImalePost)+ totalWeightPost * GSImalePost * CoeffLossWeight
+				inportNP[0] = (totalWeightPre - totalWeightPost)* compoNoocyte; 
+				inportNP[1] = (totalWeightPre - totalWeightPost)* compoPoocyte; 	
+			}
+			else if (fish.getGender()== Gender.MALE) {
+
+				totalWeightPre = aLWfemalePre * Math.pow(fish.getLength(), bLWmalePre);
+				totalWeightPost = aLWfemalePost * Math.pow(fish.getLength(), bLWmalePost);
+				//totalWeightPost = totalWeightPre * (1-GSImalePost)+ totalWeightPost * GSImalePost * CoeffLossWeight
+				inportNP[0] = (totalWeightPre - totalWeightPost)* compoNsperm; 
+				inportNP[1] = (totalWeightPre - totalWeightPost)* compoPsperm; 
+
+			}
+			else {
+				totalWeightPre= Double.NaN; 
+				totalWeightPost = 0.; 
+				inportNP[0] = 0.; 
+				inportNP[1] = 0;
+
 			}
-			
 		}
+
+		return inportNP; 
 	}
-}
\ No newline at end of file
+
+} 
+
+
+
+
+
-- 
GitLab