pNeuma_simulator.initialization.equilibrium module
- pNeuma_simulator.initialization.equilibrium.equilibrium(L: float, lanes: int, n_cars: int, n_moto: int, rng: object, distributed: bool = True) tuple[source]
Calculate the equilibrium state of a simulation, assuming lane-based equilibrium
- Parameters:
L (float) – Length of the simulation.
lanes (int) – Number of lanes in the simulation.
n_cars (int) – Number of cars in the simulation.
n_moto (int) – Number of motorcycles in the simulation.
rng (object) – Random number generator.
distributed (bool, optional) – Whether the vehicles are distributed or not. Defaults to True.
- Returns:
A tuple for longitundinal dynamics, containing the adaptation time (tau), lambda (lam), initial velocity (v0), and distance (d).
- Return type:
tuple
Note: The function assumes that the length (L) is large enough for convergence. The function uses synthetic_fd to generate synthetic fundamental diagrams for cars and motorcycles. The equilibrium speed (v_eq) is calculated using root_scalar. The function checks if the total sum of speeds and distances equals the expected value (lanes * L). The function calculates the adaptation time (tau) based on the equilibrium speeds and fundamental diagrams. The adaptation time is limited by the minimum of 2 / lambda and the calculated tau values.
- pNeuma_simulator.initialization.equilibrium.synthetic_fd(n_veh: int, random_state, mode: str = 'Car', distributed: bool = True)[source]
Generate synthetic fundamental diagram data.
- Parameters:
n_veh (int) – Number of vehicles.
random_state (object) – Random number generator.
mode (str, optional) – Mode of transportation. Defaults to “Car”.
distributed (bool, optional) – Flag indicating if the data should be distributed. Defaults to True.
- Returns:
- Tuple containing the following:
list: List of marginal distributions.
numpy.ndarray: Array of lambda values.
numpy.ndarray: Array of desired speeds.
numpy.ndarray: Array of jam spacings.
- Return type:
tuple