@@ -60,29 +60,19 @@ void wprobe::saveOperatingPoints (void) {
6060 nr_double_t Vi = imag (getV (NODE_1 ) - getV (NODE_2 ));
6161 // operating points as for the vprobe
6262 setOperatingPoint (" Vr" , Vr);
63- setOperatingPoint (" Vi" , Vi); // This section works just like a voltmeter
64- }
65-
66- // For specific information regarding The Power triangle and Power factor:
67- // https://en.wikipedia.org/wiki/Power_factor#Definition_and_calculation
63+ setOperatingPoint (" Vi" , Vi);
6864
69- void wprobe::calcOperatingPoints (void ) {
70- // Reading the current and voltage values to calculate power values
65+ // read current and voltage values to calculate power values
7166 nr_complex_t Vw = getV (NODE_1 ) - getV (NODE_2 );
7267 nr_complex_t Iw = getJ (VSRC_1 );
7368 nr_complex_t Sw = Vw * conj (Iw);
74- nr_double_t VAr = real (Sw);
75- nr_double_t VAi = imag (Sw);
76- setOperatingPoint (" VAr" , VAr);
77- setOperatingPoint (" VAi" , VAi);
78-
79- nr_double_t P = VAr;
69+ // save P and Q instead of just S since operating points cannot hold complex values
70+ nr_double_t P = real (Sw);
71+ nr_double_t Q = imag (Sw);
8072 setOperatingPoint (" P" , P);
81-
82- nr_double_t Q = VAi;
8373 setOperatingPoint (" Q" , Q);
8474// Power Factor calculation
85- setOperatingPoint (" PF" , P/std::sqrt (P*P+VAi*VAi ));
75+ setOperatingPoint (" PF" , P/std::sqrt (P*P+Q*Q ));
8676}
8777
8878void wprobe::initTR (void ) {
0 commit comments