Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alg_TWM-PWRFFT wrapper issue for too ideal data #19

Open
KaeroDot opened this issue Feb 17, 2023 · 0 comments
Open

alg_TWM-PWRFFT wrapper issue for too ideal data #19

KaeroDot opened this issue Feb 17, 2023 · 0 comments

Comments

@KaeroDot
Copy link
Contributor

KaeroDot commented Feb 17, 2023

alg_wrapper.m in alg_TWM-PWRFFT got issue that for ideal data (simulated, e.g. during testing), it can happen the S is smaller than P because of the numerical rounding. And if P is greater than S, it will lead to complex Q and this will create error in a later code.
Therefore some comparison with numerical precision is needed.
Could be solved by this code - replacing lines 211-212:
Q = (S^2 - P^2)^0.5sign(Q_bud);
u_Q = ((S^2
u_S^2 + P^2*u_P^2)/(S^2 - P^2))^0.5; % ###note: ignoring corelations, may be improved

by code:
SmP = S^2 - P^2;
if abs(SmP) < 2eps
SmP = 0;
end
% If abs(SmP) is greater than 2
eps, and is negative, it will lead to
% complex Q and will create error later.
Q = (SmP)^0.5sign(Q_bud);
u_Q = ((S^2
u_S^2 + P^2*u_P^2)/(SmP))^0.5; % ###note: ignoring corelations, may be improved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant