pybtls.simulation.Simulation#

class Simulation(output_dir=PosixPath('.'))[source]#

Bases: object

This is the class for setting and running simulations.

Parameters:

output_dir (Path, optional) – The output directory for the simulation results. The default is “./”.

Methods

add_sim

Add a simulation to the simulation queue.

get_no_sim

Get the number of simulations.

get_output

Get the output manager for each simulation.

run

Run the simulations.

add_sim(bridge=None, traffic=None, no_day=None, output_config=None, time_step=0.1, min_gvw=0, vehicle=None, active_lane=None, tag=None, **kwargs)[source]#

Add a simulation to the simulation queue.

Parameters:
  • bridge (Bridge, optional) – The bridge to be calculated load effect. If not provided, there will not be load effect calculation.

  • traffic (Union[TrafficGenerator,TrafficLoader], optional) – The traffic can be either generated or recorded.

  • no_day (int, optional) – The number of days to be simulated (in day). If not provided, the number of days will be the same as the recorded traffic (if given). A single-vehicle simulation will ignore this argument.

  • output_config (OutputConfig, optional) – The output configuration. This argument is essential for traffic simulation. A single-vehicle simulation will ignore this argument.

  • time_step (float, optional) – The calculation time step (in s) for the simulation (about precision). This argument is only used in load effect calculation for traffic simulation. A single-vehicle simulation will ignore this argument.

  • min_gvw (int, optional) – The minimum gross vehicle weight (in kN) to be considered in the load effect calculation for traffic simulation. A single-vehicle simulation will ignore this argument.

  • vehicle (Union[Vehicle, _Vehicle], optional) – The vehicle for a single-vehicle simulation.

  • active_lane (list[int], optional) – The active bridge lanes during the simulation. The default is None, which means all lanes are active. [1-based global index].

  • tag (str, optional) – The tag for the simulation. The default tag will be “Sim_{Simulation Order}”.

Keyword Arguments:
  • overlap_avoid_distance (float, optional) – The minimum chase distance (in m) between two vehicles to avoid overlap (should equal to bridge length). If the bridge argument has an input then no need to specify this argument. The default is 100.0.

  • track_progress (bool, optional) – Whether to track the simulation progress. A single-vehicle simulation will ignore this argument. The default is False.

Return type:

None

run(no_core=None)[source]#

Run the simulations.

Parameters:

no_core (int, optional) –

The number of cores to be used for multi-core running.

If no_core is one or there is only one added simulation, the running will be single-core.

Otherwise, the running will be multi-core.

By default, (no_cpu_logic_core - 2) processes will be used for multi-core running.

Return type:

None

get_output()[source]#

Get the output manager for each simulation.

Returns:

A dict storing output manager for each simulation.

The keys are the sim_tags.

Return type:

dict[str, _OutputManager]

get_no_sim()[source]#

Get the number of simulations.

Returns:

The number of simulations.

Return type:

int