@@ -410,8 +410,15 @@ def _create_pgm_input_lines(self):
410410 in_service = self ._get_pp_attr ("line" , "in_service" , expected_type = "bool" , default = True )
411411 length_km = self ._get_pp_attr ("line" , "length_km" , expected_type = "f8" )
412412 parallel = self ._get_pp_attr ("line" , "parallel" , expected_type = "u4" , default = 1 )
413- c_nf_per_km = self ._get_pp_attr ("line" , "c_nf_per_km" , expected_type = "f8" )
414- c0_nf_per_km = self ._get_pp_attr ("line" , "c0_nf_per_km" , expected_type = "f8" , default = np .nan )
413+ c_nf_per_km = self ._get_pp_attr ("line" , "c_nf_per_km" , expected_type = "f8" , default = 0 )
414+ c0_nf_per_km = self ._get_pp_attr ("line" , "c0_nf_per_km" , expected_type = "f8" , default = 0 )
415+ g_us_per_km = self ._get_pp_attr ("line" , "g_us_per_km" , expected_type = "f8" , default = 0 )
416+ g0_us_per_km = self ._get_pp_attr ("line" , "g0_us_per_km" , expected_type = "f8" , default = 0 )
417+ # broadcast to array length
418+ c_nf_per_km = c_nf_per_km * np .ones (shape = len (pp_lines ), dtype = "f8" )
419+ c0_nf_per_km = c0_nf_per_km * np .ones (shape = len (pp_lines ), dtype = "f8" )
420+ g_us_per_km = g_us_per_km * np .ones (shape = len (pp_lines ), dtype = "f8" )
421+ g0_us_per_km = g0_us_per_km * np .ones (shape = len (pp_lines ), dtype = "f8" )
415422 multiplier = length_km / parallel
416423
417424 pgm_lines = initialize_array (
@@ -427,11 +434,11 @@ def _create_pgm_input_lines(self):
427434 pgm_lines ["c1" ] = c_nf_per_km * length_km * parallel * 1e-9
428435 # The formula for tan1 = R_1 / Xc_1 = (g * 1e-6) / (2 * pi * f * c * 1e-9) = g / (2 * pi * f * c * 1e-3)
429436 pgm_lines ["tan1" ] = np .divide (
430- self . _get_pp_attr ( "line" , " g_us_per_km" , expected_type = "f8" , default = 0 ) ,
437+ g_us_per_km ,
431438 c_nf_per_km * (2 * np .pi * self .system_frequency * 1e-3 ),
432- where = c_nf_per_km != 0.0 ,
439+ where = np . logical_not ( np . isclose ( c_nf_per_km , 0.0 )) ,
433440 )
434- pgm_lines ["tan1" ][np .equal (c_nf_per_km , 0.0 )] = 0.0
441+ pgm_lines ["tan1" ][np .isclose (c_nf_per_km , 0.0 )] = 0.0
435442 pgm_lines ["i_n" ] = (
436443 (self ._get_pp_attr ("line" , "max_i_ka" , expected_type = "f8" , default = np .nan ) * 1e3 )
437444 * self ._get_pp_attr ("line" , "df" , expected_type = "f8" , default = 1 )
@@ -441,11 +448,11 @@ def _create_pgm_input_lines(self):
441448 pgm_lines ["x0" ] = self ._get_pp_attr ("line" , "x0_ohm_per_km" , expected_type = "f8" , default = np .nan ) * multiplier
442449 pgm_lines ["c0" ] = c0_nf_per_km * length_km * parallel * 1e-9
443450 pgm_lines ["tan0" ] = np .divide (
444- self . _get_pp_attr ( "line" , " g0_us_per_km" , expected_type = "f8" , default = 0 ) ,
451+ g0_us_per_km ,
445452 c0_nf_per_km * (2 * np .pi * self .system_frequency * 1e-3 ),
446- where = c0_nf_per_km != 0.0 ,
453+ where = np . logical_not ( np . isclose ( c0_nf_per_km , 0.0 )) ,
447454 )
448- pgm_lines ["tan0" ][np .equal (c0_nf_per_km , 0.0 )] = 0.0
455+ pgm_lines ["tan0" ][np .isclose (c0_nf_per_km , 0.0 )] = 0.0
449456 assert ComponentType .line not in self .pgm_input_data
450457 self .pgm_input_data [ComponentType .line ] = pgm_lines
451458
0 commit comments