Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions RUFAS/biophysical/feed_storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def process_degradations(self, weather: Weather, time: RufasTime) -> None:
}
total_gaseous_dry_matter_loss = 0.0
for crop in self.stored:
if crop.config_name in GRAIN_CROPS:
if crop.config_name in GRAIN_CROPS or crop.dry_matter_mass <= 0.0:
continue
degraded_crop_values = self._calculate_degradation_values(crop, weather, time)
total_gaseous_dry_matter_loss += degraded_crop_values["gaseous_dry_matter_loss"]
Expand Down Expand Up @@ -268,6 +268,8 @@ def project_degradations(
for crop in crops:
if crop.config_name in GRAIN_CROPS:
continue
if crop.dry_matter_mass <= 0.0:
continue
degraded_crop_values = self._calculate_degradation_values(crop, weather, time)
last_time_degraded = degraded_crop_values["last_time_degraded"]
del degraded_crop_values["gaseous_dry_matter_loss"]
Expand Down Expand Up @@ -298,6 +300,11 @@ def _calculate_degradation_values(self, crop: HarvestedCrop, weather: Weather, t
"""
weather_conditions = self._get_conditions(crop.last_time_degraded, time, weather)
gaseous_dry_matter_loss = self.calculate_dry_matter_loss_to_gas(crop, weather_conditions, time)

if isinstance(gaseous_dry_matter_loss, complex):
print("gaseous dm loss ",gaseous_dry_matter_loss)
if crop.dry_matter_mass < 0:
print(self.crop_name, " DM mass: ", crop.dry_matter_mass)
crude_protein_percent = self.recalculate_nutrient_percentage(
crop.crude_protein_percent,
self.crude_protein_loss_coefficient,
Expand Down Expand Up @@ -366,9 +373,15 @@ def _calculate_mass_attributes_after_loss(
these two attributes have been set, the dry matter percentage is recalculated and set.

"""
new_dry_matter_mass = crop.dry_matter_mass - dry_matter_loss
new_fresh_mass = crop.fresh_mass - (dry_matter_loss + moisture_loss)
if new_fresh_mass == 0.0:
new_dry_matter_mass = max(crop.dry_matter_mass - dry_matter_loss, 0.0)

if new_dry_matter_mass > 0.0:
new_fresh_mass = crop.fresh_mass - (dry_matter_loss + moisture_loss)
else:
new_fresh_mass = 0.0


if new_fresh_mass == 0.0 or new_dry_matter_mass <= 0.0:
dry_matter_percentage = 0.0
else:
dry_matter_percentage = new_dry_matter_mass / new_fresh_mass * GeneralConstants.FRACTION_TO_PERCENTAGE
Expand Down Expand Up @@ -834,6 +847,11 @@ def recalculate_nutrient_percentage(
return 0.0

fraction_of_nutrient_in_lost_dry_matter = loss_coefficient * dry_matter_loss_fraction
if isinstance(initial_nutrient_fraction, complex) :
print(initial_nutrient_fraction)
if isinstance(fraction_of_nutrient_in_lost_dry_matter, complex) :
print(fraction_of_nutrient_in_lost_dry_matter)

if initial_nutrient_fraction < fraction_of_nutrient_in_lost_dry_matter:
info_map = {
"class": self.__class__.__name__,
Expand Down
9 changes: 6 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ A **changelog** is a structured record of changes made to the codebase over time

### Current version

v1.0.0
v1.0.2

### Next Version Updates
### v1.0.2

- [3020](https://github.com/RuminantFarmSystems/RuFaS/pull/3020) - [minor change] [NoInputChange] [OutputChange] Corrected manure application ammonia composition calculation

### v1.0.1

- [2994](https://github.com/RuminantFarmSystems/RuFaS/pull/2994) - [minor change] [NoInputChange] [OutputChange] Adds minimums to urine nitrogen equation.
- [2997](https://github.com/RuminantFarmSystems/RuFaS/pull/2997) - [minor change] [NoInputChange] [OutputChange] Updates throughput in tractor dataset for combine headers.
- [2998](https://github.com/RuminantFarmSystems/RuFaS/pull/2998) - [minor change] [NoInputChange] [OutputChange] Moved changelog entries to reflect what was in v1.0. Brought changes in 2994 and 2997 into one branch.
- [3020](https://github.com/RuminantFarmSystems/RuFaS/pull/3020) - [minor change] [NoInputChange] [OutputChange] Corrected manure application ammonia composition calculation

### v1.0.0

Expand Down