Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SimAquaLife
GR3D
Commits
19ad5295
Commit
19ad5295
authored
Jul 15, 2019
by
Poulet Camille
Browse files
Compute total fluxes for import and export
parent
a2aebf7f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/species/MigrateToSea.java
View file @
19ad5295
...
...
@@ -9,8 +9,13 @@ import environment.Time;
import
environment.Time.Season
;
import
fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess
;
import
java.util.ArrayList
;
import
java.util.Hashtable
;
import
java.util.List
;
import
java.util.Map
;
import
miscellaneous.Duo
;
import
species.DiadromousFish.Stage
;
import
org.openide.util.lookup.ServiceProvider
;
@ServiceProvider
(
service
=
AquaNismsGroupProcess
.
class
)
...
...
@@ -28,19 +33,48 @@ public class MigrateToSea extends AquaNismsGroupProcess<DiadromousFish, Diadromo
if
(
Time
.
getSeason
(
group
.
getPilot
())
==
seaMigrationSeason
){
Basin
destination
;
List
<
Duo
<
DiadromousFish
,
Basin
>>
fishesToMove
=
new
ArrayList
<
Duo
<
DiadromousFish
,
Basin
>>();
for
(
int
i
=
0
;
i
<
group
.
getEnvironment
().
getRiverBasins
().
length
;
i
++)
{
RiverBasin
basin
=
group
.
getEnvironment
().
getRiverBasins
()[
i
];
List
<
DiadromousFish
>
fishes
=
basin
.
getFishs
(
group
);
if
(
fishes
!=
null
)
for
(
DiadromousFish
fish
:
fishes
)
{
destination
=
group
.
getEnvironment
().
getAssociatedSeaBasin
(
fish
.
getPosition
());
fishesToMove
.
add
(
new
Duo
<
DiadromousFish
,
Basin
>(
fish
,
destination
));
}
}
for
(
Duo
<
DiadromousFish
,
Basin
>
duo
:
fishesToMove
)
{
duo
.
getFirst
().
moveTo
(
group
.
getPilot
(),
duo
.
getSecond
(),
group
);
}
}
//On crer la Map pour stocker les flux d'export
Map
<
String
,
Double
>
totalOutputFluxes
=
new
Hashtable
<
String
,
Double
>();
List
<
Duo
<
DiadromousFish
,
Basin
>>
fishesToMove
=
new
ArrayList
<
Duo
<
DiadromousFish
,
Basin
>>();
for
(
int
i
=
0
;
i
<
group
.
getEnvironment
().
getRiverBasins
().
length
;
i
++)
{
RiverBasin
basin
=
group
.
getEnvironment
().
getRiverBasins
()[
i
];
//Fish move to sea and compute the related export of nutrients
List
<
DiadromousFish
>
fishes
=
basin
.
getFishs
(
group
);
// ON r-initialise notre map pour chauqe bassin
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
src/main/java/species/ReproduceAndSurviveAfterReproductionWithDiagnose.java
View file @
19ad5295
...
...
@@ -110,11 +110,12 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
if
(
fishInBasin
!=
null
){
//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
>
total
Input
Fluxes
=
new
Hashtable
<
String
,
Double
>();
//On crer la Map pour stocker les flux
for
(
String
nutrient
:
group
.
getFishNutrient
().
getNutrientsOfInterest
())
{
totalFluxes
.
put
(
nutrient
,
0
.);
// ON MET A JOUR NOTRE map
total
Input
Fluxes
.
put
(
nutrient
,
0
.);
// ON MET A JOUR NOTRE map
}
totalInputFluxes
.
put
(
"biomass"
,
0
.);
// --------------------------------------------------------------------------------------------------
// definition of the stock recruiment relationship
// --------------------------------------------------------------------------------------------------
...
...
@@ -188,30 +189,44 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
// survival after reproduction (semelparity or iteroparity) of SI (change the amount of the SI)
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
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
())
{
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
{
//Le superinvidu est mort !!!
deadFish
.
add
(
fish
);
//Export for fished died before spawning (fish.getAmount): carcasses + excretion + gametes
Map
<
String
,
Double
>
aFlux
=
group
.
getFishNutrient
().
computeNutrientsInputForDeathAfterSpawning
(
fish
);
//
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
...
...
@@ -366,15 +381,12 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
// Remove deadfish and compute the related nutrient fluxes
// --------------------------------------------------------------------------------------------------
for
(
DiadromousFish
fish
:
deadFish
){
group
.
removeAquaNism
(
fish
);
}
deadFish
.
clear
();
System
.
out
.
println
(
group
.
getPilot
().
getCurrentTime
()
+
"; "
+
Time
.
getYear
(
group
.
getPilot
())
+
";"
+
Time
.
getSeason
(
group
.
getPilot
())
+
";"
+
riverBasin
.
getName
()
+
"; "
+
totalFluxes
);
System
.
out
.
println
(
group
.
getPilot
().
getCurrentTime
()
+
"; "
+
Time
.
getYear
(
group
.
getPilot
())
+
";"
+
Time
.
getSeason
(
group
.
getPilot
())
+
";
IMPORT;
"
+
riverBasin
.
getName
()
+
"; "
+
total
Input
Fluxes
);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment