OpenTNSim#
This page lists all functions and classes available in the OpenTNSim.model and OpenTNSim.core modules. For examples on how to use these submodules please check out the Examples page, information on installing OpenCLSim can be found on the Installation page.
Submodules#
The main components are the Model module and the Core module. All of their components are listed below.
opentnsim.model module#
Vessel generator.
- class opentnsim.model.Simulation(simulation_start, graph, scenario=None)#
Bases:
Identifiable
A class to generate vessels from a database
- add_vessels(origin, destination, vessel=None, vessel_generator=None, arrival_distribution=1, arrival_process='Markovian')#
Make arrival process
environment: simpy environment arrival_distribution: specify the distribution from which vessels are generated, int or list arrival_process: process of arrivals
- run(duration=86400)#
Run the simulation
duration: specify the duration of the simulation in seconds
- class opentnsim.model.VesselGenerator(vessel_type, vessel_database, loaded=None, random_seed=3)#
Bases:
object
A class to generate vessels from a database
- arrival_process(environment, origin, destination, arrival_distribution, scenario, arrival_process)#
Make arrival process
environment: simpy environment arrival_distribution: specify the distribution from which vessels are generated, int or list arrival_process: process of arrivals
- generate(environment, vessel_name, scenario=None)#
Generate a vessel
opentnsim.core module#
Main module.
- class opentnsim.core.ContainerDependentMovable(compute_v, *args, **kwargs)#
Bases:
Movable
,HasContainer
ContainerDependentMovable class Used for objects that move with a speed dependent on the container level compute_v: a function, given the fraction the container is filled (in [0,1]), returns the current speed
- property current_speed#
- class opentnsim.core.ExtraMetadata(*args, **kwargs)#
Bases:
object
store all leftover keyword arguments as metadata property (use as last mixin)
- class opentnsim.core.HasContainer(capacity, level=0, total_requested=0, *args, **kwargs)#
Bases:
SimpyObject
Mixin class: Something with a storage capacity capacity: amount the container can hold level: amount the container holds initially container: a simpy object that can hold stuff total_requested: a counter that helps to prevent over requesting
- property filling_degree#
- property is_loaded#
- property max_load#
return the maximum cargo to load
- class opentnsim.core.HasLength(length, remaining_length=0, total_requested=0, *args, **kwargs)#
Bases:
SimpyObject
Mixin class: Something with a storage capacity
capacity: amount the container can hold level: amount the container holds initially total_requested: a counter that helps to prevent over requesting
- class opentnsim.core.HasLoad(H_e, H_f, T_e, T_f, filling_degree=0, *args, **kwargs)#
Bases:
object
Mixin class with load dependent height (H) and draught (T). The filling degree (filling_degree: fraction) will interpolate between empty and full height and draught.
- property H#
Calculate current height based on filling degree
- property T#
- class opentnsim.core.HasResource(nr_resources=1, priority=False, *args, **kwargs)#
Bases:
SimpyObject
Something that has a resource limitation, a resource request must be granted before the object can be used.
nr_resources: nr of requests that can be handled simultaneously
- class opentnsim.core.Movable(v: float, *args, **kwargs)#
Bases:
Locatable
,Routable
,Log
Mixin class: Something can move.
Used for object that can move with a fixed speed
geometry: point used to track its current location
v: speed
on_pass_edge_functions can contain a list of generators in the form of on_pass_edge(source: Point, destination: Point) -> yield event
on_pass_node_functions can contain a list of generators in the form of on_pass_node(source: Point) -> yield event
- property current_speed#
- move(destination: Locatable | Geometry | str | None = None, engine_order: float = 1.0, duration: float | None = None)#
determine distance between origin and destination, and yield the time it takes to travel it Assumption is that self.path is in the right order - vessel moves from route[0] to route[-1].
- pass_edge(origin, destination)#
- pass_node(node)#
- class opentnsim.core.Neighbours#
Bases:
object
Can be added to a locatable object (list)
travel_to: list of locatables to which can be travelled
- class opentnsim.core.Routable(route, complete_path=None, *args, **kwargs)#
Bases:
SimpyObject
Mixin class: Something with a route (networkx format)
route: list of node-IDs
position_on_route: index of position
- property graph#
Return the graph of the underlying environment.
If it’s multigraph cast to corresponding type If you want the multidigraph use the HasMultiGraph mixin
- class opentnsim.core.Routeable(*args, **kwargs)#
Bases:
Routable
Old name for Mixin class: renamed to Routable.
- class opentnsim.core.VesselProperties(type, B, L, h_min=None, T=None, safety_margin=None, h_squat=None, payload=None, vessel_type=None, renewable_fuel_mass=None, renewable_fuel_volume=None, renewable_fuel_required_space=None, *args, **kwargs)#
Bases:
object
Mixin class: Something that has vessel properties This mixin is updated to better accommodate the ConsumesEnergy mixin
type: can contain info on vessel type (avv class, cemt_class or other)
B: vessel width
L: vessel length
h_min: vessel minimum water depth, can also be extracted from the network edges if they have the property [‘Info’][‘GeneralDepth’]
T: actual draught
safety_margin : the water area above the waterway bed reserved to prevent ship grounding due to ship squatting during sailing, the value of safety margin depends on waterway bed material and ship types. For tanker vessel with rocky bed the safety margin is recommended as 0.3 m based on Van Dorsser et al. The value setting for safety margin depends on the risk attitude of the ship captain and shipping companies.
h_squat: the water depth considering ship squatting while the ship moving (if set to False, h_squat is disabled)
payload: cargo load [ton], the actual draught can be determined by knowing payload based on van Dorsser et al’s method. (https://www.researchgate.net/publication/344340126_The_effect_of_low_water_on_loading_capacity_of_inland_ships)
vessel_type: vessel type can be selected from “Container”,”Dry_SH”,”Dry_DH”,”Barge”,”Tanker”. (“Dry_SH” means dry bulk single hull, “Dry_DH” means dry bulk double hull), based on van Dorsser et al’s paper. (https://www.researchgate.net/publication/344340126_The_effect_of_low_water_on_loading_capacity_of_inland_ships)
Alternatively you can specify draught based on filling degree - H_e: vessel height unloaded - H_f: vessel height loaded - T_e: draught unloaded - T_f: draught loaded - renewable_fuel_mass: renewable fuel mass on board [kg] - renewable_fuel_volume: renewable fuel volume on board [m3] - renewable_fuel_required_space: renewable fuel required storage space (consider packaging factor) on board [m3]
- property T#
Compute the actual draught. This will default to using the draught passed by the constructor. If it is None it will try to find one in the super class.
- get_route(origin, destination, graph=None, minWidth=None, minHeight=None, minDepth=None, randomSeed=4)#
Calculate a path based on vessel restrictions
- property h_min#