From ea9fd184cc0012fadde6db94e81997e466083bbe Mon Sep 17 00:00:00 2001 From: JoeWaddell <109082924+JoeWaddell@users.noreply.github.com> Date: Thu, 9 Apr 2026 11:56:45 -0400 Subject: [PATCH 1/4] added DMI as input logic --- RUFAS/biophysical/animal/herd_manager.py | 1 + .../nutrients/nasem_requirements_calculator.py | 18 +++++++++++------- .../animal/ration/ration_manager.py | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/RUFAS/biophysical/animal/herd_manager.py b/RUFAS/biophysical/animal/herd_manager.py index 7a0c07a025..36c305af0c 100644 --- a/RUFAS/biophysical/animal/herd_manager.py +++ b/RUFAS/biophysical/animal/herd_manager.py @@ -134,6 +134,7 @@ def __init__( self.is_ration_defined_by_user = is_ration_defined_by_user ration_feed_config = self.im.get_data("feed") + RationManager.lac_cow_dry_matter_intake = ration_feed_config["lac_cow_dry_matter_intake"] if self.is_ration_defined_by_user: RationManager.set_user_defined_rations(ration_feed_config) RationManager.set_user_defined_ration_tolerance(ration_feed_config) diff --git a/RUFAS/biophysical/animal/nutrients/nasem_requirements_calculator.py b/RUFAS/biophysical/animal/nutrients/nasem_requirements_calculator.py index c47f77a3dc..3ee64f942f 100644 --- a/RUFAS/biophysical/animal/nutrients/nasem_requirements_calculator.py +++ b/RUFAS/biophysical/animal/nutrients/nasem_requirements_calculator.py @@ -6,6 +6,7 @@ from RUFAS.biophysical.animal.ration.amino_acid import AminoAcidCalculator from RUFAS.general_constants import GeneralConstants from RUFAS.user_constants import UserConstants +from RUFAS.biophysical.animal.ration.ration_manager import RationManager from .nutrition_requirements_calculator import NutritionRequirementsCalculator @@ -657,13 +658,16 @@ def _calculate_dry_matter_intake( """ if lactating: - parity_adjustment_factor = 1 if parity > 1 else 0 - dry_matter_intake_estimate = ( - (3.7 + parity_adjustment_factor * 5.7) - + 0.305 * net_energy_lactation - + 0.022 * body_weight - + (-0.689 - 1.87 * parity_adjustment_factor) * body_condition_score_5 - ) * (1 - (0.212 + parity_adjustment_factor * 0.136) * exp(-0.053 * days_in_milk)) + if RationManager.lac_cow_dry_matter_intake == 0: + parity_adjustment_factor = 1 if parity > 1 else 0 + dry_matter_intake_estimate = ( + (3.7 + parity_adjustment_factor * 5.7) + + 0.305 * net_energy_lactation + + 0.022 * body_weight + + (-0.689 - 1.87 * parity_adjustment_factor) * body_condition_score_5 + ) * (1 - (0.212 + parity_adjustment_factor * 0.136) * exp(-0.053 * days_in_milk)) + else: + dry_matter_intake_estimate = RationManager.lac_cow_dry_matter_intake else: dry_matter_intake_estimate = ( 0.0226 * mature_body_weight * (1 - exp(-1.47 * (body_weight / mature_body_weight))) diff --git a/RUFAS/biophysical/animal/ration/ration_manager.py b/RUFAS/biophysical/animal/ration/ration_manager.py index 4d13355e25..98a11e739f 100644 --- a/RUFAS/biophysical/animal/ration/ration_manager.py +++ b/RUFAS/biophysical/animal/ration/ration_manager.py @@ -34,6 +34,7 @@ class RationManager: user_defined_rations: dict[AnimalCombination, dict[RUFAS_ID, float]] | None tolerance: float | None = 0.0 maximum_ration_reformulation_attempts: int + lac_cow_dry_matter_intake: float @classmethod def set_ration_feeds(cls, ration_config: dict[str, list[int]]) -> None: From f69345e26442f23b65ec1643274e2d5dab5c4636 Mon Sep 17 00:00:00 2001 From: JoeWaddell <109082924+JoeWaddell@users.noreply.github.com> Date: Thu, 9 Apr 2026 11:57:03 -0400 Subject: [PATCH 2/4] updated metadata and default feed input --- input/data/feed/example_Midwest_feed.json | 1 + input/metadata/properties/default.json | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/input/data/feed/example_Midwest_feed.json b/input/data/feed/example_Midwest_feed.json index f0bc11ba7b..fc8a33c426 100644 --- a/input/data/feed/example_Midwest_feed.json +++ b/input/data/feed/example_Midwest_feed.json @@ -186,6 +186,7 @@ ], "tolerance": 0.1 }, + "lac_cow_dry_matter_intake": 200, "max_daily_feed_recalculations_per_year": 4, "allowances": [ { diff --git a/input/metadata/properties/default.json b/input/metadata/properties/default.json index 2d52ff68de..51fe8ba071 100644 --- a/input/metadata/properties/default.json +++ b/input/metadata/properties/default.json @@ -4375,6 +4375,12 @@ "maximum": 365, "default": 4 }, + "lac_cow_dry_matter_intake": { + "type": "number", + "description": "Fixed amount of dry matter intake (kg) for lactating cows. Set to 0 to use NASEM or NRC predicted dry matter intake.", + "minimum": 0, + "default": 0 + }, "allowances": { "type": "array", "properties": { From 723d972014ba1f647be63443ad7ab281b9643aeb Mon Sep 17 00:00:00 2001 From: JoeWaddell <109082924+JoeWaddell@users.noreply.github.com> Date: Thu, 9 Apr 2026 12:01:00 -0400 Subject: [PATCH 3/4] reasonable lac cow DMI --- input/data/feed/example_Midwest_feed.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/data/feed/example_Midwest_feed.json b/input/data/feed/example_Midwest_feed.json index fc8a33c426..de14c207e2 100644 --- a/input/data/feed/example_Midwest_feed.json +++ b/input/data/feed/example_Midwest_feed.json @@ -186,7 +186,7 @@ ], "tolerance": 0.1 }, - "lac_cow_dry_matter_intake": 200, + "lac_cow_dry_matter_intake": 27, "max_daily_feed_recalculations_per_year": 4, "allowances": [ { From 5d0b6a03bab61dd2ecc0f4ab75c6982d2ba8a7a0 Mon Sep 17 00:00:00 2001 From: JoeWaddell <109082924+JoeWaddell@users.noreply.github.com> Date: Tue, 14 Apr 2026 12:57:24 -0400 Subject: [PATCH 4/4] constant changes --- RUFAS/biophysical/animal/animal_module_constants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RUFAS/biophysical/animal/animal_module_constants.py b/RUFAS/biophysical/animal/animal_module_constants.py index a62c5da2d2..da7a859201 100644 --- a/RUFAS/biophysical/animal/animal_module_constants.py +++ b/RUFAS/biophysical/animal/animal_module_constants.py @@ -82,10 +82,10 @@ class AnimalModuleConstants: MILK_LACTOSE: float = 4.85 """Milk lactose content, percentage.""" - DMI_CONSTRAINT_FRACTION: float = 0.30 + DMI_CONSTRAINT_FRACTION: float = 0.00 """The +/- fraction of DMI estimated allowed for ration formulation.""" - DMI_REQUIREMENT_BOOST: float = 1.1 + DMI_REQUIREMENT_BOOST: float = 1.0 """The fraction of the dry matter intake requirement used as the basis for the inclusion rate bounds in user defined ration formulation method."""