简体   繁体   English

如何使用broyden1算法计算指数值

[英]how to use broyden1 algorithm to calculate an exponential value

I have to find the temperature in the equation: 我必须在方程式中找到温度:

u = 1.2*e^(-.025*T)
u = viscosity in N*s/m^2

T = degree C

using 运用

scipy.optimize.broyden1()

how would you use that to find the T when u=.001? 当u = .001时,您将如何用它来找到T?

To use the broyden1 function, just give it the function that you want the root to be found and also an initial value. 要使用broyden1函数,只需为其提供您希望找到根的函数以及一个初始值即可。 If you are only interested in solving for u=.001, you can just define a function that take T as an input. 如果只对求解u = .001感兴趣,则可以定义一个以T作为输入的函数。 If you might want to change the value of u, partial might be a handy tool. 如果您想更改u的值,partial可能是一个方便的工具。

import scipy.optimize
import numpy as np
from functools import partial

def findtemp(T, u):
    return u - 1.2 * np.exp(-.025*T)

sol = scipy.optimize.broyden1(partial(findtemp, u=.001), 0)
print(sol)

gives me a value of 283.4828690696808 which is close to the theoretical value. 给我一个283.4828690696808的值,它接近理论值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM