Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update energy query with new power demand model #996

Merged
merged 5 commits into from
Jul 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions flow/data_pipeline/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,12 @@
speed,
acceleration,
road_grade,
GREATEST(0, 2041 * speed * ((
CASE
WHEN acceleration > 0 THEN 1
WHEN acceleration < 0 THEN 0
ELSE 0.5
END * (1 - {0}) + {0}) * acceleration + 9.807 * SIN(road_grade)
) + 2041 * 9.807 * 0.0027 * speed + 0.5 * 1.225 * 3.2 * 0.4 * POW(speed,3)) AS power,
GREATEST(0, 2041 * acceleration * speed +
3405.5481762 +
83.12392997 * speed +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this probably doesn't matter, but the C_1 in the document is 83.123929917, there is missing one towards the end

6.7650718327 * POW(speed,2) +
0.7041355229 * POW(speed,3)
) + GREATEST(0, 4598.7155 * accel + 975.12719 * accel * speed) AS power,
\'{1}\' AS energy_model_id,
source_id
FROM {2}
Expand Down Expand Up @@ -361,7 +360,7 @@ class QueryStrings(Enum):
distance_meters,
power_watts * time_step_size_seconds AS energy_joules,
distance_meters / (power_watts * time_step_size_seconds) AS efficiency_meters_per_joules,
19972 * distance_meters / (power_watts * time_step_size_seconds) AS efficiency_miles_per_gallon
33561 * distance_meters / (power_watts * time_step_size_seconds) AS efficiency_miles_per_gallon
FROM sub_fact_vehicle_trace
WHERE 1 = 1
AND power_watts * time_step_size_seconds != 0
Expand Down Expand Up @@ -404,7 +403,7 @@ class QueryStrings(Enum):
SUM(distance_meters) AS distance_meters,
SUM(energy_joules) AS energy_joules,
SUM(distance_meters) / SUM(energy_joules) AS efficiency_meters_per_joules,
19972 * SUM(distance_meters) / SUM(energy_joules) AS efficiency_miles_per_gallon
33561 * SUM(distance_meters) / SUM(energy_joules) AS efficiency_miles_per_gallon
FROM fact_vehicle_fuel_efficiency_agg
WHERE 1 = 1
AND date = \'{date}\'
Expand All @@ -420,7 +419,7 @@ class QueryStrings(Enum):
t.source_id,
e.energy_model_id,
e.efficiency_meters_per_joules,
19972 * e.efficiency_meters_per_joules AS efficiency_miles_per_gallon,
33561 * e.efficiency_meters_per_joules AS efficiency_miles_per_gallon,
t.throughput_per_hour,
s.safety_rate,
s.safety_value_max
Expand Down