Solver stopped prematurely. fsolve stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 2.000000e+02.
I want to solve a system of equations containing two non-linear equations, one of which is Psh==Pse,the other is Qs==0, but solving it with the fsolve function doesn’t achieve the given constraints, how can I solve this problem?
V_s=10*1e3/sqrt(3);
n_t=25*sqrt(3);
V_r=400/sqrt(3);
theta_r=pi/12;
Srate=100*1e3/3;
Zbase=(V_r)^2/Srate;
X_r=0.4*Zbase;
X_t=400^2/(150*1e3)*4/100;
rho=0:2*pi/24:2*pi;
V_se=0.2*V_r;
Z_r=j*X_r;
for m=1:25
fun=@(x)myfun(x,rho(m));
x0=[0 0];
[x,fval,exitflag(m),~]=fsolve(fun,x0);
gamma(m)=x(1);
I_sh(m)=x(2);
I_r(m)=1/(Z_r+j*X_t)*(sqrt(3)*V_s*exp(j*pi/6)/n_t+V_se*exp(j*rho(m))-V_r*exp(j*theta_r)-j*X_t*I_sh(m)*exp(j*gamma(m)));
V_c1(m)=sqrt(3)*V_s*exp(j*pi/6)/n_t-j*X_t*(I_sh(m)*exp(j*gamma(m))+I_r(m));
Psh(m)=real(V_c1(m)*conj(I_sh(m)*exp(j*gamma(m))));
Pse(m)=real(V_se*exp(j*rho(m))*conj(I_r(m)));
Pr(m)=real(V_r*exp(j*theta_r)*conj(I_r(m)));
Qr(m)=imag(V_r*exp(j*theta_r)*conj(I_r(m)));
Sr(m)=sqrt(Pr(m)^2+Qr(m)^2);
Ps(m)=real(sqrt(3)*V_s*exp(j*pi/6)/n_t*conj(I_r(m)+I_sh(m)*exp(j*gamma(m))));
Qs(m)=imag(sqrt(3)*V_s*exp(j*pi/6)/n_t*conj(I_r(m)+I_sh(m)*exp(j*gamma(m))));
Ss(m)=sqrt(Ps(m)^2+Qs(m)^2);
end
plot( Ps/Srate,Qs/Srate,LineWidth=2,color='[0.9290 0.6940 0.1250]’)
function y=myfun(x,rho)
V_s=10*1e3/sqrt(3);
n_t=25*sqrt(3);
V_r=400/sqrt(3);
theta_r=pi/12;
Srate=100*1e3/3;
Zbase=(V_r)^2/Srate;
X_r=0.4*Zbase;
X_t=400^2/(150*1e3)*4/100;
V_se=0.2*V_r;
Z_r=j*X_r;
%%%%%%%%%%%%%%%%Two constraints,Psh==Pse,Qs==0
gamma=x(1);
I_sh=x(2);
I_r=1/(Z_r+j*X_t)*(sqrt(3)*V_s*exp(j*pi/6)/n_t+V_se*exp(j*rho)-V_r*exp(j*theta_r)-j*X_t*I_sh*exp(j*gamma));
V_c1=sqrt(3)*V_s*exp(j*pi/6)/n_t-j*X_t*(I_sh*exp(j*gamma)+I_r);
Psh=real(V_c1*conj(I_sh*exp(j*gamma)));
Pse=real(V_se*exp(j*rho)*conj(I_r));
Qs=imag(sqrt(3)*V_s*exp(j*pi/6)/n_t*conj(I_r+I_sh*exp(j*gamma)));
y=[Psh-Pse; Qs];
endI want to solve a system of equations containing two non-linear equations, one of which is Psh==Pse,the other is Qs==0, but solving it with the fsolve function doesn’t achieve the given constraints, how can I solve this problem?
V_s=10*1e3/sqrt(3);
n_t=25*sqrt(3);
V_r=400/sqrt(3);
theta_r=pi/12;
Srate=100*1e3/3;
Zbase=(V_r)^2/Srate;
X_r=0.4*Zbase;
X_t=400^2/(150*1e3)*4/100;
rho=0:2*pi/24:2*pi;
V_se=0.2*V_r;
Z_r=j*X_r;
for m=1:25
fun=@(x)myfun(x,rho(m));
x0=[0 0];
[x,fval,exitflag(m),~]=fsolve(fun,x0);
gamma(m)=x(1);
I_sh(m)=x(2);
I_r(m)=1/(Z_r+j*X_t)*(sqrt(3)*V_s*exp(j*pi/6)/n_t+V_se*exp(j*rho(m))-V_r*exp(j*theta_r)-j*X_t*I_sh(m)*exp(j*gamma(m)));
V_c1(m)=sqrt(3)*V_s*exp(j*pi/6)/n_t-j*X_t*(I_sh(m)*exp(j*gamma(m))+I_r(m));
Psh(m)=real(V_c1(m)*conj(I_sh(m)*exp(j*gamma(m))));
Pse(m)=real(V_se*exp(j*rho(m))*conj(I_r(m)));
Pr(m)=real(V_r*exp(j*theta_r)*conj(I_r(m)));
Qr(m)=imag(V_r*exp(j*theta_r)*conj(I_r(m)));
Sr(m)=sqrt(Pr(m)^2+Qr(m)^2);
Ps(m)=real(sqrt(3)*V_s*exp(j*pi/6)/n_t*conj(I_r(m)+I_sh(m)*exp(j*gamma(m))));
Qs(m)=imag(sqrt(3)*V_s*exp(j*pi/6)/n_t*conj(I_r(m)+I_sh(m)*exp(j*gamma(m))));
Ss(m)=sqrt(Ps(m)^2+Qs(m)^2);
end
plot( Ps/Srate,Qs/Srate,LineWidth=2,color='[0.9290 0.6940 0.1250]’)
function y=myfun(x,rho)
V_s=10*1e3/sqrt(3);
n_t=25*sqrt(3);
V_r=400/sqrt(3);
theta_r=pi/12;
Srate=100*1e3/3;
Zbase=(V_r)^2/Srate;
X_r=0.4*Zbase;
X_t=400^2/(150*1e3)*4/100;
V_se=0.2*V_r;
Z_r=j*X_r;
%%%%%%%%%%%%%%%%Two constraints,Psh==Pse,Qs==0
gamma=x(1);
I_sh=x(2);
I_r=1/(Z_r+j*X_t)*(sqrt(3)*V_s*exp(j*pi/6)/n_t+V_se*exp(j*rho)-V_r*exp(j*theta_r)-j*X_t*I_sh*exp(j*gamma));
V_c1=sqrt(3)*V_s*exp(j*pi/6)/n_t-j*X_t*(I_sh*exp(j*gamma)+I_r);
Psh=real(V_c1*conj(I_sh*exp(j*gamma)));
Pse=real(V_se*exp(j*rho)*conj(I_r));
Qs=imag(sqrt(3)*V_s*exp(j*pi/6)/n_t*conj(I_r+I_sh*exp(j*gamma)));
y=[Psh-Pse; Qs];
end I want to solve a system of equations containing two non-linear equations, one of which is Psh==Pse,the other is Qs==0, but solving it with the fsolve function doesn’t achieve the given constraints, how can I solve this problem?
V_s=10*1e3/sqrt(3);
n_t=25*sqrt(3);
V_r=400/sqrt(3);
theta_r=pi/12;
Srate=100*1e3/3;
Zbase=(V_r)^2/Srate;
X_r=0.4*Zbase;
X_t=400^2/(150*1e3)*4/100;
rho=0:2*pi/24:2*pi;
V_se=0.2*V_r;
Z_r=j*X_r;
for m=1:25
fun=@(x)myfun(x,rho(m));
x0=[0 0];
[x,fval,exitflag(m),~]=fsolve(fun,x0);
gamma(m)=x(1);
I_sh(m)=x(2);
I_r(m)=1/(Z_r+j*X_t)*(sqrt(3)*V_s*exp(j*pi/6)/n_t+V_se*exp(j*rho(m))-V_r*exp(j*theta_r)-j*X_t*I_sh(m)*exp(j*gamma(m)));
V_c1(m)=sqrt(3)*V_s*exp(j*pi/6)/n_t-j*X_t*(I_sh(m)*exp(j*gamma(m))+I_r(m));
Psh(m)=real(V_c1(m)*conj(I_sh(m)*exp(j*gamma(m))));
Pse(m)=real(V_se*exp(j*rho(m))*conj(I_r(m)));
Pr(m)=real(V_r*exp(j*theta_r)*conj(I_r(m)));
Qr(m)=imag(V_r*exp(j*theta_r)*conj(I_r(m)));
Sr(m)=sqrt(Pr(m)^2+Qr(m)^2);
Ps(m)=real(sqrt(3)*V_s*exp(j*pi/6)/n_t*conj(I_r(m)+I_sh(m)*exp(j*gamma(m))));
Qs(m)=imag(sqrt(3)*V_s*exp(j*pi/6)/n_t*conj(I_r(m)+I_sh(m)*exp(j*gamma(m))));
Ss(m)=sqrt(Ps(m)^2+Qs(m)^2);
end
plot( Ps/Srate,Qs/Srate,LineWidth=2,color='[0.9290 0.6940 0.1250]’)
function y=myfun(x,rho)
V_s=10*1e3/sqrt(3);
n_t=25*sqrt(3);
V_r=400/sqrt(3);
theta_r=pi/12;
Srate=100*1e3/3;
Zbase=(V_r)^2/Srate;
X_r=0.4*Zbase;
X_t=400^2/(150*1e3)*4/100;
V_se=0.2*V_r;
Z_r=j*X_r;
%%%%%%%%%%%%%%%%Two constraints,Psh==Pse,Qs==0
gamma=x(1);
I_sh=x(2);
I_r=1/(Z_r+j*X_t)*(sqrt(3)*V_s*exp(j*pi/6)/n_t+V_se*exp(j*rho)-V_r*exp(j*theta_r)-j*X_t*I_sh*exp(j*gamma));
V_c1=sqrt(3)*V_s*exp(j*pi/6)/n_t-j*X_t*(I_sh*exp(j*gamma)+I_r);
Psh=real(V_c1*conj(I_sh*exp(j*gamma)));
Pse=real(V_se*exp(j*rho)*conj(I_r));
Qs=imag(sqrt(3)*V_s*exp(j*pi/6)/n_t*conj(I_r+I_sh*exp(j*gamma)));
y=[Psh-Pse; Qs];
end fsolve, solving systems of nonlinear equations MATLAB Answers — New Questions