Buckets:
| """ | |
| Implementation of functions for the traffic model. | |
| """ | |
| import numpy | |
| def rho_red_light(x, rho_max): | |
| """ | |
| Computes the "red light" initial condition with shock. | |
| Parameters | |
| ---------- | |
| x : numpy.ndarray | |
| Locations on the road as a 1D array of floats. | |
| rho_max : float | |
| The maximum traffic density allowed. | |
| Returns | |
| ------- | |
| rho : numpy.ndarray | |
| The initial car density along the road as a 1D array of floats. | |
| """ | |
| rho = rho_max * numpy.ones_like(x) | |
| mask = numpy.where(x < 3.0) | |
| rho[mask] = 0.5 * rho_max | |
| return rho | |
| def flux(rho, u_max, rho_max): | |
| """ | |
| Computes the traffic flux F = V * rho. | |
| Parameters | |
| ---------- | |
| rho : numpy.ndarray | |
| Traffic density along the road as a 1D array of floats. | |
| u_max : float | |
| Maximum speed allowed on the road. | |
| rho_max : float | |
| Maximum car density allowed on the road. | |
| Returns | |
| ------- | |
| F : numpy.ndarray | |
| The traffic flux along the road as a 1D array of floats. | |
| """ | |
| F = rho * u_max * (1.0 - rho / rho_max) | |
| return F | |
Xet Storage Details
- Size:
- 1.1 kB
- Xet hash:
- f0dfbdf8a0be1bf58e3b770dae04413fd036bffee3b76c721ad27f5e50fc1fc8
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.