@@ -85,19 +85,17 @@ def find_solution(
8585 simulation_unit_id = self ._shaft_id ,
8686 value = max (speed_configurations ),
8787 )
88- all_configurations : dict = { self . _shaft_id : shaft_config }
88+ solution = Solution ( success = True , configuration = [ shaft_config ])
8989
9090 current_inlet = inlet_stream
91- overall_success = True
9291
9392 for segment , target in zip (self ._segments , pressure_targets ):
9493 segment .runner .apply_configuration (shaft_config )
9594
9695 segment .anti_surge_strategy .reset ()
9796 anti_surge_solution = segment .anti_surge_strategy .apply (inlet_stream = current_inlet )
9897 segment .runner .apply_configurations (anti_surge_solution .configuration )
99- for config in anti_surge_solution .configuration :
100- all_configurations [config .simulation_unit_id ] = config
98+ solution = solution .combine (anti_surge_solution )
10199
102100 outlet = segment .runner .run (inlet_stream = current_inlet )
103101
@@ -106,18 +104,12 @@ def find_solution(
106104 target_pressure = target ,
107105 inlet_stream = current_inlet ,
108106 )
109- for config in pressure_control_solution .configuration :
110- all_configurations [config .simulation_unit_id ] = config
107+ solution = solution .combine (pressure_control_solution )
111108 segment .runner .apply_configurations (pressure_control_solution .configuration )
112109 outlet = segment .runner .run (inlet_stream = current_inlet )
113- if not pressure_control_solution .success :
114- overall_success = False
115110 elif outlet .pressure_bara < target :
116- overall_success = False
111+ solution = Solution ( success = False , configuration = solution . configuration )
117112
118113 current_inlet = outlet
119114
120- return Solution (
121- success = overall_success ,
122- configuration = list (all_configurations .values ()),
123- )
115+ return solution
0 commit comments