@@ -193,6 +193,23 @@ def test_Network_from_dict(self):
193193 )
194194 assert imported_nwk .checked , msg
195195
196+ def test_Network_import_with_component_parameter_as_variable (self ):
197+ """Test if component variables are retained after import."""
198+ pipe = Pipe ("pipe" )
199+ c1 = Connection (self .source , 'out1' , pipe , 'in1' , label = "c1" )
200+ c2 = Connection (pipe , 'out1' , self .sink , 'in1' , label = "c2" )
201+ self .nw .add_conns (c1 , c2 )
202+ c1 .set_attr (fluid = {"H2O" : 1 }, m = 1 , T = 25 , p = 2 )
203+ c2 .set_attr (p = 1.9 )
204+ pipe .set_attr (Q = 0 , D = "var" , ks = 0.00005 , L = 100 )
205+ self .nw .solve ("design" )
206+ self .nw .assert_convergence ()
207+ serialization = self .nw .export ()
208+ imported_nwk = Network .from_dict (serialization )
209+ imported_nwk .solve ("design" )
210+ imported_nwk .assert_convergence ()
211+ assert approx (pipe .D .val ) == imported_nwk .get_comp ("pipe" ).D .val
212+
196213 def test_Network_reader_unknown_component_class (self , tmp_path ):
197214 """Test notsupported component."""
198215 tmp_path = f"{ tmp_path } .json"
0 commit comments