Simulation Core Classes
+ +Contents
+Simulation Core Classes#
+There are a variety of components that enable a simulation to be run, from the +environmen to the management of repairs to the servicing equipment. The below will show +how each of the APIs are powered to enable the full flexibility of modeling.
+ +Environment#
+-
+
- +class wombat.core.environment.WombatEnvironment(data_dir: pathlib.Path | str, weather_file: str, workday_start: int, workday_end: int, simulation_name: Optional[str] = None, start_year: Optional[int] = None, end_year: Optional[int] = None, port_distance: Optional[Union[int, float]] = None, non_operational_start: Optional[Union[str, datetime.datetime]] = None, non_operational_end: Optional[Union[str, datetime.datetime]] = None, reduced_speed_start: Optional[Union[str, datetime.datetime]] = None, reduced_speed_end: Optional[Union[str, datetime.datetime]] = None, reduced_speed: float = 0.0, random_seed: Optional[int] = None, random_generator: Optional[numpy.random._generator.Generator] = None)# +
The primary mechanism for powering an O&M simulation. This object has insight +into all other simulation objects, and controls the timing, date/time stamps, and +weather conditions.
+-
+
- Parameters +
-
+
data_dir (pathlib.Path | str) – Directory where the inputs are stored and where to save outputs.
+weather_file (str) – Name of the weather file. Should be contained within
data_dir
/weather/, with +columns “datetime”, “windspeed”, and, optionally, “waveheight”. The datetime +column should adhere to the following format: “MM/DD/YY HH:MM”, in 24-hour time.
+workday_start (int) – Starting time for the repair crew, in 24 hour local time. This can be overridden +by an
ServiceEquipmentData
object that operates outside of the “typical” +working hours.
+workday_end (int) – Ending time for the repair crew, in 24 hour local time. This can be overridden +by an
ServiceEquipmentData
object that operates outside of the “typical” +working hours.
+simulation_name (str | None, optional) – Name of the simulation; will be used for naming the log file, by default None. +If
+None
, then the current time will be used. Will always save to +data_dir
/outputs/logs/simulation_name
.log.
+start_year (int | None, optional) – Custom starting year for the weather profile, by default None. If
None
or +less than the first year of the weather profile, this will be ignored.
+end_year (int | None, optional) – Custom ending year for the weather profile, by default None. If
None
or +greater than the last year of the weather profile, this will be ignored.
+port_distance (int | float) – The simulation-wide daily travel distance for servicing equipment. This +should be used as a base setting when multiple or all servicing equipment +will be operating out of the same base location, but can be individually +modified.
+non_operational_start (str | datetime.datetime | None) – The starting month and day, e.g., MM/DD, M/D, MM-DD, etc. for an annualized +period of prohibited operations. When defined at the environment level, +an undefined or later starting date will be overridden for all servicing +equipment and any modeled port, by default None.
+non_operational_end (str | datetime.datetime | None) – The ending month and day, e.g., MM/DD, M/D, MM-DD, etc. for an annualized +period of prohibited operations. When defined at the environment level, +an undefined or earlier ending date will be overridden for all servicing +equipment and any modeled port, by default None.
+reduced_speed_start (str | datetime.datetime | None) – The starting month and day, e.g., MM/DD, M/D, MM-DD, etc. for an annualized +period of reduced speed operations. When defined at the environment level, +an undefined or later starting date will be overridden for all servicing +equipment and any modeled port, by default None.
+reduced_speed_end (str | datetime.datetime | None) – The ending month and day, e.g., MM/DD, M/D, MM-DD, etc. for an annualized +period of reduced speed operations. When defined at the environment level, +an undefined or earlier ending date will be overridden for all servicing +equipment and any modeled port, by default None.
+reduced_speed (float) – The maximum operating speed during the annualized reduced speed operations. +When defined at the environment level, an undefined or faster value will be +overridden for all servicing equipment and any modeled port, by default 0.0.
+random_seed (int | None) – The random seed to be passed to a universal NumPy
default_rng
object to +generate Weibull random generators, by default None.
+random_generator (np.random._generator.Generator | None) – An optional numpy random generator that can be provided to seed a simulation +with the same generator each time, in place of the random seed. If a +
random_seed
is also provided, this will override the random seed, +by default None.
+
+- Raises +
FileNotFoundError – Raised if
+data_dir
cannot be found.
+
-
+
- +cleanup_log_files() None # +
Convenience method to clear the output log files in case a large +batch of simulations is being run and there are space limitations.
+-
+
- … warning:: This shuts down the loggers, so no more logging will be able
to be performed.
+
+
-
+
- +property current_time: str# +
Timestamp for the current time as a datetime.datetime.strftime.
+
-
+
- +date_ix(date: datetime.datetime | datetime.date) int # +
The first index of a future date. This corresponds to the number of hours +until this dates from the very beginning of the simulation.
+-
+
- Parameters +
date (datetime.datetime | datetime.date) – A date within the environment’s simulation range.
+
+- Returns +
Index of the weather profile corresponds to the first hour of
+date
.
+- Return type +
int
+
+
-
+
- +get_random_seconds(low: int = 0, high: int = 10) float # +
Generate a random number of seconds to wait, between
+low
and +high
.-
+
- Parameters +
-
+
low (int, optional) – Minimum number of seconds to wait, by default 0.
+high (int, optional) – Maximum number of seconds to wait, by default 10.
+
+- Returns +
Number of seconds to wait.
+
+- Return type +
float
+
+
-
+
- +hour_in_shift(hour: int, workday_start: int = - 1, workday_end: int = - 1) bool # +
Checks whether an
+hour
is within the working hours.-
+
- Parameters +
-
+
hour (int) – Hour of the day.
+workday_start (int) – A valid hour in 24 hour time, by default -1. This should only be provided +from an
ServiceEquipmentData
object.workday_end
must also be +provided in order to be used.
+workday_end (int) – A valid hour in 24 hour time, by default -1. This should only be provided +from an
ServiceEquipmentData
object.workday_start
must also be +provided in order to be used.
+
+- Returns +
True if
+hour
is during working hours, False otherwise.
+- Return type +
bool
+
+
-
+
- +hours_to_next_shift(workday_start: int = - 1) float # +
Time until the next work shift starts, in hours.
+-
+
- Parameters +
workday_start (int) – A valid hour in 24 hour time, by default -1. This should only be provided +from an
+ServiceEquipmentData
object.
+- Returns +
Hours until the next shift starts.
+
+- Return type +
float
+
+
-
+
- +is_workshift(workday_start: int = - 1, workday_end: int = - 1) bool # +
Check if the current simulation time is within the windfarm’s working hours.
+-
+
- Parameters +
-
+
workday_start (int) – A valid hour in 24 hour time, by default -1. This should only be provided +from an
ServiceEquipmentData
object.workday_end
must also be +provided in order to be used.
+workday_end (int) – A valid hour in 24 hour time, by default -1. This should only be provided +from an
ServiceEquipmentData
object.workday_start
must also be +provided in order to be used.
+
+- Returns +
True if it’s valid working hours, False otherwise.
+
+- Return type +
bool
+
+
-
+
- +load_events_log_dataframe() pandas.core.frame.DataFrame # +
Imports the logging file created in
+run
and returns it as a formatted +pandas.DataFrame
.-
+
- Returns +
The formatted logging data from a simulation.
+
+- Return type +
pd.DataFrame
+
+
-
+
- +load_operations_log_dataframe() pandas.core.frame.DataFrame # +
Imports the logging file created in
+run
and returns it as a formatted +pandas.DataFrame
.-
+
- Returns +
The formatted logging data from a simulation.
+
+- Return type +
pd.DataFrame
+
+
-
+
- +log_action(*, agent: str, action: str, reason: str, additional: str = '', system_id: str = '', system_name: str = '', part_id: str = '', part_name: str = '', system_ol: float | int = 0, part_ol: float | int = 0, duration: float = 0, distance_km: float = 0, request_id: str = 'na', location: str = 'na', materials_cost: int | float = 0, hourly_labor_cost: int | float = 0, salary_labor_cost: int | float = 0, equipment_cost: int | float = 0) None # +
Formats the logging messages into the expected format for logging.
+-
+
- Parameters +
-
+
agent (str) – Agent performing the action.
+action (str) – Action that was taken.
+reason (str) – Reason an action was taken.
+additional (str) – Any additional information that needs to be logged.
+system_id (str) – Turbine ID,
System.id
, by default “”.
+system_name (str) – Turbine name,
System.name
, by default “”.
+part_id (str) – Subassembly, component, or cable ID,
_.id
, by default “”.
+part_name (str) – Subassembly, component, or cable name,
_.name
, by default “”.
+system_ol (float | int) – Turbine operating level,
System.operating_level
. Use an empty string +for n/a, by default 0.
+part_ol (float | int) – Subassembly, component, or cable operating level,
_.operating_level
. Use +an empty string for n/a, by default 0.
+request_id (str) – The
RepairManager
assigned request_id found in +RepairRequest.request_id
, by default “na”.
+location (str) – The location of where the event ocurred: should be one of site, port, +enroute, or system, by default “na”.
+duration (float) – Length of time the action lasted, by default 0.
+distance (float) – Distance traveled, in km, if applicable, by default 0.
+materials_cost (Union[int, float], optional) – Total cost of materials for action, in USD, by default 0.
+hourly_labor_cost (Union[int, float], optional) – Total cost of hourly labor for action, in USD, by default 0.
+salary_labor_cost (Union[int, float], optional) – Total cost of salaried labor for action, in USD, by default 0.
+equipment_cost (Union[int, float], optional) – Total cost of equipment for action, in USD, by default 0.
+
+
-
+
- +power_production_potential_to_csv(windfarm: wombat.windfarm.windfarm.Windfarm, operations: Optional[pandas.core.frame.DataFrame] = None, return_df: bool = True) tuple[pandas.core.frame.DataFrame, pandas.core.frame.DataFrame] # +
Creates the power production
+DataFrame
and optionally returns it.-
+
- Parameters +
-
+
windfarm (wombat.windfarm.Windfarm) – The simulation’s windfarm object.
+operations (Optional[pd.DataFrame], optional) – The operations log
DataFrame
if readily available, by default None. If +None
, then it will be created through +load_operations_log_dataframe()
.
+return_df (bool, optional) – Indicator to return the power production for further usage, by default True.
+
+- Returns +
The power potential and production timeseries data.
+
+- Return type +
Tuple[pd.DataFrame, pd.DataFrame]
+
+
-
+
- +run(until: Optional[Union[int, float, simpy.events.Event]] = None)# +
Extends the
+simpy.Environment.run
method to change the default behavior +if no argument is passed tountil
, which will now run a simulation until the +end of the weather profile is reached.-
+
- Parameters +
until (Optional[Union[int, float, Event]], optional) – When to stop the simulation, by default None. See documentation on +
+simpy.Environment.run
for more details.
+
-
+
- +property simulation_time: datetime.datetime# +
Current time within the simulation (“datetime” column within weather).
+
-
+
- +weather_forecast(hours: int | float) tuple[polars.series.series.Series, polars.series.series.Series, polars.series.series.Series, polars.series.series.Series] # +
Returns the datetime, wind, wave, and hour data for the next
+hours
hours, +starting from the current hour’s weather.-
+
- Parameters +
hours (Union[int, float]) – Number of hours to look ahead, rounds up to the nearest hour.
+
+- Returns +
Each of the relevant columns (datetime, wind, wave, hour) from the weather +profile.
+
+- Return type +
tuple[pl.Series, pl.Series, pl.Series, pl.Series]
+
+
-
+
- +property weather_now: polars.dataframe.frame.DataFrame# +
The current weather.
+-
+
- Returns +
A length 1 slice from the weather profile at the current
+int()
rounded +hour, in simulation time.
+- Return type +
pl.DataFrame
+
+
Repair Management#
+-
+
- +class wombat.core.repair_management.RepairManager(env: wombat.core.environment.WombatEnvironment, capacity: float = inf)# +
Provides a class to manage repair and maintenance tasks.
+-
+
- Parameters +
-
+
FilterStore (simpy.resources.store.FilterStore) – The
simpy
class on which RepairManager is based to manage the repair and +maintenance tasks.
+env (wombat.core.WombatEnvironment) – The simulation environment.
+capacity (float) – The maximum number of tasks that can be submitted to the manager, by default +
np.inf
.
+
+- Variables +
-
+
env (wombat.core.WombatEnvironment) – The simulation environment.
+windfarm (wombat.windfarm.Windfarm) – The simulated windfarm. This is only used for getting the operational capacity.
+_current_id (int) – The logged and auto-incrememented integer base for the ID generated for each +submitted repair request.
+downtime_based_equipment (StrategyMap) – The mapping between downtime-based servicing equipment and their capabilities.
+request_based_equipment (StrategyMap) – The mapping between request-based servicing equipment and their capabilities.
+
+
-
+
- +enable_requests_for_system(system: System | Cable, tow: bool = False) None # +
Reenables service equipment operations on the provided system.
+-
+
- Parameters +
-
+
system_id (System | Cable) – The
System
orCable
that can be operated on again.
+tow (bool, optional) – Set to True if this is for a tow-to-port request.
+
+
-
+
- +get_all_requests_for_system(agent: str, system_id: str) list[wombat.core.data_classes.RepairRequest] | None | collections.abc.Generator # +
Gets all repair requests for a specific
+system_id
.-
+
- Parameters +
-
+
agent (str) – The name of the entity requesting all of a system’s repair requests.
+system_id (Optional[str], optional) – ID of the turbine or OSS; should correspond to
System.id
. +the first repair requested.
+
+- Returns +
All repair requests for a given system. If no matching requests are found, +or there aren’t any items in the queue yet, then None is returned.
+
+- Return type +
Optional[list[RepairRequest]]
+
+
-
+
- +get_request_by_severity(equipment_capability: list[str] | set[str], severity_level: Optional[int] = None) simpy.resources.store.FilterStoreGet | None # +
Gets the next repair request by
+severity_level
.-
+
- Parameters +
-
+
equipment_capability (list[str]) – The capability of the equipment requesting possible repairs to make.
+severity_level (int) – Severity level of focus, default None.
+
+- Returns +
Repair request meeting the required criteria.
+
+- Return type +
Optional[FilterStoreGet]
+
+
-
+
- +get_request_by_system(equipment_capability: list[str], system_id: Optional[str] = None) simpy.resources.store.FilterStoreGet | None # +
Gets all repair requests for a certain turbine with given a sequence of +
+equipment_capability
as long as it isn’t registered as unable to be +serviced.-
+
- Parameters +
-
+
equipment_capability (list[str]) – The capability of the servicing equipment requesting repairs to process.
+system_id (Optional[str], optional) – ID of the turbine or OSS; should correspond to
System.id
, by default +None. If None, then it will simply sort the list bySystem.id
and return +the first repair requested.
+
+- Returns +
The first repair request for the focal system or None, if self.items is +empty, or there is no matching system.
+
+- Return type +
Optional[FilterStoreGet]
+
+
-
+
- +interrupt_system(system: System | Cable) None # +
Sets the turbine status to be in servicing, and interrupts all the processes +to turn off operations.
+-
+
- Parameters +
system_id (str) – The system to disable repairs.
+
+
-
+
- +invalidate_system(system: System | Cable | str, tow: bool = False) None # +
Disables the ability for servicing equipment to service a specific system, +sets the turbine status to be in servicing, and interrupts all the processes +to turn off operations.
+-
+
- Parameters +
-
+
system (System | Cable | str) – The system, cable, or
str
id of one to disable repairs.
+tow (bool, optional) – Set to True if this is for a tow-to-port request.
+
+
-
+
- +purge_subassembly_requests(system_id: str, subassembly_id: str, exclude: list[str] = []) list[wombat.core.data_classes.RepairRequest] | None # +
Yields all the requests for a system/subassembly combination. This is +intended to be used to remove erroneous requests after a subassembly has been +replaced.
+-
+
- Parameters +
-
+
system_id (str) – Either the
System.id
orCable.id
.
+subassembly_id (str) – Either the
Subassembly.id
or theCable.id
repeated for cables.
+exclude (list[str]) – A list of
request_id
to exclude from the purge. This is a specific use +case for the combined cable system/subassembly, but can be to exclude +certain requests from the purge.
+
+- Yields +
Optional[list[RepairRequest]] – All requests made to the repair manager for the provided system/subassembly +combination. Returns None if self.items is empty or the loop terminates +without finding what it is looking for.
+
+
-
+
- +register_repair(repair: wombat.core.data_classes.RepairRequest) collections.abc.Generator # +
Registers the repair as complete with the repair managiner.
+-
+
- Parameters +
-
+
repair (RepairRequest) – The repair that has been completed.
+port (bool, optional) – If True, indicates that a port handled the repair, otherwise that a managed +servicing equipment handled the repair, by default False.
+
+- Yields +
Generator – The
+completed_requests.put()
that registers completion.
+
-
+
- +register_request(request: wombat.core.data_classes.RepairRequest) wombat.core.data_classes.RepairRequest # +
The method to submit requests to the repair mananger and adds a unique +identifier for logging.
+-
+
- Parameters +
request (RepairRequest) – The request that needs to be tracked and logged.
+
+- Returns +
The same request as passed into the method, but with a unique identifier +used for logging.
+
+- Return type +
- + +
-
+
- +property request_map: dict[str, int]# +
Creates an updated mapping between the servicing equipment capabilities and +the number of requests that fall into each capability category (nonzero values +only).
+
-
+
- +submit_request(request: wombat.core.data_classes.RepairRequest) None # +
The method to submit requests to the repair mananger and adds a unique +identifier for logging.
+-
+
- Parameters +
request (RepairRequest) – The request that needs to be tracked and logged.
+
+- Returns +
The same request as passed into the method, but with a unique identifier +used for logging.
+
+- Return type +
- + +
Servicing Equipment#
+The servicing equipment module provides a small number of utility functions specific +to the operations of servicing equipment and the ServiceEquipment class that provides +the repair and transportation logic for scheduled, unscheduled, and unscheduled towing +servicing equipment.
+-
+
- +wombat.core.service_equipment.calculate_delay_from_forecast(forecast: numpy.ndarray, hours_required: int | float) tuple[bool, int] # +
Calculates the delay from the binary weather forecast for if that hour is all +clear for operations.
+-
+
- Parameters +
-
+
forecast (np.ndarray) – Truth array to indicate if that hour satisfies the weather limit requirements.
+hours_required (np.ndarray) – The minimum clear weather window required, in hours.
+
+- Returns +
Indicator if a window is found (
+True
) or not (False
), and the number +of hours the event needs to be delayed in order to start.
+- Return type +
tuple[bool, int]
+
+
-
+
- +wombat.core.service_equipment.consecutive_groups(data: numpy.ndarray, step_size: int = 1) list[numpy.ndarray] # +
Generates the subgroups of an array where the difference between two sequential +elements is equal to the
+step_size
. The intent is to find the length of delays +in a weather forecast.-
+
- Parameters +
-
+
data (np.ndarray) – An array of integers.
+step_size (int, optional) – The step size to be considered a consecutive number, by default 1.
+
+- Returns +
A list of arrays of the consecutive elements of
+data
.
+- Return type +
list[np.ndarray]
+
+
-
+
- +wombat.core.service_equipment.reset_system_operations(system: wombat.windfarm.system.system.System, subassembly_resets: list[str]) None # +
Completely resets the failure and maintenance events for a given system +and its subassemblies, and puts each
+Subassembly.operating_level
back to 100%.++Note
+This is only intended to be used in conjunction with a tow-to-port +repair where a turbine will be completely serviced.
+-
+
- Parameters +
-
+
system (System) – The turbine to be reset.
+subassembly_resets (list[str]) – The `subassembly_id`s to reset to good as new, if not assuming all +subassemblies.
+
+
-
+
- +wombat.core.service_equipment.validate_end_points(start: str, end: str, no_intrasite: bool = False) None # +
Checks the starting and ending locations for traveling and towing.
+-
+
- Parameters +
-
+
start (str) – The starting location; should be on of: “site”, “system”, or “port”.
+end (str) – The ending location; should be on of: “site”, “system”, or “port”.
+no_intrasite (bool) – A flag to disable intrasite travel, so that
start
andend
cannot +both be “system”, by default False.
+
+- Raises +
-
+
ValueError – Raised if the starting location is invalid.
+ValueError – Raised if the ending location is invalid
+ValueError – Raised if “system” is provided to both
start
andend
, but +no_intrasite
is set toTrue
.
+
+
-
+
- +class wombat.core.service_equipment.ServiceEquipment(env: wombat.core.environment.WombatEnvironment, windfarm: wombat.windfarm.windfarm.Windfarm, repair_manager: wombat.core.repair_management.RepairManager, equipment_data_file: str | pathlib.Path | dict)# +
Provides a servicing equipment object that can handle various maintenance and +repair tasks.
+-
+
- Parameters +
-
+
env (WombatEnvironment) – The simulation environment.
+windfarm (Windfarm) – The
Windfarm
object.
+repair_manager (RepairManager) – The
RepairManager
object.
+equipment_data_file (str) – The equipment settings file name with extension.
+
+- Variables +
-
+
env (WombatEnvironment) – The simulation environment instance.
+windfarm (Windfarm) – The simulation windfarm instance.
+manager (RepairManager) – The simulation repair manager instance.
+settings (ScheduledServiceEquipmentData | UnscheduledServiceEquipmentData) – The servicing equipment’s configuration settings, as provided by the user.
+onsite (bool) – Indicates if the servicing equipment is at the site (
True
), or not +(False
).
+enroute (bool) – Indicates if the servicing equipment is on its way to the site (
True
), +or not (False
).
+at_port (bool) – Indicates if the servicing equipment is at the port, or similar location for +land-based, (
True
), or not (False
).
+at_system (bool) – Indications if the servicing equipment is at a cable, substation, or turbine +while on the site (
True
), or not (False
).
+current_system (str | None) – Either the
System.id
ifat_system
, orNone
if not.
+transferring_crew (bool) – Indications if the servicing equipment is at a cable, substation, or turbine +and transferring the crew to or from that system (
True
), or not +(False
).
+
+
-
+
- +crew_transfer(system: wombat.windfarm.system.system.System | wombat.windfarm.system.cable.Cable, subassembly: wombat.windfarm.system.subassembly.Subassembly, request: wombat.core.data_classes.RepairRequest, to_system: bool) collections.abc.Generator[simpy.events.Timeout | simpy.events.Process, None, None] # +
The process of transfering the crew from the equipment to the
+System
+for servicing using an uninterrupted weather window to ensure safe transfer.-
+
- Parameters +
-
+
system (System | Cable) – The System where the crew needs to be transferred to.
+subassembly (Subassembly) – The Subassembly that is being worked on.
+request (RepairRequest) – The repair to be processed.
+to_system (bool) – True if the crew is being transferred to the system, or False if the crew +is being transferred off the system.
+
+- Returns +
None is returned when this is run recursively to not repeat the crew +transfer process.
+
+- Return type +
None
+
+- Yields +
Generator[Timeout | Process, None, None] – Yields a timeout event for the crew transfer once an uninterrupted weather +window can be found.
+
+
-
+
- +enable_string_operations(cable: wombat.windfarm.system.cable.Cable) None # +
Traverses the upstream cable and turbine connections and resets the +
+System.cable_failure
andCable.downstream_failure
until it hits +another cable failure, then the loop exits.-
+
- Parameters +
subassembly (Cable) – The Cable or System
+
+
-
+
- +find_interrupted_weather_window(hours_required: int | float) tuple[pandas.core.indexes.datetimes.DatetimeIndex, numpy.ndarray, bool] # +
Assesses at which points in the repair window, the wind (and wave) +constraints for safe operation are met.
+The initial search looks for a weather window of length
+hours_required
, and +adds 24 hours to the window for the proceeding 9 days. If no satisfactory window +is found, then the calling process must make another call to this function, but +likely there is something wrong with the constraints or weather conditions if +no window is found within 10 days.-
+
- Parameters +
hours_required (int | float) – The number of hours required to complete the repair.
+
+- Returns +
The pandas DatetimeIndex, and a corresponding boolean array for what points +in the time window are safe to complete a maintenance task or repair.
+
+- Return type +
tuple[DatetimeIndex, np.ndarray, bool]
+
+
-
+
- +find_uninterrupted_weather_window(hours_required: int | float) tuple[int | float, bool] # +
Finds the delay required before starting on a process that won’t be able to +be interrupted by a weather delay.
+TODO: WEATHER FORECAST NEEDS TO BE DONE FOR
+math.floor(self.now)
, not the +ceiling or there will be a whole lot of rounding up errors on process times.-
+
- Parameters +
hours_required (int | float) – The number of uninterrupted of hours that a process requires for completion.
+
+- Returns +
The number of hours in weather delays before a process can be completed, and +an indicator for if the process has to be delayed until the next shift for +a safe transfer.
+
+- Return type +
tuple[int | float, bool]
+
+
-
+
- +finish_setup_with_environment_variables() None # +
A post-initialization step that will override unset parameters with those +from the the environemt that may have already been set.
+
-
+
- +get_next_request()# +
Gets the next request by the rig’s method for processing repairs.
+-
+
- Returns +
The next
+RepairRequest
to be processed.
+- Return type +
simpy.resources.store.FilterStoreGet
+
+
-
+
- +get_speed(tow: bool = False) float # +
Determines the appropriate speed that the servicing equipment should be +traveling at for towing or traveling, and if the timeframe is during a reduced +speed scenario.
+-
+
- Parameters +
tow (bool, optional) – True indicates the servicing equipment should be using the towing speed, +and if False, then the traveling speed should be used, by default False.
+
+- Returns +
The maximum speed the servicing equipment should be traveling/towing at.
+
+- Return type +
float
+
+
-
+
- +hours_to_next_operational_date(start_search_date: datetime.datetime | datetime.date | pandas._libs.tslibs.timestamps.Timestamp, exclusion_days: int = 0) float # +
Calculates the number of hours until the first date that is not a part of +the
+non_operational_dates
given a starting datetime and for search criteria. +Optionally,exclusion_days
can be used to account for a mobilization period +so that mobilization can occur during the non operational period.-
+
- Parameters +
-
+
start_search_date (datetime.datetime | datetime.date | pd.Timestamp) – The first date to be considered in the search.
+exclusion_days (int, optional) – The number of days to subtract from the next available datetime that +represents a non operational action that can occur during the non +operational period, such as mobilization, by default 0.
+
+- Returns +
The total number of hours until the next operational date.
+
+- Return type +
float
+
+
-
+
- +in_situ_repair(request: wombat.core.data_classes.RepairRequest, time_processed: int | float = 0, prior_operation_level: float = - 1.0, initial: bool = False) collections.abc.Generator[simpy.events.Timeout | simpy.events.Process, None, None] # +
Processes the repair including any weather and shift delays.
+-
+
- Parameters +
-
+
request (RepairRequest) – The
Maintenance
orFailure
receiving attention.
+time_processed (int | float, optional) – Time that has already been processed, by default 0.
+prior_operation_level (float, optional) – The operating level of the
System
just before the repair has begun, by +default -1.0.
+initial (bool, optional) – True for first step in a potentially-recursive logic, otherwise False. When +True, the repair manager will turn off the system being worked on, but if +done multiple times, the simulation will error out.
+
+- Yields +
Generator[Timeout | Process, None, None] – Timeouts for the repair process.
+
+
-
+
- +initialize_cost_calculators(which: str) None # +
Creates the cost calculators for each of the subclasses that will need to +calculate hourly costs.
+-
+
- Parameters +
which (str) – One of “port” or “equipment” to to indicate how to access equipment costs
+
+
-
+
- +mobilize() collections.abc.Generator[simpy.events.Timeout, None, None] # +
Mobilizes the ServiceEquipment object.
+NOTE: weather delays are not accounted for at this stage.
+-
+
- Yields +
Generator[Timeout, None, None] – A Timeout event for the number of hours the ServiceEquipment requires for +mobilizing to the windfarm site.
+
+
-
+
- +mobilize_scheduled() collections.abc.Generator[simpy.events.Timeout, None, None] # +
Mobilizes the ServiceEquipment object by waiting for the next operational +period, less the mobilization time, then logging the mobiliztion cost.
+NOTE: weather delays are not accounted for in this process.
+-
+
- Yields +
Generator[Timeout, None, None] – A Timeout event for the number of hours between when the function is called +and when the next operational period starts.
+
+
-
+
- +mooring_connection(system: wombat.windfarm.system.system.System, request: wombat.core.data_classes.RepairRequest, which: str) collections.abc.Generator[simpy.events.Timeout | simpy.events.Process, None, None] # +
The process of either umooring a floating turbine to prepare for towing it to +port, or reconnecting it after its repairs have been completed.
+-
+
- Parameters +
-
+
system (System) – The System that needs unmooring/reconnecting.
+request (RepairRequest) – The repair to be processed.
+which (bool) – “unmoor” for unmooring the turbine, “reconnect” for reconnecting the +turbine.
+
+- Returns +
None is returned when this is run recursively to not repeat the process.
+
+- Return type +
None
+
+- Yields +
Generator[Timeout | Process, None, None] – Yields a timeout event for the unmooring/reconnection once an uninterrupted +weather window can be found.
+
+
-
+
- +process_repair(hours: int | float, request_details: wombat.core.data_classes.Maintenance | wombat.core.data_classes.Failure, **kwargs) collections.abc.Generator[simpy.events.Timeout | simpy.events.Process, None, None] # +
The logging and timeout process for performing a repair or doing maintenance.
+-
+
- Parameters +
-
+
hours (int | float) – The lenght, in hours, of the repair or maintenance task.
+request_details (Maintenance | Failure) – The deatils of the request, this is only being checked for the type.
+kwargs (dict) – Additional parameters to be passed to
WombatEnvironment.log_action
.
+
+- Yields +
Generator[Timeout | Process, None, None] – A
+Timeout
is yielded of lengthhours
.
+
-
+
- +register_repair_with_subassembly(subassembly: wombat.windfarm.system.subassembly.Subassembly | wombat.windfarm.system.cable.Cable, repair: wombat.core.data_classes.RepairRequest, starting_operating_level: float) None # +
Goes into the repaired subassembly, component, or cable and returns its +
+operating_level
back to good as new for the specific repair. For fatal cable +failures, all upstream turbines are turned back on unless there is another fatal +cable failure preventing any more from operating.-
+
- Parameters +
-
+
subassembly (Subassembly | Cable) – The subassembly or cable that was repaired.
+repair (RepairRequest) – The request for repair that was submitted.
+starting_operating_level (float) – The operating level before a repair was started.
+
+
-
+
- +run_scheduled_in_situ() collections.abc.Generator[simpy.events.Process, None, None] # +
Runs the simulation of in situ repairs for scheduled servicing equipment +that have the onsite designation or don’t require mobilization.
+-
+
- Yields +
Generator[Process, None, None] – The simulation.
+
+
-
+
- +run_tow_to_port(request: wombat.core.data_classes.RepairRequest) collections.abc.Generator[simpy.events.Process, None, None] # +
Runs the tow to port logic, so a turbine can be repaired at port.
+-
+
- Parameters +
request (RepairRequest) – The request the triggered the tow-to-port strategy.
+
+- Yields +
Generator[Process, None, None] – The series of events that simulate the complete towing logic.
+
+- Raises +
ValueError – Raised if the equipment is not currently at port
+
+
-
+
- +run_tow_to_site(request: wombat.core.data_classes.RepairRequest, subassembly_resets: list[str] = []) collections.abc.Generator[simpy.events.Process, None, None] # +
Runs the tow to site logic for after a turbine has had its repairs completed +at port.
+-
+
- Parameters +
-
+
request (RepairRequest) – The request the triggered the tow-to-port strategy.
+subassembly_resets (list[str]) – The `subassembly_id`s to reset to good as new. Defaults to [].
+
+- Yields +
Generator[Process, None, None] – The series of events that simulate the complete towing logic.
+
+- Raises +
ValueError – Raised if the equipment is not currently at port
+
+
-
+
- +run_unscheduled_in_situ() collections.abc.Generator[simpy.events.Process, None, None] # +
Runs an in situ repair simulation for unscheduled servicing equipment, or +those that have to be mobilized before performing repairs and maintenance.
+-
+
- Yields +
Generator[Process, None, None] – The simulation
+
+
-
+
- +tow(start: str, end: str, set_current: Optional[str] = None, **kwargs) collections.abc.Generator[simpy.events.Timeout | simpy.events.Process, None, None] # +
The process for towing a turbine to/from port.
+-
+
- Parameters +
-
+
start (str) – The starting location; one of “site” or “port”.
+end (str) – The ending location; one of “site” or “port”.
+set_current (str | None, optional) – The
System.id
if the turbine is being returned to site, by default None
+
+- Yields +
Generator[Timeout | Process, None, None] – The series of SimPy events that will be processed for the actions to occur.
+
+
-
+
- +travel(start: str, end: str, set_current: Optional[str] = None, hours: Optional[float] = None, distance: Optional[float] = None, **kwargs) collections.abc.Generator[simpy.events.Timeout | simpy.events.Process, None, None] # +
The process for traveling between port and site, or two systems onsite.
+NOTE: This does not currently take the weather conditions into account.
+-
+
- Parameters +
-
+
start (str) – The starting location, one of “site”, “port”, or “system”.
+end (str) – The starting location, one of “site”, “port”, or “system”.
+set_current (str, optional) – Where to set
current_system
to be if traveling to site or a different +system onsite, by default None.
+hours (float, optional) – The number hours required for traveling between
start
andend
. +If provided, no internal travel time will be calculated.
+distance (float, optional) – The distance, in km, to be traveled. Only used if hours is provided
+
+- Yields +
Generator[Timeout | Process, None, None] – The timeout event for traveling.
+
+
-
+
- +wait_until_next_operational_period(*, less_mobilization_hours: int = 0) collections.abc.Generator[simpy.events.Timeout, None, None] # +
Delays the crew and equipment until the start of the next operational +period.
+TODO: Need a custom error if weather doesn’t align with the equipment dates.
+-
+
- Parameters +
less_mobilization_hours (int) – The number of hours required for mobilization that will be subtracted from +the waiting period to account for mobilization, by default 0.
+
+- Yields +
Generator[Timeout, None, None] – A Timeout event for the number of hours between when the function is called +and when the next operational period starts.
+
+
-
+
- +wait_until_next_shift(**kwargs) collections.abc.Generator[simpy.events.Timeout, None, None] # +
Delays the process until the start of the next shift.
+-
+
- Yields +
Generator[Timeout, None, None] – Delay until the start of the next shift.
+
+
-
+
- +weather_delay(hours: int | float, **kwargs) collections.abc.Generator[simpy.events.Event, Any, Any] # +
Processes a weather delay of length
+hours
hours. Ifhours
= 0, then +a Timeout is still processed, but not logging is done (this is to increase +consistency and do better typing validation across the codebase).-
+
- Parameters +
hours (int | float) – The lenght, in hours, of the weather delay.
+
+- Yields +
Generator[Event, Any, Any] – If the delay is more than 0 hours, then a
+Timeout
is yielded of length +hours
.
+
Port#
+Creates the Port class that provies the tow-to-port repair capabilities for +offshore floating wind farms. The Port will control a series of tugboats enabled +through the “TOW” capability that get automatically dispatched once a tow-to-port repair +is submitted and a tugboat is available (ServiceEquipment.at_port). The Port also +controls any mooring repairs through the “AHV” capability, which operates similarly to +the tow-to-port except that it will not be released until the repair is completed, and +operates on a strict shift scheduling basis.
+-
+
- +class wombat.core.port.Port(env: wombat.core.environment.WombatEnvironment, windfarm: wombat.windfarm.windfarm.Windfarm, repair_manager: wombat.core.repair_management.RepairManager, config: dict | str | pathlib.Path)# +
The offshore wind base port that operates tugboats and performs tow-to-port +repairs.
+++Note
+The operating costs for the port are incorporated into the
+FixedCosts
+functionality in the high-levl cost bucket: +operations_management_administration
or the more granula cost bucket: +marine_management
-
+
- Parameters +
-
+
env (WombatEnvironment) – The simulation environment instance.
+windfarm (Windfarm) – The simulation windfarm instance.
+repair_manager (RepairManager) – The simulation repair manager instance.
+config (dict | str | Path) – A path to a YAML object or dictionary encoding the port’s configuration +settings. This will be loaded into a
PortConfig
object during +initialization.
+
+- Variables +
-
+
env (WombatEnvironment) – The simulation environment instance.
+windfarm (Windfarm) – The simulation windfarm instance.
+manager (RepairManager) – The simulation repair manager instance.
+settings (PortConfig) – The port’s configuration settings, as provided by the user.
+requests_serviced (set[str]) – The set of requests that have already been serviced to ensure there are no +duplications of labor when splitting out the repair requests to be processed.
+turbine_manager (simpy.Resource) – A SimPy
Resource
object that limits the number of turbines that can be towed +to port, so as not to overload the quayside waters, which is controlled by +settings.max_operations
.
+crew_manager (simpy.Resource) – A SimPy
Resource
object that limts the number of repairs that can be +occurring at any given time, which is controlled bysettings.n_crews
.
+service_equipment_manager (simpy.FilterStore) – A SimPy
FilterStore
object that acts as a coordination system for the +registered tugboats to tow turbines between port and site. In order to tow +in either direction they must be filtered byServiceEquipment.at_port
. This +is generated from the tugboat definitions insettings.tugboats
.
+active_repairs (dict[str, dict[str, simpy.events.Event]]) – A nested dictionary of turbines, and its associated request IDs with a SimPy +
Event
. The use of events allows them to automatically succeed at the end of +repairs, and once all repairs are processed on a turbine, the tow-to-site +process can commence.
+
+
-
+
- +get_all_requests_for_system(system_id: str) None | collections.abc.Generator[simpy.resources.store.FilterStoreGet, None, None] # +
Gets all repair requests for a specific
+system_id
.-
+
- Parameters +
system_id (Optional[str], optional) – ID of the turbine or OSS; should correspond to
+System.id
. +the first repair requested.
+- Returns +
All repair requests for a given system. If no matching requests are found, +or there aren’t any items in the queue yet, then None is returned.
+
+- Return type +
Optional[Generator[FilterStoreGet]]
+
+
-
+
- +hours_to_next_operational_date(start_search_date: datetime.datetime | datetime.date | pandas._libs.tslibs.timestamps.Timestamp, exclusion_days: int = 0) float # +
Calculates the number of hours until the first date that is not a part of +the
+non_operational_dates
given a starting datetime and for search criteria. +Optionally,exclusion_days
can be used to account for a mobilization period +so that mobilization can occur during the non operational period.-
+
- Parameters +
-
+
start_search_date (datetime.datetime | datetime.date | pd.Timestamp) – The first date to be considered in the search.
+exclusion_days (int, optional) – The number of days to subtract from the next available datetime that +represents a non operational action that can occur during the non +operational period, such as mobilization, by default 0.
+
+- Returns +
The total number of hours until the next operational date.
+
+- Return type +
float
+
+
-
+
- +initialize_cost_calculators(which: str) None # +
Creates the cost calculators for each of the subclasses that will need to +calculate hourly costs.
+-
+
- Parameters +
which (str) – One of “port” or “equipment” to to indicate how to access equipment costs
+
+
-
+
- +process_repair(hours: int | float, request_details: wombat.core.data_classes.Maintenance | wombat.core.data_classes.Failure, **kwargs) collections.abc.Generator[simpy.events.Timeout | simpy.events.Process, None, None] # +
The logging and timeout process for performing a repair or doing maintenance.
+-
+
- Parameters +
-
+
hours (int | float) – The lenght, in hours, of the repair or maintenance task.
+request_details (Maintenance | Failure) – The deatils of the request, this is only being checked for the type.
+kwargs (dict) – Additional parameters to be passed to
WombatEnvironment.log_action
.
+
+- Yields +
Generator[Timeout | Process, None, None] – A
+Timeout
is yielded of lengthhours
.
+
-
+
- +repair_single(request: wombat.core.data_classes.RepairRequest) collections.abc.Generator[simpy.events.Timeout | simpy.events.Process, None, None] # +
Simulation logic to process a single repair request.
+-
+
- Parameters +
request (RepairRequest) – The submitted repair or maintenance request.
+
+
-
+
- +run_repairs(system_id: str) collections.abc.Generator | None # +
Method that transfers the requests from the repair manager and initiates the +repair sequence.
+-
+
- Parameters +
system_id (str) – The
+System.id
that is has been towed to port.
+
-
+
- +run_tow_to_port(request: wombat.core.data_classes.RepairRequest) collections.abc.Generator[simpy.events.Process, None, None] # +
The method to initiate a tow-to-port repair sequence.
+The process follows the following following routine:
+-
+
Request a tugboat from the tugboat resource manager and wait
+-
+
- Runs
ServiceEquipment.tow_to_port
, which encapsulates the traveling to site, unmooring, and return tow with a turbine
+
+
+- Runs
Transfers the the turbine’s repair log to the port, and gets all available +crews to work on repairs immediately
+Requests a tugboat to return the turbine to site
+Runs
ServiceEquipment.tow_to_site()
, which encapsulates the tow back to +site, reconnection, resetting the operating status, and returning back to +port
+
-
+
- Parameters +
request (RepairRequest) – The request that initiated the process. This is primarily used for logging +purposes.
+
+- Yields +
Generator[Process, None, None] – The series of events constituting the tow-to-port repairs
+
+
-
+
- +run_unscheduled_in_situ(request: wombat.core.data_classes.RepairRequest, initial: bool = False) collections.abc.Generator[simpy.events.Process, None, None] # +
Runs the in-situ repair processes for port-based servicing equipment such as +tugboats that will always return back to port, but are not necessarily a feature +of the windfarm itself, such as a crew transfer vessel.
+-
+
- Parameters +
request (RepairRequest) – The request that triggered the non tow-to-port, but port-based servicing +equipment repair.
+
+- Yields +
Generator[Process, None, None] – The travel and repair processes.
+
+
-
+
- +transfer_requests_from_manager(system_id: str) None | list[wombat.core.data_classes.RepairRequest] | collections.abc.Generator # +
Gets all of a given system’s repair requests from the simulation’s repair +manager, removes them from that queue, and puts them in the port’s queue.
+-
+
- Parameters +
system_id (str) – The
+System.id
attribute from the system that will be repaired at port.
+- Returns +
The list of repair requests that need to be completed at port.
+
+- Return type +
None | list[RepairRequest]
+
+
-
+
- +wait_until_next_shift(**kwargs) collections.abc.Generator[simpy.events.Timeout, None, None] # +
Delays the process until the start of the next shift.
+-
+
- Yields +
Generator[Timeout, None, None] – Delay until the start of the next shift.
+
+