两个复方程的numpy非线性根寻找

时间:2022-01-20 21:26:12

Why it does not calculate properly? Correct solution is c=25.672 and b2=10.24. Here solver returns the input values. Thanks for help!

为什么不能正确计算?正确的解是c = 25.672,b2 = 10.24。这里求解器返回输入值。感谢帮助!

from numpy import *
from scipy.optimize import *

#UNITS:
psi = 6895.
ft=0.3048
inch=0.0254
psisqin=psi*sqrt(inch)

#DATA:
K_Ict=1500.*psisqin
K_Icb=1700.*psisqin
sigma_2=6700.*psi
sigma_1=6000.*psi
sigma_3=7200.*psi
hp=105.*ft
P = 6500*psi

def f(p):
    b2,c= p
    F1 =  sqrt(pi*c)*(K_Icb-K_Ict)/2 - ( (sigma_2-sigma_1)*sqrt(c**2-b2**2) - (sigma_3-sigma_1)*sqrt(c**2-(hp-b2)**2) )
    F2 =  sqrt(pi)*(K_Icb+K_Ict)/(2*sqrt(c)) - ( (sigma_2-sigma_1)*arcsin(b2/c) + (sigma_3-sigma_1)*arcsin((hp-b2)/c) - (sigma_2+sigma_3-2*P)*pi/2 )
    return (F1,F2)

b2, c =  fsolve(f,(16.002,30))
print b2, c

1 个解决方案

#1


0  

Not entirely sure why but I think it's because you are leaving one of the roots out of the range, so it just returns the boundaries you gave. The true reason depends on whatever method is using to find the roots. The documentation states:

不完全确定为什么,但我认为这是因为你离开了一个超出范围的根,所以它只是返回你给出的边界。真正的原因取决于用于查找根的任何方法。文件说明:

fsolve is a wrapper around MINPACK’s hybrd and hybrj algorithms.

fsolve是MINPACK的hybrd和hybrj算法的包装器。

These algorithms are a bit beyond my expertise but you'll find documentation about them easily. This link is one example.

这些算法有点超出我的专业知识,但您可以轻松找到有关它们的文档。这个链接就是一个例子。

In any case if you change the boundaries to contain both your roots you should obtain the correct results (within a tolerance):

在任何情况下,如果您更改边界以包含两个根,则应获得正确的结果(在公差范围内):

from numpy import *
from scipy.optimize import *

#UNITS:
psi = 6895.
ft=0.3048
inch=0.0254
psisqin=psi*sqrt(inch)

#DATA:
K_Ict=1500*psisqin
K_Icb=1700*psisqin
sigma_2=6700*psi
sigma_1=6000*psi
sigma_3=7200*psi
hp=105.*ft
P = 6500*psi

def f(p):
    b2,c= p
    F1 =  sqrt(pi*c)*(K_Icb-K_Ict)/2
    F1 =  sqrt(pi*c)*(K_Icb-K_Ict)/2 - ( (sigma_2-sigma_1)*sqrt(c**2-b2**2) - (sigma_3-sigma_1)*sqrt(c**2-(hp-b2)**2) )
    F2 =  sqrt(pi)*(K_Icb+K_Ict)/(2*sqrt(c)) - ( (sigma_2-sigma_1)*arcsin(b2/c) + (sigma_3-sigma_1)*arcsin((hp-b2)/c) - (sigma_2+sigma_3-2*P)*pi/2 )
    return (F1,F2)

b2, c =  fsolve(f,(9.002,30))
print(b2, c)

This results in:

这导致:

10.2613616029 25.63857432

#1


0  

Not entirely sure why but I think it's because you are leaving one of the roots out of the range, so it just returns the boundaries you gave. The true reason depends on whatever method is using to find the roots. The documentation states:

不完全确定为什么,但我认为这是因为你离开了一个超出范围的根,所以它只是返回你给出的边界。真正的原因取决于用于查找根的任何方法。文件说明:

fsolve is a wrapper around MINPACK’s hybrd and hybrj algorithms.

fsolve是MINPACK的hybrd和hybrj算法的包装器。

These algorithms are a bit beyond my expertise but you'll find documentation about them easily. This link is one example.

这些算法有点超出我的专业知识,但您可以轻松找到有关它们的文档。这个链接就是一个例子。

In any case if you change the boundaries to contain both your roots you should obtain the correct results (within a tolerance):

在任何情况下,如果您更改边界以包含两个根,则应获得正确的结果(在公差范围内):

from numpy import *
from scipy.optimize import *

#UNITS:
psi = 6895.
ft=0.3048
inch=0.0254
psisqin=psi*sqrt(inch)

#DATA:
K_Ict=1500*psisqin
K_Icb=1700*psisqin
sigma_2=6700*psi
sigma_1=6000*psi
sigma_3=7200*psi
hp=105.*ft
P = 6500*psi

def f(p):
    b2,c= p
    F1 =  sqrt(pi*c)*(K_Icb-K_Ict)/2
    F1 =  sqrt(pi*c)*(K_Icb-K_Ict)/2 - ( (sigma_2-sigma_1)*sqrt(c**2-b2**2) - (sigma_3-sigma_1)*sqrt(c**2-(hp-b2)**2) )
    F2 =  sqrt(pi)*(K_Icb+K_Ict)/(2*sqrt(c)) - ( (sigma_2-sigma_1)*arcsin(b2/c) + (sigma_3-sigma_1)*arcsin((hp-b2)/c) - (sigma_2+sigma_3-2*P)*pi/2 )
    return (F1,F2)

b2, c =  fsolve(f,(9.002,30))
print(b2, c)

This results in:

这导致:

10.2613616029 25.63857432