Skip to content

Commit fc1be20

Browse files
committed
Change logic
1 parent 3088fb5 commit fc1be20

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

src/simulation/investment.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,20 +206,19 @@ fn update_demand_map(demand: &mut AllDemandMap, flows: &FlowMap, assets: &[Asset
206206
time_slice.clone(),
207207
);
208208

209-
// Only consider output flows from the primary commodity
210-
if flow > &Flow(0.0)
211-
&& asset
209+
// Only consider input flows and output flows from the primary output commodity
210+
// (excluding secondary outputs)
211+
if (flow < &Flow(0.0))
212+
| asset
212213
.primary_output()
213214
.is_some_and(|p| &p.commodity.id != commodity_id)
214215
{
215-
continue;
216+
// Note: we use the negative of the flow as input flows are negative in the flow map.
217+
demand
218+
.entry(key)
219+
.and_modify(|value| *value -= *flow)
220+
.or_insert(-*flow);
216221
}
217-
218-
// Note: we use the negative of the flow as input flows are negative in the flow map.
219-
demand
220-
.entry(key)
221-
.and_modify(|value| *value -= *flow)
222-
.or_insert(-*flow);
223222
}
224223
}
225224
}

0 commit comments

Comments
 (0)