Skip to content
Open
Show file tree
Hide file tree
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
26 changes: 13 additions & 13 deletions examples/circularity/commodities.csv
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
id,description,type,time_slice_level
OILCRD,Crude oil,sed,season
GASPRD,Gas produced,sed,season
GASOLI,Gasoline,sed,season
DIESEL,Diesel,sed,season
GASNAT,Natural gas,sed,season
ELCTRI,Electricity,sed,daynight
H2YPRD,Hydrogen,sed,season
TPASKM,Passenger kms,svd,daynight
RSHEAT,Residential heating,svd,daynight
CO2EMT,CO2 emitted,oth,annual
BIOPRD,Biomass produced,sed,season
BIOPEL,Biomass pellets,sed,season
id,description,type,time_slice_level,units
OILCRD,Crude oil,sed,season,NOUNIT
GASPRD,Gas produced,sed,season,NOUNIT
GASOLI,Gasoline,sed,season,NOUNIT
DIESEL,Diesel,sed,season,NOUNIT
GASNAT,Natural gas,sed,season,NOUNIT
ELCTRI,Electricity,sed,daynight,NOUNIT
H2YPRD,Hydrogen,sed,season,NOUNIT
TPASKM,Passenger kms,svd,daynight,NOUNIT
Copy link
Collaborator

Choose a reason for hiding this comment

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

Presumably the unit of this one is km 😄

RSHEAT,Residential heating,svd,daynight,NOUNIT
CO2EMT,CO2 emitted,oth,annual,NOUNIT
BIOPRD,Biomass produced,sed,season,NOUNIT
BIOPEL,Biomass pellets,sed,season,NOUNIT
16 changes: 8 additions & 8 deletions examples/missing_commodity/commodities.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
id,description,type,time_slice_level
GASPRD,Gas produced,sed,season
GASNAT,Natural gas,sed,season
BIOPRD,Biomass produced,sed,season
BIOPEL,Biomass pellets,sed,season
ELCTRI,Electricity,sed,daynight
RSHEAT,Residential heating,svd,daynight
CO2EMT,CO2 emitted,oth,annual
id,description,type,time_slice_level,units
GASPRD,Gas produced,sed,season,NOUNIT
GASNAT,Natural gas,sed,season,NOUNIT
BIOPRD,Biomass produced,sed,season,NOUNIT
BIOPEL,Biomass pellets,sed,season,NOUNIT
ELCTRI,Electricity,sed,daynight,NOUNIT
RSHEAT,Residential heating,svd,daynight,NOUNIT
CO2EMT,CO2 emitted,oth,annual,NOUNIT
12 changes: 6 additions & 6 deletions examples/muse1_default/commodities.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id,description,type,time_slice_level
electricity,Electricity,sed,daynight
gas,Gas,sed,daynight
heat,Heat,svd,daynight
wind,Wind,oth,daynight
CO2f,Carbon dioxide,oth,daynight
id,description,type,time_slice_level,units
electricity,Electricity,sed,daynight,PJ
gas,Gas,sed,daynight,PJ
heat,Heat,svd,daynight,PJ
wind,Wind,oth,daynight,PJ
CO2f,Carbon dioxide,oth,daynight,kt
12 changes: 6 additions & 6 deletions examples/simple/commodities.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id,description,type,time_slice_level
GASPRD,Gas produced,sed,season
GASNAT,Natural gas,sed,season
ELCTRI,Electricity,sed,daynight
RSHEAT,Residential heating,svd,daynight
CO2EMT,CO2 emitted,oth,annual
id,description,type,time_slice_level,units
GASPRD,Gas produced,sed,season,NOUNIT
GASNAT,Natural gas,sed,season,NOUNIT
ELCTRI,Electricity,sed,daynight,NOUNIT
RSHEAT,Residential heating,svd,daynight,NOUNIT
CO2EMT,CO2 emitted,oth,annual,NOUNIT
24 changes: 12 additions & 12 deletions examples/two_outputs/commodities.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
id,description,type,time_slice_level
OILCRD,Crude oil,sed,season
GASPRD,Gas produced,sed,season
GASOLI,Gasoline,sed,season
DIESEL,Diesel,sed,season
GASNAT,Natural gas,sed,season
ELCTRI,Electricity,sed,daynight
TPASKM,Passenger kms,svd,daynight
RSHEAT,Residential heating,svd,daynight
CO2EMT,CO2 emitted,oth,annual
BIOPRD,Biomass produced,sed,season
BIOPEL,Biomass pellets,sed,season
id,description,type,time_slice_level,units
OILCRD,Crude oil,sed,season,NOUNIT
GASPRD,Gas produced,sed,season,NOUNIT
GASOLI,Gasoline,sed,season,NOUNIT
DIESEL,Diesel,sed,season,NOUNIT
GASNAT,Natural gas,sed,season,NOUNIT
ELCTRI,Electricity,sed,daynight,NOUNIT
TPASKM,Passenger kms,svd,daynight,NOUNIT
RSHEAT,Residential heating,svd,daynight,NOUNIT
CO2EMT,CO2 emitted,oth,annual,NOUNIT
BIOPRD,Biomass produced,sed,season,NOUNIT
BIOPEL,Biomass pellets,sed,season,NOUNIT
12 changes: 6 additions & 6 deletions examples/two_regions/commodities.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id,description,type,time_slice_level
electricity,Electricity,sed,daynight
gas,Gas,sed,daynight
heat,Heat,svd,daynight
wind,Wind,oth,daynight
CO2f,Carbon dioxide,oth,daynight
id,description,type,time_slice_level,units
electricity,Electricity,sed,daynight,PJ
gas,Gas,sed,daynight,PJ
heat,Heat,svd,daynight,PJ
wind,Wind,oth,daynight,PJ
CO2f,Carbon dioxide,oth,daynight,kt
8 changes: 8 additions & 0 deletions schemas/input/commodities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@ fields:

If unspecified, the commodity will use the default pricing strategy according to the commodity
type: `shadow` for `svd` and `sed` commodities, and `unpriced` for `oth` commodities.
- name: units
type: string
description: The units of measurement for this commodity
notes: |
This field is used for validation only and is not used for internal unit conversions. MUSE
will validate that all SED/SVD output flows from the same process have the same units,
as the annual fixed costs are distributed proportionally between outputs based on flow coefficients.
E.g. `Petajoules`, `Tonnes`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd give the abbreviations because that's what users will probably do:

Suggested change
E.g. `Petajoules`, `Tonnes`.
E.g. "PJ" (petajoules) or "t" (tonnes)

3 changes: 3 additions & 0 deletions src/commodity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ pub struct Commodity {
/// `time_slice_level` field. E.g. if the `time_slice_level` is seasonal, then there will be
/// keys representing each season (and not e.g. individual time slices).
pub demand: DemandMap,
/// Units for this commodity represented as a string e.g Petajoules, Tonnes
/// This is only used for validation purposes.
pub units: String,
}
define_id_getter! {Commodity, CommodityID}

Expand Down
37 changes: 35 additions & 2 deletions src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ pub fn svd_commodity() -> Commodity {
levies_prod: CommodityLevyMap::new(),
levies_cons: CommodityLevyMap::new(),
demand: DemandMap::new(),
units: "PJ".into(),
}
}

Expand All @@ -164,6 +165,7 @@ pub fn sed_commodity() -> Commodity {
levies_prod: CommodityLevyMap::new(),
levies_cons: CommodityLevyMap::new(),
demand: DemandMap::new(),
units: "PJ".into(),
}
}

Expand All @@ -178,6 +180,37 @@ pub fn other_commodity() -> Commodity {
levies_prod: CommodityLevyMap::new(),
levies_cons: CommodityLevyMap::new(),
demand: DemandMap::new(),
units: "PJ".into(),
}
}

#[fixture]
pub fn sed_commodity_pj() -> Commodity {
Commodity {
id: "sed_pj".into(),
description: "Test SED commodity (PJ)".into(),
kind: CommodityType::SupplyEqualsDemand,
time_slice_level: TimeSliceLevel::DayNight,
pricing_strategy: PricingStrategy::Shadow,
levies_prod: CommodityLevyMap::new(),
levies_cons: CommodityLevyMap::new(),
demand: DemandMap::new(),
units: "PJ".into(),
}
}

#[fixture]
pub fn sed_commodity_tonnes() -> Commodity {
Commodity {
id: "sed_tonnes".into(),
description: "Test SED commodity (tonnes)".into(),
kind: CommodityType::SupplyEqualsDemand,
time_slice_level: TimeSliceLevel::DayNight,
pricing_strategy: PricingStrategy::Shadow,
levies_prod: CommodityLevyMap::new(),
levies_cons: CommodityLevyMap::new(),
demand: DemandMap::new(),
units: "tonnes".into(),
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we probs won't want these fixtures anywhere outside of input/commodity.rs? In which case that's probably where they should live


Expand Down Expand Up @@ -415,14 +448,14 @@ mod tests {
#[test]
fn patch_and_validate_simple_fail() {
let patch = FilePatch::new("commodities.csv")
.with_deletion("RSHEAT,Residential heating,svd,daynight");
.with_deletion("RSHEAT,Residential heating,svd,daynight,NOUNIT");
assert!(patch_and_validate_simple!(vec![patch]).is_err());
}

#[test]
fn patch_and_run_simple_fail() {
let patch = FilePatch::new("commodities.csv")
.with_deletion("RSHEAT,Residential heating,svd,daynight");
.with_deletion("RSHEAT,Residential heating,svd,daynight,NOUNIT");
assert!(patch_and_run_simple!(vec![patch]).is_err());
}
}
2 changes: 2 additions & 0 deletions src/input/agent/commodity_portion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ mod tests {
levies_prod: CommodityLevyMap::new(),
levies_cons: CommodityLevyMap::new(),
demand: DemandMap::new(),
units: "PJ".into(),
}),
)]);

Expand Down Expand Up @@ -269,6 +270,7 @@ mod tests {
levies_prod: CommodityLevyMap::new(),
levies_cons: CommodityLevyMap::new(),
demand: DemandMap::new(),
units: "PJ".into(),
}),
);
assert!(
Expand Down
3 changes: 3 additions & 0 deletions src/input/commodity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct CommodityRaw {
pub kind: CommodityType,
pub time_slice_level: TimeSliceLevel,
pub pricing_strategy: Option<PricingStrategy>,
pub units: String,
}

/// Read commodity data from the specified model directory.
Expand Down Expand Up @@ -119,6 +120,7 @@ where
levies_prod: CommodityLevyMap::default(),
levies_cons: CommodityLevyMap::default(),
demand: DemandMap::default(),
units: commodity_raw.units,
};

validate_commodity(&commodity)?;
Expand Down Expand Up @@ -200,6 +202,7 @@ mod tests {
levies_prod: CommodityLevyMap::default(),
levies_cons: CommodityLevyMap::default(),
demand: DemandMap::default(),
units: "PJ".into(),
}
}

Expand Down
Loading