Skip to content
Draft
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
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ missing_panics_doc = "allow"
implicit_hasher = "allow"
cast_lossless = "allow"
return_self_not_must_use = "allow"
from_iter_instead_of_collect = "allow"

[[bench]]
name = "examples"
Expand Down
14 changes: 9 additions & 5 deletions benches/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,16 @@ fn calculate_seed_prices(
candidates: &[AssetRef],
writer: &mut DataWriter,
) -> Prices {
let solution_existing = DispatchRun::new(model, base_year_assets, BASE_YEAR)
let market_demands =
flatten_preset_demands_for_year(&model.commodities, &model.time_slice_info, BASE_YEAR);
let solution_existing = DispatchRun::new(model, base_year_assets, BASE_YEAR, &market_demands)
.run("bench setup: without candidates", writer)
.expect("Dispatch without candidates failed");
let solution_with_candidates = DispatchRun::new(model, base_year_assets, BASE_YEAR)
.with_candidates(candidates)
.run("bench setup: with candidates", writer)
.expect("Dispatch with candidates failed");
let solution_with_candidates =
DispatchRun::new(model, base_year_assets, BASE_YEAR, &market_demands)
.with_candidates(candidates)
.run("bench setup: with candidates", writer)
.expect("Dispatch with candidates failed");

calculate_prices(
model,
Expand Down Expand Up @@ -162,6 +165,7 @@ fn criterion_benchmark(c: &mut Criterion) {
&commodity.id,
region_id,
commodity_portion,
commodity.time_slice_level,
);

// Real candidate technologies for this market, used as templates to build up to
Expand Down
38 changes: 19 additions & 19 deletions examples/circularity/processes.csv
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
id,description,regions,primary_output,start_year,end_year,capacity_to_activity
GASDRV,Dry gas extraction,GBR,GASPRD,2020,,1.0
OAGRSV,Oil and associated gas extraction,GBR,OILCRD,2020,,1.0
GASPRC,Gas processing,GBR,GASNAT,2020,,1.0
OILREF,Oil refinery,GBR,DIESEL,2020,,1.0
OILRF2,O2G refinery,GBR,GASOLI,2020,,1.0
WNDFRM,Wind farm,GBR,ELCTRI,2020,,31.54
GASCGT,Gas combined cycle turbine,GBR,ELCTRI,2020,,31.54
H2YGEN,H2 turbine,GBR,ELCTRI,2020,,31.54
H2YPRO,H2 electrolyer,GBR,H2YPRD,2020,,1.0
TPETCR,Petrol car,GBR,TPASKM,2020,,1.0
TDIECR,Diesel car,GBR,TPASKM,2020,,1.0
TELCCR,Electric car,GBR,TPASKM,2020,,1.0
THYBCR,Plug-in hybrid car,GBR,TPASKM,2020,,1.0
RGASBR,Gas boiler,GBR,RSHEAT,2020,,1.0
RELCHP,Heat pump,GBR,RSHEAT,2020,,1.0
BIOPRO,Biomass production,all,BIOPRD,2020,,1.0
BIOPLL,Biomass pelletiser,all,BIOPEL,2020,,1.0
RBIOBL,Biomass boiler,all,RSHEAT,2020,,1.0
id,description,regions,primary_output,start_year,end_year,capacity_to_activity,feedback_process
GASDRV,Dry gas extraction,GBR,GASPRD,2020,,1.0,
OAGRSV,Oil and associated gas extraction,GBR,OILCRD,2020,,1.0,
GASPRC,Gas processing,GBR,GASNAT,2020,,1.0,
OILREF,Oil refinery,GBR,DIESEL,2020,,1.0,
OILRF2,O2G refinery,GBR,GASOLI,2020,,1.0,
WNDFRM,Wind farm,GBR,ELCTRI,2020,,31.54,
GASCGT,Gas combined cycle turbine,GBR,ELCTRI,2020,,31.54,
H2YGEN,H2 turbine,GBR,ELCTRI,2020,,31.54,true
H2YPRO,H2 electrolyer,GBR,H2YPRD,2020,,1.0,true
TPETCR,Petrol car,GBR,TPASKM,2020,,1.0,
TDIECR,Diesel car,GBR,TPASKM,2020,,1.0,
TELCCR,Electric car,GBR,TPASKM,2020,,1.0,
THYBCR,Plug-in hybrid car,GBR,TPASKM,2020,,1.0,
RGASBR,Gas boiler,GBR,RSHEAT,2020,,1.0,
RELCHP,Heat pump,GBR,RSHEAT,2020,,1.0,
BIOPRO,Biomass production,all,BIOPRD,2020,,1.0,
BIOPLL,Biomass pelletiser,all,BIOPEL,2020,,1.0,
RBIOBL,Biomass boiler,all,RSHEAT,2020,,1.0,
4 changes: 0 additions & 4 deletions schemas/input/model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ properties:
type: number
description: The relative tolerance for price convergence in the ironing out loop
default: 1e-6
capacity_margin:
type: number
description: Slack proportion for assets selected during cycle balancing to absorb small demand shifts
default: 0.2
mothball_years:
type: integer
default: 0
Expand Down
2 changes: 1 addition & 1 deletion src/asset/capacity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl AssetCapacity {
pub fn new(num_tranches: u32, tranche_size: Capacity) -> Self {
assert!(
tranche_size.is_finite() && tranche_size >= Capacity(0.0),
"Tranche size must be a finite non-negative number"
"Tranche size must be a finite non-negative number. Got {tranche_size}"
);
AssetCapacity {
num_tranches,
Expand Down
5 changes: 3 additions & 2 deletions src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::simulation::investment::appraisal::LCOXMetric;
use crate::simulation::investment::appraisal::{
AppraisalOutput, coefficients::ObjectiveCoefficients,
};
use crate::time_slice::{TimeSliceID, TimeSliceInfo, TimeSliceLevel};
use crate::time_slice::{TimeSliceID, TimeSliceInfo, TimeSliceLevel, TimeSliceSelection};
use crate::units::{
Activity, ActivityPerCapacity, Capacity, Dimensionless, Flow, MoneyPerActivity,
MoneyPerCapacity, MoneyPerCapacityPerYear, Year,
Expand Down Expand Up @@ -325,6 +325,7 @@ pub fn process(
capacity_to_activity: ActivityPerCapacity(1.0),
investment_constraints: process_investment_constraints,
tranche_size: None,
feedback_process: false,
}
}

Expand Down Expand Up @@ -406,7 +407,7 @@ pub fn appraisal_output(asset: Asset, time_slice: TimeSliceID) -> AppraisalOutpu
let activity_coefficients = indexmap! { time_slice.clone() => MoneyPerActivity(0.5) };
let market_costs = indexmap! { time_slice.clone() => MoneyPerActivity(0.4) };
let activity = indexmap! { time_slice.clone() => Activity(10.0) };
let unmet_demand = indexmap! { time_slice.clone() => Flow(5.0) };
let unmet_demand = indexmap! { TimeSliceSelection::Single(time_slice.clone()) => Flow(5.0) };
AppraisalOutput {
asset: AssetRef::from(asset),
coefficients: Arc::new(ObjectiveCoefficients {
Expand Down
30 changes: 23 additions & 7 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,21 @@ pub enum GraphNode {
/// An edge in the commodity graph
pub enum GraphEdge {
/// An edge representing a primary flow of a process
#[display("{_0}")]
Primary(ProcessID),
#[display("{process_id}")]
Primary {
/// The process responsible for the flow.
process_id: ProcessID,
/// Whether the process participates in a feedback conversion.
feedback: bool,
},
/// An edge representing a secondary (non-primary) flow of a process
#[display("{_0}")]
Secondary(ProcessID),
#[display("{process_id}")]
Secondary {
/// The process responsible for the flow.
process_id: ProcessID,
/// Whether the process participates in a feedback conversion.
feedback: bool,
},
/// An edge representing a service demand
#[display("DEMAND")]
Demand,
Expand Down Expand Up @@ -150,9 +160,15 @@ fn create_commodities_graph_for_region_year(
source_node_index,
target_node_index,
if is_primary {
GraphEdge::Primary(process.id.clone())
GraphEdge::Primary {
process_id: process.id.clone(),
feedback: process.feedback_process,
}
} else {
GraphEdge::Secondary(process.id.clone())
GraphEdge::Secondary {
process_id: process.id.clone(),
feedback: process.feedback_process,
}
},
);
}
Expand Down Expand Up @@ -181,7 +197,7 @@ pub fn build_commodity_graphs_for_model(
fn get_edge_attributes(_: &CommoditiesGraph, edge_ref: EdgeReference<GraphEdge>) -> String {
match edge_ref.weight() {
// Use dashed lines for secondary flows
GraphEdge::Secondary(_) => "style=dashed".to_string(),
GraphEdge::Secondary { .. } => "style=dashed".to_string(),
// Other edges use default attributes
_ => String::new(),
}
Expand Down
Loading
Loading