built_environment

class pyrecodes.system.built_environment.BuiltEnvironment(system_configuration: dict, component_library: dict, system_creator: SystemCreator)

Bases: System

This class represents a built environment system using the iRe-CoDeS framework as an assembly of components that exchange resources. It inherits from the System abstract class and implements the necessary methods to run the resilience assessment for the built environment.

Attributes:
components (list[Component]): List of system components represented as Component objects.
resources (dict): Dictionary containing resource parameters.
system_creator (SystemCreator): The system creator object responsible for system initialization.
FINISH (bool): Flag indicating if the resilience assessment has finished.
FINISH = False
calculate_resilience(print_output=True, return_output=False) dict

Calculates and returns the resilience metrics for the system.

Returns:

list: A list containing resilience metrics specific to each of the resilience calculators.

check_system_convergence(system_supply: dict, updated_system_supply: dict) bool

Checks whether the system has converged to a stable state.

This is checked by comparing the system-level resource supply before and after the resource distribution.

Returns:

bool: True if the system has converged, False otherwise.

components: list[Component]
create_system()

Creates the system based on the provided SystemCreator object.

deepcopy(input)

Method to deepcopy a dict or a list. Alternative to copy.deepcopy as it is too expensive.

distribute_independent_resources() None
distribute_interdependent_resources() None
distribute_resources() None

Distributes resources among components following the resource distribution list.

get_percent_damaged_buildings() float

Gets the percent of damaged buildings in the system.

Returns:

float: The percent of damaged buildings in the system.

get_supply_of_interdependent_resources() dict

Gets the supply of interdependent resources in the system.

Returns:

dict: A dictionary with the supply of interdependent resources in the system.

get_system_supply(resource_name: str) dict

Get the system-level supply for a resource resource_name based on current components’ state.

This method is already implemented in the ResourceDistributionClass but uses the system matrix. However, using that method requires one to update the system matrix outside of resource distribution which then screws up consumption calculation. This method is a workaround to avoid that.

load_as_pickle(loadname='./system_object.pickle') None

Loads the system object from a pickle file and returns it.

Args:

loadname (str, optional): The name of the pickle file to load the system object. Defaults to ‘./system_object.pickle’.

Returns:

BuiltEnvironmentSystem: The loaded system object.

recover() None

Simulates the recovery process in the system at a single time step.

recovery_target_met() bool

Checks whether the recovery target has been met for the built environment system.

Returns:

bool: True if the recovery target is met, False otherwise.

resources: dict
save_as_pickle(savename='./system_object.pickle') None

Saves the system object as a pickle file.

Args:

savename (str, optional): The name of the pickle file to save the system object. Defaults to ‘./system_object.pickle’.

set_component_library(component_library: dict)

Sets the component library for the system.

Args:

component_library (dict): The component library to set for the system.

set_configuration_file(system_configuration: dict)

Sets the configuration file for the system.

Args:

system_configuration (dict): Dict with system configuration parameters.

set_damage_input()

Sets the damage input for the system based on the specified damage input type and parameters.

set_initial_damage() None

Sets the initial damage for the components based on the damage input.

set_resource_distribution_dict()

Sets the resource distribution list for the system based on components and resource parameters using the DistributionListCreator object.

set_system_creator(system_creator: SystemCreator)

This method allows setting the SystemCreator object responsible for system initialization.

Args:

system_creator (SystemCreator): The SystemCreator object to set for the system.

start_resilience_assessment()

Initiates the resilience assessment for the built environment.

The assessment consists of running a for loop where each pass represents the next time step in the system’s recovery.

At each time step, components’ state is update, resources are distributed among components to capture their interaction, and components recover following their recovery model.

Recovery starts after the disaster has occured.

system_creator: SystemCreator
update() None

Updates the system state during the resilience assessment by updating the state of components.

update_resilience_calculators() None

Updates the resilience calculators with the current resource allocations.