Commit 19ad5295 authored by Poulet Camille's avatar Poulet Camille
Browse files

Compute total fluxes for import and export

parent a2aebf7f
...@@ -9,8 +9,13 @@ import environment.Time; ...@@ -9,8 +9,13 @@ import environment.Time;
import environment.Time.Season; import environment.Time.Season;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess; import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List; import java.util.List;
import java.util.Map;
import miscellaneous.Duo; import miscellaneous.Duo;
import species.DiadromousFish.Stage;
import org.openide.util.lookup.ServiceProvider; import org.openide.util.lookup.ServiceProvider;
@ServiceProvider(service = AquaNismsGroupProcess.class) @ServiceProvider(service = AquaNismsGroupProcess.class)
...@@ -28,19 +33,48 @@ public class MigrateToSea extends AquaNismsGroupProcess<DiadromousFish, Diadromo ...@@ -28,19 +33,48 @@ public class MigrateToSea extends AquaNismsGroupProcess<DiadromousFish, Diadromo
if (Time.getSeason(group.getPilot()) == seaMigrationSeason ){ if (Time.getSeason(group.getPilot()) == seaMigrationSeason ){
Basin destination; Basin destination;
List<Duo<DiadromousFish,Basin>> fishesToMove = new ArrayList<Duo<DiadromousFish,Basin>>();
for (int i = 0; i < group.getEnvironment().getRiverBasins().length; i++) { //On crer la Map pour stocker les flux d'export
RiverBasin basin = group.getEnvironment().getRiverBasins()[i]; Map<String, Double> totalOutputFluxes = new Hashtable<String, Double>();
List<DiadromousFish> fishes = basin.getFishs(group); List<Duo<DiadromousFish,Basin>> fishesToMove = new ArrayList<Duo<DiadromousFish,Basin>>();
if (fishes!=null) for (DiadromousFish fish : fishes) { for (int i = 0; i < group.getEnvironment().getRiverBasins().length; i++) {
destination = group.getEnvironment().getAssociatedSeaBasin(fish.getPosition()); RiverBasin basin = group.getEnvironment().getRiverBasins()[i];
fishesToMove.add(new Duo<DiadromousFish, Basin>(fish, destination)); //Fish move to sea and compute the related export of nutrients
} List<DiadromousFish> fishes = basin.getFishs(group);
}
for (Duo<DiadromousFish,Basin> duo : fishesToMove) { // ON r-initialise notre map pour chauqe bassin
duo.getFirst().moveTo(group.getPilot(), duo.getSecond(), group); for (String nutrient : group.getFishNutrient().getNutrientsOfInterest()) {
} totalOutputFluxes.put(nutrient, 0.);
} }
totalOutputFluxes.put("biomass", 0.); //cration de la biomasse
if (fishes!=null) {
for (DiadromousFish fish : fishes) {
destination = group.getEnvironment().getAssociatedSeaBasin(fish.getPosition());
fishesToMove.add(new Duo<DiadromousFish, Basin>(fish, destination)); //Mentionne la sortie d'un poisson de la boucle
double biomass = group.getFishNutrient().getWeight(fish) * fish.getAmount();
if (fish.getStage()==Stage.IMMATURE) {
Map <String, Double> aFluxExportedByJuveniles= group.getFishNutrient().computeNutrientsExportForJuveniles(fish);
for (String nutrient: aFluxExportedByJuveniles.keySet()) {
totalOutputFluxes.put(nutrient,totalOutputFluxes.get(nutrient) + aFluxExportedByJuveniles.get(nutrient) * fish.getAmount());
}
totalOutputFluxes.put("biomass", totalOutputFluxes.get("biomass") + biomass);
}
}
}
for (Duo<DiadromousFish,Basin> duo : fishesToMove) {
duo.getFirst().moveTo(group.getPilot(), duo.getSecond(), group); //on dplace les poissons dans le fichier MoveTo et on dnote la destination du poisson.
}
System.out.println(group.getPilot().getCurrentTime() + "; " + Time.getYear(group.getPilot()) + ";" + Time.getSeason(group.getPilot()) + ";EXPORT;"
+ basin.getName() + "; " + totalOutputFluxes);
}
}
} }
} }
\ No newline at end of file
...@@ -110,11 +110,12 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG ...@@ -110,11 +110,12 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
if (fishInBasin != null){ if (fishInBasin != null){
//Initiate the total fluxes for this basin //Initiate the total fluxes for this basin
Map<String, Double> totalFluxes = new Hashtable<String, Double>(); //On crer la Map pour stocker les flux Map<String, Double> totalInputFluxes = new Hashtable<String, Double>(); //On crer la Map pour stocker les flux
for (String nutrient : group.getFishNutrient().getNutrientsOfInterest()) { for (String nutrient : group.getFishNutrient().getNutrientsOfInterest()) {
totalFluxes.put(nutrient, 0.); // ON MET A JOUR NOTRE map totalInputFluxes.put(nutrient, 0.); // ON MET A JOUR NOTRE map
} }
totalInputFluxes.put("biomass",0.);
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
// definition of the stock recruiment relationship // definition of the stock recruiment relationship
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
...@@ -188,30 +189,44 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG ...@@ -188,30 +189,44 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
// survival after reproduction (semelparity or iteroparity) of SI (change the amount of the SI) // survival after reproduction (semelparity or iteroparity) of SI (change the amount of the SI)
survivalAmount = Miscellaneous.binomialForSuperIndividual(group.getPilot(), fish.getAmount(), survivalRateAfterReproduction); survivalAmount = Miscellaneous.binomialForSuperIndividual(group.getPilot(), fish.getAmount(), survivalRateAfterReproduction);
if (survivalAmount > 0) { double biomass = 0.;
if (survivalAmount > 0) {// SUperindividu est encore vivant mais il perd des effectifs
//Export for fishes survived after spawning (survivalAmount) : excretion + gametes //Export for fishes survived after spawning (survivalAmount) : excretion + gametes
Map <String, Double> aFluxAfterSurvival = group.getFishNutrient().computeNutrientsInputForSurvivalAfterSpawning(fish); Map <String, Double> aFluxAfterSurvival = group.getFishNutrient().computeNutrientsInputForSurvivalAfterSpawning(fish);
//Export for fishes that dies after spawning (fish.getAmount - survivalAmount): excretion + gametes + carcasse
Map<String, Double> aFluxForDeadFish = group.getFishNutrient().computeNutrientsInputForDeathAfterSpawning(fish);
for (String nutrient: aFluxAfterSurvival.keySet()) { for (String nutrient: aFluxAfterSurvival.keySet()) {
totalFluxes.put(nutrient,totalFluxes.get(nutrient) + aFluxAfterSurvival.get(nutrient) * survivalAmount); //For survival fish
totalInputFluxes.put(nutrient,totalInputFluxes.get(nutrient) + aFluxAfterSurvival.get(nutrient) * survivalAmount);
//For dead fish
totalInputFluxes.put(nutrient,totalInputFluxes.get(nutrient) + aFluxForDeadFish.get(nutrient) * (fish.getAmount() - survivalAmount));
} }
fish.setAmount(survivalAmount); }
//compute biomass for dead fish
biomass = group.getFishNutrient().getWeight(fish) * (fish.getAmount() - survivalAmount);
totalInputFluxes.put("biomass", totalInputFluxes.get("biomass") + biomass);
//update the amount of individual in the super-individual
fish.setAmount(survivalAmount);
}
else { else {
//Le superinvidu est mort !!!
deadFish.add(fish); deadFish.add(fish);
//Export for fished died before spawning (fish.getAmount): carcasses + excretion + gametes //Export for fished died before spawning (fish.getAmount): carcasses + excretion + gametes
Map<String, Double> aFlux = group.getFishNutrient().computeNutrientsInputForDeathAfterSpawning(fish); // Map<String, Double> aFlux = group.getFishNutrient().computeNutrientsInputForDeathAfterSpawning(fish); //
for (String nutrient: aFlux.keySet()) { for (String nutrient: aFlux.keySet()) {
totalFluxes.put(nutrient,totalFluxes.get(nutrient) + aFlux.get(nutrient) * (fish.getAmount()) - survivalAmount); //Fish.getAmount - survivalAmount = total fishes died. totalInputFluxes.put(nutrient,totalInputFluxes.get(nutrient) + aFlux.get(nutrient) * fish.getAmount()); //Fish.getAmount - survivalAmount = total fishes died.
} }
biomass = group.getFishNutrient().getWeight(fish) * (fish.getAmount());
totalInputFluxes.put("biomass", totalInputFluxes.get("biomass") + biomass);
} }
} }
} }
// keep the spawner number // keep the spawner number
...@@ -366,15 +381,12 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG ...@@ -366,15 +381,12 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
// Remove deadfish and compute the related nutrient fluxes // Remove deadfish and compute the related nutrient fluxes
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
for (DiadromousFish fish : deadFish){ for (DiadromousFish fish : deadFish){
group.removeAquaNism(fish); group.removeAquaNism(fish);
} }
deadFish.clear(); deadFish.clear();
System.out.println(group.getPilot().getCurrentTime() + "; " + Time.getYear(group.getPilot()) + ";" + Time.getSeason(group.getPilot()) + ";" System.out.println(group.getPilot().getCurrentTime() + "; " + Time.getYear(group.getPilot()) + ";" + Time.getSeason(group.getPilot()) + ";IMPORT;"
+ riverBasin.getName() + "; " + totalFluxes); + riverBasin.getName() + "; " + totalInputFluxes);
} }
else { else {
......
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