RUFAS.routines.manure.manure_manager module#

class RUFAS.routines.manure.manure_manager.ManureManager(pen_list: List[PenManureData], weather: Weather, time: RufasTime, manure_manager_config: dict[str, Any], simulate_animals: bool)#

Bases: object

A class that sets up and manages different manure management components including manure handlers, reception pits, manure separators, and manure storage treatments. When the simulation engine performs a daily simulation, it invokes the update method on an instance of this class, thereby generating and storing daily output data.

Attributes#

manure_handlersDict

A dictionary that maps an animal pen’s id to a ManureHandler object.

reception_pitsDict

A dictionary that maps an animal pen’s id to a ReceptionPit object.

manure_separatorsDict

A dictionary that maps an animal pen’s id to a ManureSeparator object.

manure_treatmentsDict

A dictionary that maps an animal pen’s id to a Treatment object.

simulate_animalsbool

Records whether animals are being simulated.

__init__(pen_list: List[PenManureData], weather: Weather, time: RufasTime, manure_manager_config: dict[str, Any], simulate_animals: bool) None#

Initializes a ManureManager object by setting up the appropriate manure manager components as specified by the data in the animal_manager object.

Parameters#

pen_listList[PenManureData]

List of pen manure data instances containing all needed manure information.

weatherWeather

The Weather object used to initialize State variables.

timeRufasTime

The RufasTime object used to initialize State variables.

manure_manager_configdict[str, Any]

A dictionary that contains the configuration data for different manure management scenarios.

simulate_animalsbool

Indicates whether animals are being simulated.

configure_manure_manager_components(pen_list: List[PenManureData]) None#

Configures the manure manager components for each animal pen.

Each pen is associated with the following components - bedding, manure handler, reception pit, manure separator, and manure treatment.

Parameters#

pen_listList[PenManureData]

List of PenManureData instances that contain all needed manure information.

daily_update(pen_list: List[PenManureData], simulation_day: int) None#

Calculates daily output data for each manure manager component for each animal pen.

Notes#

On the last day of the simulation, all the data generated daily by the manure manager components will be exported to a CSV file.

Parameters#

pen_listList[Pen]

List of pens found in AnimalManager object.

simulation_dayint

Day of simulation.

static _get_manure_type(treatment_type: ManureTreatmentType) ManureType#

Look up the type of manure produced by a given manure treatment system.

This method is used to map the type of treatment system to the type of manure it produces. This mapping is based on a predefined relationship between the treatment types and manure types.

Parameters#

treatment_typeManureTreatmentType

The type of manure treatment system.

Returns#

ManureType

The type of manure produced by the given manure treatment system. The possible values are specified in the definition of the enum class ManureType.

static _get_manure_density_by_type(manure_type: ManureType) float#

Look up the density of manure based on the given type. The specific density values are specified in the class ManureConstants.

Parameters#

manure_typeManureType

The type of manure.

Returns#

float

The density of manure based on the given type.

_add_manure_nutrients(pen: ManureManagerPen, manure_treatment_daily_output: ManureTreatmentDailyOutput) None#

Add the nutrients in the manure to the manure nutrient manager by manure type.

Parameters#

penManureManagerPen

A pen object to look up the type of its manure treatment system.

manure_treatment_daily_outputManureTreatmentDailyOutput

The daily output data of the manure treatment system.

Returns#

None

request_nutrients(request: NutrientRequest) NutrientRequestResults#

Handle the request for specific nutrients from the crop and soil module. This method evaluates the nutrient request made by considering both nitrogen and phosphorus quantities desired. It calculates the projected manure mass that would satisfy the request and checks against the nutrients available in the manager.

If the request can be fulfilled either partially or wholly, the corresponding amount of nutrients is subtracted from the manager’s internal bookkeeping. The method then returns the results of the nutrient request, which detail the amounts of nutrients that can be provided to fulfill the request. If the request cannot be fulfilled at all, the method will return None.

Notes#

This is a wrapper method that calls the request_nutrients method of the manure nutrient manager.

Parameters#

requestNutrientRequest

The specific nutrient request, including quantities of nitrogen and phosphorus.

Returns#

NutrientRequestResults | None

The results of the nutrient request, detailed in a NutrientRequestResults object, which includes the amount of nitrogen, phosphorus, total manure mass, dry matter, and others that can be provided to fulfill the request. Returns None if the request cannot be fulfilled.

_record_manure_request_results(manure_request_results: NutrientRequestResults | None, manure_source: str) None#

Record the results of a manure request in the Output Manager.

Parameters#

manure_request_resultsNutrientRequestResults | None

The results of a manure request. If None, it means that there was no available on-farm manure.

manure_sourcestr

The source of the manure.

static _calculate_supplemental_manure_needed(on_farm_manure: NutrientRequestResults | None, nutrient_request: NutrientRequest) NutrientRequest#

Calculate the amount of supplemental manure needed to fulfill the nutrient request.

Parameters#

on_farm_manureNutrientRequestResults | None

The results of the nutrient request for manure available from the farm. If None, it means that there was no available on-farm manure.

nutrient_requestNutrientRequest

The nutrient request.

Returns#

NutrientRequest

The request for supplemental manure needed to fulfill the original nutrient request.

_pen_daily_update(simulation_day: int, pen: PenManureData) None#

Calculate daily output data for each manure manager component for a given animal pen.

Parameters#

simulation_dayint

The current simulation day.

penPenManureData

The animal pen for which the daily output data will be calculated.

Returns#

None

_pen_daily_update_for_separator_and_treatment(simulation_day: int, pen: ManureManagerPen, manure_handler_daily_output: ManureHandlerDailyOutput, reception_pit_daily_output: ReceptionPitDailyOutput) Tuple[ManureTreatmentDailyOutput | None, ManureSeparatorDailyOutput | None, ManureTreatmentDailyOutput, ManureTreatmentDailyOutput, ManureTreatmentDailyOutput]#

Calculates daily output for the manure separator and treatment components of a pen.

Parameters#

simulation_dayint

The current simulation day.

penManureManagerPen

The current pen.

manure_handler_daily_outputManureHandlerDailyOutput

The daily output of the manure handler for the current day.

reception_pit_daily_outputReceptionPitDailyOutput

The daily output of the reception pit for the current day.

classmethod _is_compound_anaerobic_manure_treatment(manure_treatment_name: str) bool#

Returns True if the manure treatment is a compound anaerobic manure treatment, False otherwise.

Parameters#

manure_treatment_namestr

The name of the manure treatment.

Returns#

bool

True if the manure treatment is a compound anaerobic manure treatment, False otherwise.

_handle_daily_update_for_compound_anaerobic_manure_treatment(simulation_day: int, pen: ManureManagerPen, manure_handler_daily_output: ManureHandlerDailyOutput, reception_pit_daily_output: ReceptionPitDailyOutput) Tuple[ManureTreatmentDailyOutput, ManureSeparatorDailyOutput | None, ManureSeparatorDailyOutput | None, ManureTreatmentDailyOutput, ManureTreatmentDailyOutput]#

Handles the daily update for a compound anaerobic manure treatment.

Parameters#

simulation_dayint

The current simulation day.

penManureManagerPen

The current pen.

manure_handler_daily_outputManureHandlerDailyOutput

The daily output of the manure handler for the current day.

reception_pit_daily_outputReceptionPitDailyOutput

The daily output of the reception pit for the current day.

Returns#

Tuple[ManureTreatmentDailyOutput, Optional[ManureSeparatorDailyOutput], ManureTreatmentDailyOutput, ManureTreatmentDailyOutput]

The daily output of the anaerobic digestion, the daily output of the manure separator, the daily output of the anaerobic lagoon, and the accumulated output of the anaerobic lagoon.

_handle_daily_update_for_simple_manure_treatment(simulation_day: int, pen: ManureManagerPen, manure_handler_daily_output: ManureHandlerDailyOutput, reception_pit_daily_output: ReceptionPitDailyOutput) Tuple[ManureSeparatorDailyOutput | None, ManureTreatmentDailyOutput, ManureTreatmentDailyOutput]#

Handles the daily update for a manure treatment that is not a compound anaerobic manure treatment.

If the given pen does not use a manure separator, the manure separator daily output will be None.

Parameters#

simulation_dayint

The current simulation day.

penManureManagementPen

The manure management pen.

manure_handler_daily_outputManureHandlerDailyOutput

The manure handler daily output for the current day.

reception_pit_daily_outputReceptionPitDailyOutput

The reception pit daily output for the current day.

Returns#

Tuple[Optional[ManureSeparatorDailyOutput], ManureTreatmentDailyOutput, ManureTreatmentDailyOutput]

The manure separator daily output and the manure treatment daily output.