@@ -47,7 +47,7 @@ class Source : public Appliance {
4747 return SourceCalcParam{.y1 = y1_ref, .y0 = y0_ref};
4848 }
4949
50- // setter
50+ // setter for u_ref
5151 bool set_u_ref (double new_u_ref, double new_u_ref_angle) {
5252 bool changed = false ;
5353 if (!is_nan (new_u_ref)) {
@@ -87,10 +87,13 @@ class Source : public Appliance {
8787 UpdateChange update (SourceUpdate const & update_data) {
8888 assert (update_data.id == this ->id () || is_nan (update_data.id ));
8989 bool const topo_changed = set_status (update_data.status );
90- bool const param_changed = set_u_ref (update_data.u_ref , update_data.u_ref_angle );
90+ bool const u_ref_changed = set_u_ref (update_data.u_ref , update_data.u_ref_angle );
91+ bool const param_changed_impedance =
92+ set_sk_rx_ratio_z01_ratio (update_data.sk , update_data.rx_ratio , update_data.z01_ratio );
9193 // change source connection will change both topo and param
9294 // change u ref will change param
93- return {.topo = topo_changed, .param = param_changed || topo_changed};
95+ // change sk/rx_ratio/z01_ratio will change param
96+ return {.topo = topo_changed, .param = u_ref_changed || param_changed_impedance || topo_changed};
9497 }
9598
9699 SourceUpdate inverse (SourceUpdate update_data) const {
@@ -99,6 +102,9 @@ class Source : public Appliance {
99102 set_if_not_nan (update_data.status , status_to_int (this ->status ()));
100103 set_if_not_nan (update_data.u_ref , u_ref_);
101104 set_if_not_nan (update_data.u_ref_angle , u_ref_angle_);
105+ set_if_not_nan (update_data.sk , sk_);
106+ set_if_not_nan (update_data.rx_ratio , rx_ratio_);
107+ set_if_not_nan (update_data.z01_ratio , z01_ratio_);
102108
103109 return update_data;
104110 }
@@ -113,6 +119,23 @@ class Source : public Appliance {
113119 double rx_ratio_;
114120 double z01_ratio_;
115121
122+ bool set_sk_rx_ratio_z01_ratio (double new_sk, double new_rx_ratio, double new_z01_ratio) {
123+ bool changed = false ;
124+ if (!is_nan (new_sk)) {
125+ sk_ = new_sk;
126+ changed = true ;
127+ }
128+ if (!is_nan (new_rx_ratio)) {
129+ rx_ratio_ = new_rx_ratio;
130+ changed = true ;
131+ }
132+ if (!is_nan (new_z01_ratio)) {
133+ z01_ratio_ = new_z01_ratio;
134+ changed = true ;
135+ }
136+ return changed;
137+ }
138+
116139 double injection_direction () const final { return 1.0 ; }
117140};
118141
0 commit comments