I'm a beginning programmer who's currently working on translating a Julia script to Python. It concerns the following piece of Julia code:
function p(temp, irr)
p_max = P_1 *
exp(T_AP / T_P1 - T_AP / (temp + 273.15)) /
(1 + exp(T_APL / (temp + 273.15) - T_APL / T_PL) + exp(T_APH / T_PH - T_APH / (temp + 273.15)))
β_func(x) = p_max -
(α * I_sat / log(1 + α / x)) * (α / (α + x)) * (x / (α + x))^(x / α)
β = find_zero(β_func, (0, 0.1), Bisection())
p_s = α * I_sat / log(1 + α / β)
return p_s * (1 - exp(-α * irr / p_s)) * exp(-β * irr / p_s)
end
As far as I understand, the code finds an x value for which the difference between p_max and β_func is zero, and uses this value in the equation for p_s.
I've been trying to translate this code to Python for a while now, without any success. There are several examples of applying Newton's method in Python (e.g., https://personal.math.ubc.ca/~pwalls/math-python/roots-optimization/newton/), but these examples use 1 equation instead of 2.
Any help or insights are very welcome. Thanks!