@@ -61,26 +61,21 @@ def coal():
6161 return fx .Bus ('Kohle' )
6262
6363 @staticmethod
64- def all_standard ():
64+ def defaults ():
6565 """Get all standard buses at once"""
6666 return [Buses .electricity (), Buses .heat (), Buses .gas ()]
6767
68- @staticmethod
69- def all_with_coal ():
70- """Get all buses including coal"""
71- return [Buses .electricity (), Buses .heat (), Buses .gas (), Buses .coal ()]
72-
7368
7469class Effects :
7570 """Standard effects used across flow systems"""
7671
7772 @staticmethod
78- def costs_standard ():
73+ def costs ():
7974 return fx .Effect ('costs' , '€' , 'Kosten' , is_standard = True , is_objective = True )
8075
8176 @staticmethod
82- def costs_only ():
83- return fx .Effect ('Costs ' , '€ ' , 'Kosten' , is_standard = True , is_objective = True )
77+ def co2 ():
78+ return fx .Effect ('CO2 ' , 'kg ' , 'CO2_e-Emissionen' )
8479
8580 @staticmethod
8681 def co2_with_costs_share ():
@@ -89,23 +84,10 @@ def co2_with_costs_share():
8984 'kg' ,
9085 'CO2_e-Emissionen' ,
9186 specific_share_to_other_effects_operation = {'costs' : 0.2 },
92- maximum_operation_per_hour = 1000 ,
9387 )
9488
9589 @staticmethod
96- def co2_simple ():
97- return fx .Effect ('CO2' , 'kg' , 'CO2_e-Emissionen' , specific_share_to_other_effects_operation = {'costs' : 0.2 })
98-
99- @staticmethod
100- def co2_basic ():
101- return fx .Effect ('CO2' , 'kg' , 'CO2_e-Emissionen' )
102-
103- @staticmethod
104- def primary_energy_limited ():
105- return fx .Effect ('PE' , 'kWh_PE' , 'Primärenergie' , maximum_total = 3.5e3 )
106-
107- @staticmethod
108- def primary_energy_basic ():
90+ def primary_energy ():
10991 return fx .Effect ('PE' , 'kWh_PE' , 'Primärenergie' )
11092
11193
@@ -351,23 +333,17 @@ class Sources:
351333 """Energy sources"""
352334
353335 @staticmethod
354- def gas_with_co2 ():
336+ def gas_with_costs_and_co2 ():
355337 """Standard gas tariff with CO2 emissions"""
356- return fx . Source (
357- 'Gastarif' , source = fx . Flow ( 'Q_Gas' , bus = 'Gas' , size = 1000 , effects_per_flow_hour = {'costs' : 0.04 , 'CO2' : 0.3 })
358- )
338+ source = Sources . gas_with_costs ()
339+ source . source . effects_per_flow_hour = {'costs' : 0.04 , 'CO2' : 0.3 }
340+ return source
359341
360342 @staticmethod
361- def gas_simple ():
343+ def gas_with_costs ():
362344 """Simple gas tariff without CO2"""
363- return fx .Source ('Gastarif' , source = fx .Flow ('Q_Gas' , 'Gas' , size = 1000 , effects_per_flow_hour = 0.04 ))
364-
365- @staticmethod
366- def gas_with_price (gas_price ):
367- """Gas tariff with variable pricing"""
368345 return fx .Source (
369- 'Gastarif' ,
370- source = fx .Flow ('Q_Gas' , bus = 'Gas' , size = 1000 , effects_per_flow_hour = {'costs' : gas_price , 'CO2' : 0.3 }),
346+ 'Gastarif' , source = fx .Flow (label = 'Q_Gas' , bus = 'Gas' , size = 1000 , effects_per_flow_hour = {'costs' : 0.04 })
371347 )
372348
373349
@@ -386,20 +362,21 @@ def simple_flow_system() -> fx.FlowSystem:
386362 base_timesteps = pd .date_range ('2020-01-01' , periods = 9 , freq = 'h' , name = 'time' )
387363
388364 # Define effects
389- costs = Effects .costs_standard ()
365+ costs = Effects .costs ()
390366 co2 = Effects .co2_with_costs_share ()
367+ co2 .maximum_operation_per_hour = 1000
391368
392369 # Create components
393370 boiler = Converters .Boilers .simple ()
394371 chp = Converters .CHPs .simple ()
395372 storage = Storage .simple ()
396373 heat_load = Sinks .heat_load (base_thermal_load )
397- gas_tariff = Sources .gas_with_co2 ()
374+ gas_tariff = Sources .gas_with_costs_and_co2 ()
398375 electricity_feed_in = Sinks .electricity_feed_in (base_electrical_price )
399376
400377 # Create flow system
401378 flow_system = fx .FlowSystem (base_timesteps )
402- flow_system .add_elements (* Buses .all_standard ())
379+ flow_system .add_elements (* Buses .defaults ())
403380 flow_system .add_elements (storage , costs , co2 , boiler , heat_load , gas_tariff , electricity_feed_in , chp )
404381
405382 return flow_system
@@ -415,22 +392,23 @@ def simple_flow_system_scenarios() -> fx.FlowSystem:
415392 base_timesteps = pd .date_range ('2020-01-01' , periods = 9 , freq = 'h' , name = 'time' )
416393
417394 # Define effects
418- costs = Effects .costs_standard ()
395+ costs = Effects .costs ()
419396 co2 = Effects .co2_with_costs_share ()
397+ co2 .maximum_operation_per_hour = 1000
420398
421399 # Create components
422400 boiler = Converters .Boilers .simple ()
423401 chp = Converters .CHPs .simple ()
424402 storage = Storage .simple ()
425403 heat_load = Sinks .heat_load (base_thermal_load )
426- gas_tariff = Sources .gas_with_co2 ()
404+ gas_tariff = Sources .gas_with_costs_and_co2 ()
427405 electricity_feed_in = Sinks .electricity_feed_in (base_electrical_price )
428406
429407 # Create flow system
430408 flow_system = fx .FlowSystem (
431409 base_timesteps , scenarios = pd .Index (['A' , 'B' , 'C' ]), weights = np .array ([0.5 , 0.25 , 0.25 ])
432410 )
433- flow_system .add_elements (* Buses .all_standard ())
411+ flow_system .add_elements (* Buses .defaults ())
434412 flow_system .add_elements (storage , costs , co2 , boiler , heat_load , gas_tariff , electricity_feed_in , chp )
435413
436414 return flow_system
@@ -444,12 +422,12 @@ def basic_flow_system() -> fx.FlowSystem:
444422 thermal_load = LoadProfiles .random_thermal (10 )
445423 p_el = LoadProfiles .random_electrical (10 )
446424
447- costs = Effects .costs_only ()
425+ costs = Effects .costs ()
448426 heat_load = Sinks .heat_load (thermal_load )
449- gas_source = Sources .gas_simple ()
427+ gas_source = Sources .gas_with_costs ()
450428 electricity_sink = Sinks .electricity_feed_in (p_el )
451429
452- flow_system .add_elements (* Buses .all_standard ())
430+ flow_system .add_elements (* Buses .defaults ())
453431 flow_system .add_elements (costs , heat_load , gas_source , electricity_sink )
454432
455433 return flow_system
@@ -465,15 +443,17 @@ def flow_system_complex() -> fx.FlowSystem:
465443 flow_system = fx .FlowSystem (pd .date_range ('2020-01-01' , periods = 9 , freq = 'h' , name = 'time' ))
466444
467445 # Define the components and flow_system
468- costs = Effects .costs_standard ()
469- co2 = Effects .co2_simple ()
470- pe = Effects .primary_energy_limited ()
446+ costs = Effects .costs ()
447+ co2 = Effects .co2 ()
448+ co2 .specific_share_to_other_effects_operation = {'costs' : 0.2 }
449+ pe = Effects .primary_energy ()
450+ pe .maximum_total = 3.5e3
471451
472452 heat_load = Sinks .heat_load (thermal_load )
473- gas_tariff = Sources .gas_with_co2 ()
453+ gas_tariff = Sources .gas_with_costs_and_co2 ()
474454 electricity_feed_in = Sinks .electricity_feed_in (electrical_load )
475455
476- flow_system .add_elements (* Buses .all_standard ())
456+ flow_system .add_elements (* Buses .defaults ())
477457 flow_system .add_elements (costs , co2 , pe , heat_load , gas_tariff , electricity_feed_in )
478458
479459 boiler = Converters .Boilers .complex ()
@@ -544,8 +524,12 @@ def flow_system_long():
544524 )
545525
546526 # Add buses and effects using library
547- flow_system .add_elements (* Buses .all_with_coal ())
548- flow_system .add_elements (Effects .costs_standard (), Effects .co2_basic (), Effects .primary_energy_basic ())
527+ flow_system .add_elements (* Buses .defaults (), Buses .coal ())
528+
529+ flow_system .add_elements (Effects .costs (), Effects .co2 (), Effects .primary_energy ())
530+
531+ gas = Sources .gas_with_costs ()
532+ gas .source .effects_per_flow_hour = {'costs' : gas_price , 'CO2' : 0.3 }
549533
550534 # Add loads and sources - mix of library and special elements
551535 flow_system .add_elements (
@@ -560,8 +544,6 @@ def flow_system_long():
560544 'Kohletarif' ,
561545 source = fx .Flow ('Q_Kohle' , bus = 'Kohle' , size = 1000 , effects_per_flow_hour = {'costs' : 4.6 , 'CO2' : 0.3 }),
562546 ),
563- # Gas tariff with variable pricing using library
564- Sources .gas_with_price (gas_price ),
565547 # Special electricity feed-in with time series
566548 fx .Sink ('Einspeisung' , sink = fx .Flow ('P_el' , bus = 'Strom' , size = 1000 , effects_per_flow_hour = p_feed_in )),
567549 # Special electricity purchase tariff
@@ -633,12 +615,12 @@ def basic_flow_system_linopy(timesteps_linopy) -> fx.FlowSystem:
633615 thermal_load = LoadProfiles .random_thermal (10 )
634616 p_el = LoadProfiles .random_electrical (10 )
635617
636- costs = Effects .costs_only ()
618+ costs = Effects .costs ()
637619 heat_load = Sinks .heat_load (thermal_load )
638- gas_source = Sources .gas_simple ()
620+ gas_source = Sources .gas_with_costs ()
639621 electricity_sink = Sinks .electricity_feed_in (p_el )
640622
641- flow_system .add_elements (* Buses .all_standard ())
623+ flow_system .add_elements (* Buses .defaults ())
642624 flow_system .add_elements (costs , heat_load , gas_source , electricity_sink )
643625
644626 return flow_system
0 commit comments