问题描述
这个问题已经在另一个平台上问过了,但我还没有得到答案。
https://discourse.julialang.org/t/generalizing-the-inputs-of-the-nlsolve-function-in-julia/
在使用 Julia 中的 SymPy 进行大量过程后,我生成了一个非线性方程组。我的系统被分配在一个矩阵 NxS 中。像这样(NN = 2,S = 2)。
我想调整系统以使用 NLsolve 包。我为 NN=1 和 S =1 的情况做了一些蠢事。 system_equations2 函数给我非线性系统,如图
using SymPy
using Plots
using NLsolve
res = system_equations2()
为了模拟输出,我这样做:
NN = 1
S = 1
p= [Sym("p$i$j") for i in 1:NN,j in 1:S]
res = [ Eq( -331.330122303069*p[i,j]^(1.0) + p[i,j]^(2.81818181818182) - 1895.10478893046/(p[i,j]^(-1.0))^(2.0),0 ) for i in 1:NN,j in 1:S]
resf = convert( Function,lhs( res[1,1] ) )
plot(resf,10731)
现在
resf = convert( Function,1] ) )
# This for the argument in the nlsolve function
function resf2(p)
p = Tuple(p)[1]
r = resf(p)
return r
end
现在,我找到了零
function K(F,p)
F[1] = resf2(p[1])
end
nlsolve(K,[7500.8])
我想将此价格推广到任何 NN 和任何 S。我相信有一种更简单的方法可以做到这一点。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)