RUFAS.simulation_engine module#

class RUFAS.simulation_engine.SimulationEngine(is_end_to_end_test_run: bool)#

Bases: object

The SimulationEngine class is responsible for orchestrating the entire simulation process for RuFaS. It manages the simulation’s lifecycle, advancing time, executing daily and annual routines, and logging simulation progress.

Parameters#

is_end_to_end_test_runbool

TODO: remove this attribute after Animal and Feed Storage modules are connected - #1878 Indicates if a simulation is being run for end-to-end testing.

Attributes#

weatherWeather

The weather object that contains the weather data.

timeRufasTime

The RufasTime object that contains methods for accessing and manipulating the simulation time.

feed: Feed

The Feed object that stores the information for the feeds managed by the farm, and the methods for storage.

herd_manager: HerdManager

The HerdManager object that manages all animal in the herd.

manure_manager: ManureManager

The ManureManager object that sets up and manages different manure management components including manure handlers, reception pits, manure separators, and manure storage treatments.

field_manager: FieldManager

The FieldManager object that manages all fields in the simulation.

is_end_to_end_test_runbool

TODO: remove this attribute after Animal and Feed Storage modules are connected - #1878 Indicates if a simulation is being run for end-to-end testing. Set to True if end-to-end testing inputs are found in the Input Manager.

Methods#

simulate()

Execute the simulation process.

__init__(is_end_to_end_test_run: bool) None#

Initializes the simulation engine.

simulate() None#

Executes the simulation.

_run_simulation_main_loop() None#

The main loop for simulation.

_daily_simulation() None#

Executes the daily simulation routines.

_formulate_ration() None#

Formulates the ration for the animals.

generate_daily_manure_applications() list[ManureEventNutrientRequestResults]#

Requests nutrients from the manure manager for each field in the simulation.

Returns#

list[ManureEventNutrientRequestResults]

A list containing the ManureEvents and corresponding NutrientRequestResults to be applied to fields.

_advance_time() None#

Advances time and increments simulation_day.

_run_post_annual_routines() None#

Writes the annual report to the output files Flushes the data in the output object Resets the state for the following year

_annual_simulation() None#

Executes the annual simulation routines.

annual_reset() None#

Resets all annual variables that require reset.

annual_mass_balance(time: RufasTime) None#
_initialize_simulation() None#

Instantiates the simulation object by requesting data from the Input Manager.