diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/component/genericbranch.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/component/genericbranch.hpp index 00a158916..095629523 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/component/genericbranch.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/component/genericbranch.hpp @@ -19,7 +19,7 @@ paramaters should be given as r1, x1, .... -----| |-----------y_series------- - | | | | + | | | | | | y_shunt y_shunt | | | | | | | | @@ -37,7 +37,7 @@ class GenericBranch final : public Branch { static constexpr char const* name = "genericbranch"; explicit GenericBranch(GenericBranchInput const& genericbranch_input, double u1_rated, double u2_rated) - : Branch{genericbranch_input}, + : Branch{genericbranch_input}, u1_{genericbranch_input.u1}, u2_{genericbranch_input.u2}, sn_{genericbranch_input.sn}, @@ -48,7 +48,7 @@ class GenericBranch final : public Branch { r0_{genericbranch_input.r0}, x0_{genericbranch_input.x0}, b0_{genericbranch_input.b0}, - g0_{genericbranch_input.g0}, + g0_{genericbranch_input.g0}, shift_{fmod(genericbranch_input.shift, 2 * M_PI)}, nominal_ratio_{u1_rated / u2_rated}, base_i_from_{base_power_3p / u1_rated / sqrt3}, @@ -61,9 +61,15 @@ class GenericBranch final : public Branch { double const base_y_to = base_i_to_ * base_i_to_ / base_power_1p; y1_series_ = 1.0 / (r1_ + 1.0i*x1_) / base_y_to; y1_shunt_ = (g1_ + 1.0i*b1_) / base_y_to; + + r0_ = is_nan(r0_) ? 0 : r0_; + x0_ = is_nan(x0_) ? 0 : x0_; + b0_ = is_nan(b0_) ? 0 : b0_; + g0_ = is_nan(g0_) ? 0 : g0_; + y0_series_ = 1.0 / (r0_ + 1.0i * x0_) / base_y_to; - y1_shunt_ = (g0_ + 1.0i*b0_) / base_y_to; - ratio_ = (u1_ / u2_) / nominal_ratio_; + y0_shunt_ = (g0_ + 1.0i*b0_) / base_y_to; + ratio_ = (u1_ / u2_) / nominal_ratio_; } // override getter @@ -95,7 +101,7 @@ class GenericBranch final : public Branch { DoubleComplex y1_shunt_; DoubleComplex y0_series_; DoubleComplex y0_shunt_; - + BranchCalcParam sym_calc_param() const override { return calc_param_y_sym(y1_series_, y1_shunt_, ratio_*std::exp(1.0i * shift_)); }