reRoute_Dynamics package

Submodules

reRoute_Dynamics.Geography_Tools module

Geography_Tools.py S. Peck

Geography_Tools.py is a module that contains the methods primarily used in the interpretation of geospatial data for the ultimate creation of Route .json files from position and elevation data.

Methods: geodesic_formula() - method to calculate the geodesic distance between two (lat, lon) points. compass_heading() - method to determine cardinal compass heading from an angle off of North. heading_to_angle() - method to determine the compass degree angle from a cardinal direction. point_bearing() - method to determine the travel bearing between two points. get_bounding_box() - method to create the smallest possible box that encompasses all the points in a shape. interpolate_points() - method to interpolate additional points between two initial geospatial points. repeat_id_remover() - method to swap any repeated value in an iterable with -1. verbose_line_updater() - method to provide line updates for verbosity query_elevation_changes() - method to determine the elevation changes in an iterable of elevation. query_stops() - method to assign stops to their closest corresponding point in a geometry series. query_signals() - method to assign signals to their closest corresponding point in a geometry series. query_distance_traveled() - method to calculate the distance traveled from point to point in a geometry series. query_speed_limits() - method to assign speed limits to each point in a geometry series. query_bearings() - method to query the bearing to the next point for each point in a geometric series. get_rasterfiles() - method to return all standard .tif files in a directory. reproject_rasterfiles() - method to reproject and save raster files to a particular geographic projection. query_elevation_series() - method to query the elevation from each point in a geometry series using rasterfiles. smooth_elevation() - method to use a savisky-golay filter to smooth out elevation changes (or otherwise) calculate_grades() - method to calculate the slope grade at each point in a geometry series with elevations interpolate_geometry_series() - method to take a whole series of points and interolate extra points if there are significant gaps. load_from_json() - method to load a Route object from a saved .json file.

Classes: Route - a class used to store information on a route, like geometry, elevation, signals, limits, and stops. save_to_json() - class method used to encode and store a Route class as a .json file query_point() - class method used to query the information of a point at an index in the route to_gdf() - class method used to convert a Route class’s stored information to a GeoDataFrame.

class reRoute_Dynamics.Geography_Tools.Route(geometry, elevation, limits=None, stops=None, signals=None, signs=None, intersperse_empty=False, smooth_grades=False)[source]

Bases: object

Route class is is used to store route information.

Params: :param geometry: iterable of shapely geometry points :param elevation: iterable of elevation data :param limits: iterable of speed limit at each point. (optional, defaults to 25mph in km/s) :param stops: iterable of stop flags at each point. (optional, defaults to 10 evenly spaced stops.) :param signals: iterable of signal flags at each point. (optional, defaults to 8 evenly spaced signals.) :param signs: iterable of sign flags at each point. (optional, defaults to 3 evenly spaced stop signs.) :param intersperse_empty: boolean flag to intersperse any empty parameters. Default False.

Methods: save_to_json() - saves the stored data to a json file. can be loaded again with Geography Tools’ load_from_json.

query_point(index)[source]

query_point() takes an index of a point and returns the data for the corresponding point.

Parameters:

index – index of the route which data you would like to query.

Returns:

Data at that given point, as a dict.

save_to_json(path)[source]

save_to_json() is used to encode and save the Route data to a json file.

Parameters:

path – path and filename to be saved to, as str. Should end with ‘.json’.

Returns:

path to the saved json file.

to_gdf()[source]

to_gdf() takes the constituent information in geography_tools and converts it to a geodataframe.

Returns:

geodataframe of all information contained by a Route object.

reRoute_Dynamics.Geography_Tools.calculate_grades(dx, elevations, clip=True, max_grade=7.5)[source]

calculate_grades takes the distance between points, as well as the elevations at each point, and returns the grade at each point.

Parameters:
  • dx – an iterable of distances between each point

  • elevations – an iterable of elevations corresponding to each point.

  • clip – boolean to determine to clip the grades or not. Default True.

  • max_grade – an int representing the maximum grade a point can be without being clipped to. Default 7.5

Returns:

iterable of the slope grade at each point.

reRoute_Dynamics.Geography_Tools.compass_heading(bearing)[source]

compass_heading converts a bearing in degrees to a compass value like North, South, or East.

Parameters:

bearing – The bearing value, in degrees, as float.

Returns:

String representation of compass heading.

Notes:

11/18/2024 - There is a more mathematically elegant solution to this, but I’m not bothering with it right now.

reRoute_Dynamics.Geography_Tools.geodesic_formula(x1, y1, x2, y2)[source]

geodesic_formula takes the latitude and longitude of two separate points, and calculates the distance in kilometers between those two points as a crow flies, according to the geodesic formula as calculated by geopy.

Parameters:
  • x1 – latitude of point 1 in degrees

  • y1 – longitude of point 1 in degrees

  • x2 – latitude of point 2 in degrees

  • y2 – longitude of point 2 in degrees

Returns:

Distance between the points in kilometers.

reRoute_Dynamics.Geography_Tools.get_bounding_box(shape, how='basic')[source]

get_bounding_box() takes in a shapely shape, and then generates a polygon that is a rectangular bounding box.

Parameters:

shape – Any shapely shape

Returns:

shapely.polygon that fits around the provided shape

reRoute_Dynamics.Geography_Tools.get_rasterfiles(dir_path)[source]

get_rasterfiles takes a path to a directory and returns a series of paths to any .tif files contained therin.

Parameters:

dir_path – path to directory, as str.

Returns:

pandas series of path strings to each .tif file.

reRoute_Dynamics.Geography_Tools.heading_to_angle(heading)[source]

heading_to_angle() takes a compass heading of 8 directions, and converts it to an angle in degrees.

Parameters:

heading – A string representing heading.

Returns:

A compass bearing angle as float.

reRoute_Dynamics.Geography_Tools.interpolate_geometry_series(geometry, max_distance=1)[source]

interpolate_geometry_series takes an iterable of geospatial shapely points, and then generates an interpolated series in the event that the maximum distance (in meters) is exceeded.

Parameters:
  • geometry – a series of shapely points of lat and lon.

  • max_distance – int representing maximum distance the points can be without interpolation.

Returns:

iterable of lists of shapely points that have been interpolated.

reRoute_Dynamics.Geography_Tools.interpolate_points(point_1, point_2, max_dist=1)[source]

interpolate_points takes two shapely points and a maximum distance, and then interpolates between the points if the maximum distance is exceeded.

Parameters:
  • point_1 – starting point as a shapely point of lat, lon

  • point_2 – final point as a shapely point of lat, lon

  • max_dist – maximum distance the points can be without interpolation. Default int of 1.

Returns:

An iterable of (lon,lat) shapely points.

reRoute_Dynamics.Geography_Tools.load_from_json(path)[source]

load_from_json() takes in a path to a json file from an exported Route object, and returns a path object as close as possible to what was saved. Waring: Some data types may be altered or adjusted. Speed limits are expected to be floats, stops, signals, signs, are expected to be ints.

Parameters:

path – path to json file.

Returns:

a Route object.

reRoute_Dynamics.Geography_Tools.point_bearing(x1, y1, x2, y2, bearing_type='Angle')[source]

point_bearing takex in the latitude and longitude of two separate ponts, and calculates the bearing when travelling from point 1 and point 2.

Parameters:
  • x1 – latitude of point 1 in degrees

  • y1 – longitude of point 1 in degrees

  • x2 – latitude of point 2 in degrees

  • y2 – longitude of point 2 in degrees

  • bearing_type – Determine the bearing output. ‘Angle’ - return the angle in degrees. ‘Compass’ - return the angle as a directional bearing (eg: N, E, S, W)

Returns:

Bearing of the vector between the two points.

reRoute_Dynamics.Geography_Tools.query_bearings(geometry, bearing_type='Angle', verbose=False)[source]

query_bearings takes a geometric iterable of shapely points, and returns the corresponding bearing when travelling form one point to the next.

Parameters:
  • geometry – a series of shapely points of lat and lon

  • bearing_type – determine the bearing output. Angle - return the angle in degrees. Compass - return the angle as a directional bearing (eg: N, E, S, W)

  • verbose – boolean to enable verbosity. Default False.

Returns:

list of bearings when travelling to subsequent point.

reRoute_Dynamics.Geography_Tools.query_distance_traveled(geometry_series, verbose=False)[source]

query_distance_traveled takes in a series of points, and then calculates the distance traveled from point to point, in kilometers.

Parameters:
  • geometry_series – a series of shapely points of lat and lon.

  • verbose – boolean to enable verbosity. Default False.

Returns:

an iterable representing the change in distance between each point and the next.

reRoute_Dynamics.Geography_Tools.query_elevation_changes(elev)[source]

query_elevation_change takes an iterable of elevation, and returns the elevation change between the point at the current index, and the next poinnt.

Parameters:

elev – iterable of elevation data

Returns:

list of elevation changes to reach the next point.

reRoute_Dynamics.Geography_Tools.query_elevation_series(geometry, gtiff_dir_ser, verbose=False)[source]

query_elevation_series takes a series of geometric shapely points, and an iterable of geotiff filepaths, and generates a pandas series of elevations from each point in the geometry. Also for some reason tifs store lat and long in (lon, lat), so i swap em.

Parameters:
  • geometry – a series of shapely points of lat and lon

  • gtiff_dir_ser – an iterable of geometric shapely points. Must have an identical projection to the raster files.

  • verbose – boolean parameter to specify verbosity. Defualt false.

Returns:

pandas series of elevations corresponding to the geometry iterable, in km.

reRoute_Dynamics.Geography_Tools.query_signals(geometry, signal_data_path, key='SIGNAL_ID', epsg=4326, margin=10, verbose=False)[source]

query_signals takes in a geometric series of shapely points, a path to stoplight signal data, and returns a list of the signal id at each point in that series.

Parameters:
  • geometry – a series of shapely points of lat and lon.

  • signal_data_path – path, as str, to a shapefile containing stop signal data.

  • key – the column identifier of signal id (or other target value) to be queried

  • epsg – the epsg the data will be re-set as. Default is 4326.

  • margin – the distance, in meters, that the signal is allowed to be from a given point to qualify.

  • verbose – boolean to enable verbosity. Default False.

Returns:

list of signal IDs, or other info about the signal, as specified. -1 if none found.

reRoute_Dynamics.Geography_Tools.query_speed_limits(geometry, limit_data_path, key='SPEED_LIM', epsg=4326, margin=0.0003, last_known_limit=0.0089408, verbose=False)[source]

query_speed_limits takes a geometric iterable of shapely points, a path to speed limit geodata, and returns the corresponding speed limits at each point.

Parameters:
  • geometry – a series of shapely points of lat and lon

  • limit_data_path – path to shapefile of speed limit data as str

  • key – column identifier of a speed limit or other value as str, assumed to be an int in units of mph

  • margin – distance a point can be from the street to qualify. Default 5e-5.

  • last_known_limit – the speed limit int value that the bus will assumedly start at or above. Default 20 mph.

  • verbose – boolean to enable verbosity. Default False.

Returns:

list of speed limits corresponding to the geometry.

Notes:

11/13/2024 - This can be adjusted such that instead of the first value, it’s the true closest. Also can probably be combined with the other queries in such a way that it reduces individual methods. FIXED – 11/19/2024 11/18/2024 - Currently Broken. FIXED – 11/19/2024

reRoute_Dynamics.Geography_Tools.query_stops(geometry, stop_table_path, key='stop_id', epsg_from=4326, epsg_to=4326, margin=10, verbose=False)[source]

query_stops takes in a geometry point series for a given route, and a path to all stop ids and geometry, and then returns a list of stop id’s in the order the bus will arrive.

Parameters:
  • geometry – a series of shapely points representing longitude and latitude

  • stop_table_path – a path to the dataset containing stop geodata csv, as str

  • key – column identifier for the stop id (or whatever value you want) as str

  • epsg_from – the epsg projection the csv is in as an int. Default is 4326.

  • epsg_to – the epsg projection the data should be reporojected to as an int Default is 4326.

  • margin – distance, in meters, that the stop is allowed to be from a given point to qualify, as int.

  • verbose – boolean to enable verbosity. Default false.

Returns:

list of stop ids (or other queried values from the data), with invalid points being labeled -1.

reRoute_Dynamics.Geography_Tools.repeat_id_remover(sequence)[source]

repeat_id_remover takes an iterable of IDs where -1 is invalid, and swaps out any repeat index with an invalid.

Parameters:

sequence – A sequence of id values in an iterable.

Returns:

Sequence with repeated values swapped for a -1.

reRoute_Dynamics.Geography_Tools.reproject_rasterfiles(filepath_sequence, target_crs='EPSG:4326', verbose=False)[source]

reproject_rasterfiles takes an iterable of geotiff files, and then reprojects them as a target crs and saves them in the same directory as the original.

Parameters:
  • filepath_sequence – an iterable of filepaths to geotiff files.

  • target_crs – the projection system the rasterfiles are to be re-projected to.

  • verbose – specify if the output is verbose. Default False.

Returns:

iterable sequence of the newly reprojected files.

Notes: 11/14/2024 - This should be made to have the ability to override if requested. For now, leaving it as-is is fine.

reRoute_Dynamics.Geography_Tools.smooth_elevation(elev_series, lg: int = 43, deg: int = 3)[source]
reRoute_Dynamics.Geography_Tools.verbose_line_updater(message, reset=False)[source]

verbose_line_updater generates a verbose message with timestamps and method calls based on a passed message. Can reset printline if specified.

Parameters:
  • message – message, as str, to be printed with the line.

  • reset – boolean to reset carrige or not. Default false.

Returns:

The string to be printed.

reRoute_Dynamics.Instance_Tools module

Instance_Tools.py S. Peck

Instance_Tools.py contains methods used in the processing and handling of individual points on a route and other miscellaneous methods in generating a trip.

Methods: generate_riders() - method used to generate a series of ridership changes at each stop based on the expected ridership of that series. check_hit_signal() - method to return if a signal light has been hit or not based on random chance. determine_stop_type() - method used to determine what kind of stop a position is based on ridership, signals, and signs. get_stop_type() - method to create an array of stop type booleans for a given position. get_distances_to_stop() - method to determine how much distance is between the current index and the next stop.

reRoute_Dynamics.Instance_Tools.check_hit_signal(stoplight_chance=0.541666, seed=None)[source]

check_hit_signal() takes a chance to hit a yellow/red, and randomly generates a flag if the light is hit (a stop) or not.

Parameters:
Returns:

an int, 0 or 1, depending if the light is green or red.

reRoute_Dynamics.Instance_Tools.determine_stop_type(rider_changes, hit_signals, signs)[source]

determine_stop_type() is used to determine the stop types based on ridership, signals, and signs, and ends.

Parameters:
  • rider_changes – iterable of ridership changes for a route

  • hit_signals – iterable of signals for a route

  • signs – iterable of signs for a route.

Returns:

a list of lists containing 0 or 1 for each stop type, with index of the sub-lists

corresponding to the passed stop types.

reRoute_Dynamics.Instance_Tools.generate_riders(n_stops, mean_ridership, seed=None)[source]

generate_riders() uses a number of stops, and mean ridership, and then generates a list of riderhsip changes by stops, such that the ridership is as close to the ceiling of the mean as possible.

Parameters:
  • n_stops – int of number of stops.

  • mean_ridership – float of the mean ridership for the trip

  • seed – int, used for the seed of the randomness. Default None.

Returns:

list of randomly generated ridership changes at each stop.

reRoute_Dynamics.Instance_Tools.get_distances_to_stops(stop_types, traveled_distance)[source]

get_distances_to_stops() takes an iterable of stop types, and the corresponding cumulative travel distances, and then generates an iterable of distance to the next stop of any type.

Parameters:
  • stop_types – iterable of stop types as generated by determine_stop_type()

  • traveled_distance – iterable of cumulative traveled distance.

Returns:

iterable of the distance to the next stop based on current locaton.

reRoute_Dynamics.Instance_Tools.get_stop_type(ridership, signal, sign, end)[source]

get_stop_type() takes a ridership, signal, and sign point, and converts to a list of 0’s and 1’s depending on if each is valid or not.

reRoute_Dynamics.Object_Params module

Object_Params.py S. Peck

Object_Params is used to create, save, and load object classes that store relevant parameters for modeling.

Methods: load_bus_params() - method to load a Bus object from a saved txt file. load_ESS_params() - method to load an ESS object from a saved txt file. load_trip_params() - method ot load a trip object from a saved txt file. a_eqn() - method to calculate the acceleration at a given time in accordance to a fitting equation. generate_a_profile() - method to create and save an acceleration profile based on a fitting equation.

Classes: Bus - a class that is used to store modeling parameters for a bus vehicle. copy() - method to create a copy of the bus class save() - method to save the bus object to a txt file ESS - a class that is used to store modeling parameters and methods for an Energy Storage System. copy() - method to create a copy of the ESS save() - method to save the ESS object to a txt file bus_E_cap() - method to calculate the energy capacity of the ESS R_bus() - method to calculate the resistance of the ESS calc_instance_power() - method to calculate the load on the ESS based on the load needed calc_voltage_simple() - method to calculate the pack voltage using a simple resistance model at a given power. Trip - a class that is used to store modeling parameters for a given vehicle trip. copy() - method to create a copy of the Trip save() - method to save the trip object to a txt file.

class reRoute_Dynamics.Object_Params.Bus(bus_mass=13300, frontal_width=2.59, frontal_height=3.38, drag_coeff=0.6, friction_coeff=0.01, braking_accel=1.5, br_factor=0.5, a_factor=0.5, i_factor=1.1, max_dist=304.8, a_prof_path='/home/docs/checkouts/readthedocs.org/user_builds/reroute-dynamics/checkouts/latest/Examples/KC_Example_Data/Acceleration_Profiles/Braunschweig_Acceleration.csv', max_acc=0.4, max_dt=1, max_P=160000)[source]

Bases: object

copy()[source]
save(filepath)[source]
class reRoute_Dynamics.Object_Params.ESS(motor_eff=0.916, inverter_eff=0.971, aux_eff=0.89, simple_load=7000, regen_eff=0.6, max_regen=-100000, cell_ocv=3.3, cell_res=0.008, module_struct=(12, 8), bus_struct=(16, 1), cell_cap=2.3, b_param=4.72605e-05)[source]

Bases: object

R_bus()[source]
bus_E_cap()[source]
calc_instance_power(value)[source]

calc_instance_power takes in a power value, and converts it to the corresponding load on the ESS. This is a simple stopgap.

Parameters:

value – a power value in Watts, as an int or float.

Returns:

converted battery power as a float.

calc_voltage_simple(value)[source]

Use a simple resistance model to calculate the voltage of a cell based off of a given power.

cell_SOH_loss_by_DB(dq, c)[source]

Use the DB equation to determine cell capacity decay using a linear fit aging parameter.

Parameters:
  • dq – Change in charge of a cell, in units corresponding the the decay parameter (default kWh)

  • c – C-rate the battery is operating at.

Returns:

a value, in the same units as dq, corresponding to the modeled linear aging.

copy()[source]
decay_by_c_rate(c_rate)[source]

Determine the capacity decay coefficient from the c-rate.

Parameters:

c_rate – a C rate being experienced by a battery, as an int or float.

Returns:

a flat decay coefficient based on the c-rate.

save(filepath)[source]
class reRoute_Dynamics.Object_Params.Trip(pass_mass=70, limit_MOE=4.47, signal_rest=32.5, signal_chance=0.541666, stop_rest=7, sign_rest=7, end_rest=10, air_density=1.2, wind_speed=1.78, wind_heading='SE', temperature=12.788, interp_length=10, mean_ridership=3.5, seed=42, lg=43, deg=3, stop_margin=1, traffic=0)[source]

Bases: object

copy()[source]
save(filepath)[source]
reRoute_Dynamics.Object_Params.a_eqn(t, m=-4.9661, b=2.9465)[source]

a_eqn is used to calculate the acceleration at a given time during the acceleration process from zero. the default values are based on a fit of the Braunschweig drive cycle.

Parameters:
  • t – time, in seconds, since the bus began accelerating, as a float

  • m – slope value of the linear fit of 1/t vs ln(v) using data aggregated from Braunschweig https://www.nrel.gov/transportation/drive-cycle-tool/ Default of -4.9661.

  • b – intercept value of aformentioned fit as float. Default of 2.9465.

Returns:

acceleration in m/s^2.

reRoute_Dynamics.Object_Params.generate_a_profile(filepath, m=-4.9661, b=2.9465, start=0, stop=34, step=0.5)[source]

generate_a_profile() takes the fit parameters for an acceleration profile, and generates one for a given range and step and saves at a filepath.

Parameters:
  • filepath – savefile path and filename.

  • m – slope value of the linear fit of 1/t vs ln(v) using data aggregated from

Braunschweig https://www.nrel.gov/transportation/drive-cycle-tool/

Default of -4.9661.

Parameters:
  • b – intercept value of aformentioned fit as float. Default of 2.9465.

  • start – starting value for range. Default value of 0

  • stop – stop value for range. Default value of 34

  • step – step size for range. Default of .5.

Returns:

filepath to generated acceleration profile

reRoute_Dynamics.Object_Params.load_ESS_params(filepath)[source]
reRoute_Dynamics.Object_Params.load_bus_params(filepath)[source]
reRoute_Dynamics.Object_Params.load_trip_params(filepath)[source]

reRoute_Dynamics.Physics_Engine module

Physics_Engine.py S. Peck

Physics_Engine.py contains methods used in the calculation of energy, speed changes, and time for a bus object based on external conditions, using a Longitudinal Dynamic Model.

Methods: calculate_wind_force() - method for determining the force that wind exerts on a moving vehicle. sign() - method to get what sign (positive or negative) a number is calculate_grade_froce() - method for determining the force that the road exerts on a moving vehicle. get_braking_distance() - method to calculate the distance it will take a vehicle to stop at its current conditions. brake() - method that determines the final velocity, power use, and time change to brake a vehicle for a distance. maintain() - method that determines the final velocity, power use, and time change to maintain a vehicle’s speed. accelerate() - method to determine the final velocity, power use, and time change to accelerate a vehicle with a given profile.

reRoute_Dynamics.Physics_Engine.accelerate(velocity, mass, travel_distance, grade_force, wind_force, raw_a_prof=       0         1 0    0.0  0.018375 1    0.5  0.659044 2    1.0  1.533375 3    1.5  1.973464 4    2.0  2.075316 ..   ...       ... 62  31.0  0.081391 63  31.5  0.079062 64  32.0  0.076831 65  32.5  0.074693 66  33.0  0.072643  [67 rows x 2 columns], braking_acceleration=1.5, braking_factor=0.5, inertial_factor=1.1, max_power=160000, max_acc=0.4, max_timestep=0.5)[source]

accelerate() is used to determine the velocity change, time change, and power consumption of accelerating a mass at a given velocity over a set distance, with a given acceleration profile.

Parameters:
  • velocity – object’s initial velocity as a float, in m/s.

  • mass – mass of the object in kg.

  • travel_distance – distance to brake over, in meters.

  • grade_force – force, in N, due to the grade of the slope the object experiences.

  • wind_force – force, in N, experienced by the object due to wind resistance.

  • raw_a_prof – an acceleration profile, with the 0 index column being cumulative time, and the 1 being acceleration at that time (in m/s^2)

  • braking_acceleration – the maximum acceleration due to braking, as float. Default 1.5 m/s^2

:param braking_factor : loat between 0 and 1 representing how much of the max braking acceleration is used. Default .5. :param inertial_factor : loat representing how inertia affects the acceleration of the bus. Default 1.1 :param max_power: float representing the maximum motor power. Default 160000 W.

Returns:

a dict containing final velocity v_f, time change dt, and power P.

reRoute_Dynamics.Physics_Engine.brake(velocity, mass, travel_distance, grade_force, wind_force, braking_acceleration=1.5, braking_factor=0.5, inertial_factor=1.1, max_distance=304.8)[source]

brake() is used to determine the velocity change, time change, and power consumption of braking a mass at a given velocity over a set distance.

Parameters:
  • velocity – object’s initial velocity as a float, in m/s.

  • mass – mass of the object in kg.

  • travel_distance – distance to brake over, in meters.

  • grade_force – force, in N, due to the grade of the slope the object experiences.

  • wind_force – force, in N, experienced by the object due to wind resistance.

  • braking_acceleration – the maximum acceleration due to braking, as float. Default 1.5 m/s^2

  • braking_factor – float between 0 and 1 representing how much of the max braking acceleration is used. Default .5.

  • inertial_factor – float representing how inertia affects the acceleration of the bus. Default 1.1

  • max_distance – float representing the ideal maximum distance the bust takes to stop. Default 304.8 m. UNUSED

Returns:

a dict containing final velocity v_f, time change dt, power P, and braking factor bf.

reRoute_Dynamics.Physics_Engine.calculate_grade_force(grade, mass, f_coeff=0.01)[source]

calculate_grade_force takes a grade of a slope, a mass, and friction coefficient, and calculates the force due to gravity against the direction of travel of the mass. Negative value means the object is being accelerated, rather than decellerated.

Parameters:
  • grade – grade angle of a point, as a percent float.

  • mass – mass of object as a float, in kg

  • f_coeff – the coefficient of friction. default .01.

Returns:

net force due to gravity as float, in Newtons

reRoute_Dynamics.Physics_Engine.calculate_wind_force(bearing, speed, wind_bearing=135.0, wind_speed=4, air_density=1.2, drag_coeff=0.6, frontal_area=8.58)[source]

calculate_wind_force() is used to calculate the force exerted against the bus’s direction of travel by the wind.

Parameters:
  • bearing – compass heading, in degrees (float), the bus is travelling in.

  • speed – current bus velocity. (float)

  • wind_bearing – compass heading, in degrees (float), the wind is in. Default of SE directon

  • wind_speed – current wind velocity in its direction of travel. (float) Default of 4 m/s.

  • air_density – current air density. (float), Default 1.2 kg/m^3.

  • drag_coeff – drag coefficient of the bus. (float), default .6.

  • frontal_area – frontal area of bus. (float), default 2.6*3.3 m^2

Returns:

float representation of force exerted against bus’s direction

of travel. Negative means the bus is being accelerated by the wind.

reRoute_Dynamics.Physics_Engine.get_braking_distance(velocity, mass, grade_force, wind_force, braking_acceleration=1.5, braking_factor=0.5, inertial_factor=1.1, max_distance=304.8)[source]

get_braking_distance() is used to determine how far an object needs to stop.

Parameters:
  • velocity – object’s initial velocity as a float, in m/s.

  • mass – mass of the object in kg.

  • grade_force – force, in N, due to the grade of the slope the object experiences.

  • wind_force – force, in N, experienced by the object due to wind resistance.

  • braking_acceleration – the maximum acceleration due to braking, as float. Default 1.5 m/s^2

  • braking_factor – float between 0 and 1 representing how much of the max braking acceleration is used. Default .5.

  • inertial_factor – float representing how inertia affects the acceleration of the bus. Default 1.1

  • max_distance – float representing the ideal maximum distance the bust takes to stop. Default 304.8 m.

Returns:

a dict containing braking distance dx, braking factor bf, and decelleration rate ad.

reRoute_Dynamics.Physics_Engine.maintain(velocity, mass, travel_distance, grade_force, wind_force, braking_acceleration=1.5, braking_factor=0.5, inertial_factor=1.1, max_power=160000)[source]

maintain() is used to determine the velocity change, time change, and power consumption of maintaining a mass at a given velocity over a set distance.

Parameters:
  • velocity – object’s initial velocity as a float, in m/s.

  • mass – mass of the object in kg.

  • travel_distance – distance to brake over, in meters.

  • grade_force – force, in N, due to the grade of the slope the object experiences.

  • wind_force – force, in N, experienced by the object due to wind resistance.

  • braking_acceleration – the maximum acceleration due to braking, as float. Default 1.5 m/s^2

  • braking_factor – float between 0 and 1 representing how much of the max braking acceleration is used. Default .5.

  • inertial_factor – float representing how inertia affects the acceleration of the bus. Default 1.1

  • max_power – float representing the maximum motor power. Default 160000 W.

Returns:

a dict containing final velocity v_f, time change dt, and power P.

reRoute_Dynamics.Physics_Engine.sign(num)[source]

sign checks the sign of a number.

reRoute_Dynamics.Trip_Simulator module

Trip_Simulator.py S. Peck

Trip_Simulator.py contains the method and scripting used to simulate a vehicle trip by passing a vehicle and its driving conditions through logic and then into a Longitudinal Dynamics Model in Physics_Engine.py. This can also be run as a standalone script.

Methods: simulate_trip.py - method to run a vehicle with a given ESS on a given trip over a given route.

reRoute_Dynamics.Trip_Simulator.simulate_trip(route, trip=<Object_Params.Trip object>, bus=<Object_Params.Bus object>, ESS=<Object_Params.ESS object>)[source]

simulate_trip() takes a route, and returns a modeled power consumption and velocity for a vehicle on that given trip.

Parameters:
  • route – a route object as exported by Geography_Tools.py that the vehicle will traverse

  • trip – a trip object from Object_Params that determines the external conditions of the trip Default: Object_Parameters.Trip()

  • bus – a bus object from Object_Params that determines the vehicle design Default: Object_Parameters.Bus()

  • ESS – an ess object from Object_Params that determines the Energy Storage System design Default: Object_Parameters.ESS()

Returns:

a geodataframe that provides all the relevant driving conditions, positional velocity, and modeled power required.

Module contents