Skip to content

Commit 9db4f17

Browse files
committed
Rename: flow => coeff
Closes #602.
1 parent 56956fe commit 9db4f17

5 files changed

Lines changed: 20 additions & 20 deletions

File tree

examples/simple/process_flows.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
process_id,commodity_id,regions,years,flow,flow_type,flow_cost,is_pac
1+
process_id,commodity_id,regions,years,coeff,flow_type,flow_cost,is_pac
22
GASDRV,GASPRD,all,all,1.0,fixed,,true
33
GASPRC,GASPRD,all,all,-1.05,fixed,,false
44
GASPRC,GASNAT,all,all,1.0,fixed,,true

schemas/input/process_flows.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fields:
2323
type: string
2424
title: The year(s) to which this entry applies
2525
description: One or more milestone years separated by semicolons or `all`
26-
- name: flow
26+
- name: coeff
2727
type: number
2828
title: The flow for this commodity
2929
description: |

src/input/process.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ fn validate_sed_commodity(
205205
for flows in flows.values() {
206206
let flows = flows.get(&(region_id.clone(), *year)).unwrap();
207207
if let Some(flow) = flows.get(&commodity_id.clone()) {
208-
if flow.flow > 0.0 {
208+
if flow.coeff > 0.0 {
209209
has_producer = true;
210-
} else if flow.flow < 0.0 {
210+
} else if flow.coeff < 0.0 {
211211
has_consumer = true;
212212
}
213213
}
@@ -250,7 +250,7 @@ fn validate_svd_commodity(
250250
// We're only interested in processes which produce this commodity
251251
continue;
252252
};
253-
if flow.flow <= 0.0 {
253+
if flow.coeff <= 0.0 {
254254
// Check if it's a producer
255255
continue;
256256
}
@@ -305,7 +305,7 @@ mod tests {
305305
("GBR".into(), 2010),
306306
indexmap! { commodity_sed.id.clone() => ProcessFlow {
307307
commodity: commodity_sed.into(),
308-
flow: -10.0,
308+
coeff: -10.0,
309309
flow_type: FlowType::Fixed,
310310
flow_cost: 1.0,
311311
is_pac: false,
@@ -319,7 +319,7 @@ mod tests {
319319
("GBR".into(), 2010),
320320
indexmap! {commodity_sed.id.clone()=>ProcessFlow {
321321
commodity: commodity_sed.into(),
322-
flow: 10.0,
322+
coeff: 10.0,
323323
flow_type: FlowType::Fixed,
324324
flow_cost: 1.0,
325325
is_pac: false,
@@ -380,7 +380,7 @@ mod tests {
380380
("GBR".into(), 2010),
381381
indexmap! { commodity_svd.id.clone() => ProcessFlow {
382382
commodity: commodity_svd.into(),
383-
flow: 10.0,
383+
coeff: 10.0,
384384
flow_type: FlowType::Fixed,
385385
flow_cost: 1.0,
386386
is_pac: false,

src/input/process/flow.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct ProcessFlowRaw {
2020
commodity_id: String,
2121
years: String,
2222
regions: String,
23-
flow: f64,
23+
coeff: f64,
2424
#[serde(default)]
2525
flow_type: FlowType,
2626
flow_cost: Option<f64>,
@@ -31,9 +31,9 @@ impl ProcessFlowRaw {
3131
fn validate(&self) -> Result<()> {
3232
// Check that flow is not infinity, nan, 0 etc.
3333
ensure!(
34-
self.flow.is_normal(),
35-
"Invalid value for flow ({})",
36-
self.flow
34+
self.coeff.is_normal(),
35+
"Invalid value for coeff ({})",
36+
self.coeff
3737
);
3838

3939
// **TODO**: https://github.com/EnergySystemsModellingLab/MUSE_2.0/issues/300
@@ -108,7 +108,7 @@ where
108108
// Create ProcessFlow object
109109
let process_flow = ProcessFlow {
110110
commodity: Rc::clone(commodity),
111-
flow: record.flow,
111+
coeff: record.coeff,
112112
flow_type: record.flow_type,
113113
flow_cost: record.flow_cost.unwrap_or(0.0),
114114
is_pac: record.is_pac,
@@ -177,7 +177,7 @@ fn validate_flow_map(flow_map: &IndexMap<CommodityID, ProcessFlow>) -> Result<()
177177
let mut flow_sign: Option<bool> = None; // False for inputs, true for outputs
178178
for flow in flow_map.values().filter(|flow| flow.is_pac) {
179179
// Check that flow sign is consistent
180-
let current_flow_sign = flow.flow > 0.0;
180+
let current_flow_sign = flow.coeff > 0.0;
181181
if let Some(flow_sign) = flow_sign {
182182
ensure!(
183183
current_flow_sign == flow_sign,
@@ -202,7 +202,7 @@ mod tests {
202202
use rstest::{fixture, rstest};
203203

204204
fn create_process_flow_raw(
205-
flow: f64,
205+
coeff: f64,
206206
flow_type: FlowType,
207207
flow_cost: Option<f64>,
208208
is_pac: bool,
@@ -212,7 +212,7 @@ mod tests {
212212
commodity_id: "commodity".into(),
213213
years: "2020".into(),
214214
regions: "region".into(),
215-
flow,
215+
coeff,
216216
flow_type,
217217
flow_cost,
218218
is_pac,
@@ -244,10 +244,10 @@ mod tests {
244244
assert!(invalid.validate().is_err());
245245
}
246246

247-
fn create_process_flow(commodity: Rc<Commodity>, flow: f64, is_pac: bool) -> ProcessFlow {
247+
fn create_process_flow(commodity: Rc<Commodity>, coeff: f64, is_pac: bool) -> ProcessFlow {
248248
ProcessFlow {
249249
commodity,
250-
flow,
250+
coeff,
251251
flow_type: FlowType::Fixed,
252252
flow_cost: 0.0,
253253
is_pac,

src/process.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ impl Process {
7777
}
7878
}
7979

80-
/// Represents a maximum annual commodity flow for a given process
80+
/// Represents a maximum annual commodity coeff for a given process
8181
#[derive(PartialEq, Debug, Clone)]
8282
pub struct ProcessFlow {
8383
/// The commodity produced or consumed by this flow
8484
pub commodity: Rc<Commodity>,
8585
/// Maximum annual commodity flow quantity relative to other commodity flows.
8686
///
8787
/// Positive value indicates flow out and negative value indicates flow in.
88-
pub flow: f64,
88+
pub coeff: f64,
8989
/// Identifies if a flow is fixed or flexible.
9090
pub flow_type: FlowType,
9191
/// Cost per unit flow.

0 commit comments

Comments
 (0)