Skip to content

[Animal] Wire per-additive dose fields into methane mitigation calculation#3164

Open
matthew7838 wants to merge 8 commits into
devfrom
methane-mitigation-additive-dose
Open

[Animal] Wire per-additive dose fields into methane mitigation calculation#3164
matthew7838 wants to merge 8 commits into
devfrom
methane-mitigation-additive-dose

Conversation

@matthew7838

@matthew7838 matthew7838 commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Feeds the dose of the selected methane mitigation additive into the enteric methane equations, reading it from that additive's own input field instead of a separate generic field.

Context

Issue(s) closed by this pull request: closes #3030

What

  • AnimalConfig gains _METHANE_MITIGATION_DOSE_FIELDS, mapping each methane_mitigation_method to the input field holding its dose.
  • AnimalConfig.set_from_data() resolves methane_mitigation_additive_amount through that mapping. "None" and any unrecognized method resolve to 0.0.
  • Removes the methane_mitigation_additive_amount input from default.json, example_freestall_animal.json, example_open_lot_animal.json, and the herd manager test fixture.
  • Removes the five animal_cross_validation.json blocks that existed to keep the generic field in sync with the per-additive fields.

Why

The animal config carried two overlapping sets of inputs: a generic methane_mitigation_additive_amount, which was the only one Python read, and the four named per-additive fields (3-NOP_additive_amount, monensin_additive_amount, essential_oils_additive_amount, seaweed_additive_amount), which had descriptions and recommended min/max ranges but were never read.

How

set_from_data() looks up the selected method in _METHANE_MITIGATION_DOSE_FIELDS and reads that field. A method with no entry in the mapping (including "None") yields 0.0, which is what the mitigation equations already fall through to.

With the dose now derived rather than user-supplied, the generic input and the five cross-validation rules that policed it are redundant and are deleted. Every one of those rules aliased animal.methane_mitigation.methane_mitigation_additive_amount, so they had to go with the field.

Test plan

  • Run with updated unit tests
  • Follow issue reproduction steps:
    • Open input/data/animal/example_freestall_animal.json.
    • Set methane_mitigation_method to "3-NOP" and 3-NOP_additive_amount to a non-default value such as 90.
    • Run a simulation and inspect the methane yield reduction — the 3-NOP dose used in the equation should now be 90.

Input Changes

  • Deleted animal.methane_mitigation.methane_mitigation_additive_amount from RUFAS/input/metadata/properties/default.json. The dose is now derived from methane_mitigation_method, not supplied by the user.
  • Deleted the same key from input/data/animal/example_freestall_animal.json and input/data/animal/example_open_lot_animal.json.
  • Deleted five cross-validation blocks from input/metadata/cross_validation/animal_cross_validation.json ("When methane mitigation method is None / 3-NOP / monensin / essential_oils / seaweed_additive, ...").
  • No new inputs. The four per-additive fields are unchanged, including their descriptions, defaults, and min/max ranges.
  • Existing animal config files that still contain methane_mitigation_additive_amount continue to load; the key is ignored.

Output Changes

  • N/A

Filter

No output changes, so no filter is needed.

@matthew7838 matthew7838 self-assigned this Jul 25, 2026
@matthew7838 matthew7838 changed the title initial implementation [Animal] Wire per-additive dose fields into methane mitigation calculation Jul 25, 2026
@github-actions
github-actions Bot force-pushed the methane-mitigation-additive-dose branch from fc941c9 to 4ea49b0 Compare July 25, 2026 07:59
@github-actions
github-actions Bot force-pushed the methane-mitigation-additive-dose branch from 4ea49b0 to 432141c Compare July 25, 2026 08:01
@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on methane-mitigation-additive-dose branch: 1136
Mypy errors on dev branch: 1136
No difference in error counts

@github-actions

Copy link
Copy Markdown
Contributor

🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended.

@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on methane-mitigation-additive-dose branch: 1136
Mypy errors on dev branch: 1136
No difference in error counts

@github-actions

Copy link
Copy Markdown
Contributor

🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended.

@matthew7838
matthew7838 marked this pull request as ready for review July 25, 2026 08:47
@github-actions

Copy link
Copy Markdown
Contributor

Current Coverage: 99%

Mypy errors on methane-mitigation-additive-dose branch: 1136
Mypy errors on dev branch: 1136
No difference in error counts

@github-actions

Copy link
Copy Markdown
Contributor

🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Animal] Wire per-additive dose fields into methane mitigation calculation

1 participant