Partial derivative calculation for circular or iterative functions

82 Views Asked by At

I have a question of partial derivatives for implicit functions. I have three equations:

$\rho_k=\rho_l\frac{\lambda_l}{H_l}+\rho_g\frac{(1-\lambda_l)}{1-H_l}$
$Re=\frac{\rho_kv_m\phi}{\mu}$
$H_l=f(Re,\lambda_l)$

$\phi$ is a constant and $f()$ is a complex function. $\rho_l,\rho_g,\lambda_l,v_m,\mu$ are all functions of $P$ (and $Q$). I solve these iteratively for $H_l$ given $P$ and $Q$. Now I need $\frac{\partial H_l}{\partial P}$. I do this by differentiating all three equations:

$\frac{\partial \rho_k}{\partial P}=\frac{\partial \rho_k}{\partial \rho_l}\frac{\partial \rho_l}{\partial P}+\frac{\partial \rho_k}{\partial \rho_g}\frac{\partial \rho_g}{\partial P}+\frac{\partial \rho_k}{\partial \lambda_l}\frac{\partial \lambda_l}{\partial P}+\frac{\partial \rho_k}{\partial H_l}\frac{\partial H_l}{\partial P}$
$\frac{\partial Re}{\partial P}=\frac{\partial Re}{\partial \rho_k}\frac{\partial \rho_k}{\partial P}+\frac{\partial Re}{\partial v_m}\frac{\partial v_m}{\partial P}+\frac{\partial Re}{\partial \mu}\frac{\partial \mu}{\partial P}$
$\frac{\partial H_L}{\partial P}=\frac{\partial H_L}{\partial Re}\frac{\partial Re}{\partial P}+\frac{\partial H_L}{\partial \lambda_l}\frac{\partial \lambda_l}{\partial P}$

I can solve these for $\frac{\partial H_L}{\partial P}$ if I have all the other derivatives.
However I have a question on how I calculate some of the other derivatives needed, in particular $\frac{\partial \rho_k}{\partial \lambda_l}$ ? Do I keep $H_l$ constant or do I need to take into consideration $\frac{\partial H_L}{\partial \lambda_l}$ ?
Mathematically, is $\frac{\partial \rho_k}{\partial \lambda_l}$ equal to:

$\rho_l\frac{2.0\lambda_l}{H_l}-\rho_g\frac{2.0(1.0-\lambda_l)}{1.0-H_l}$, or

$\rho_l\frac{2.0H_l\lambda_l-\lambda_l^2\frac{\partial H_L}{\partial \lambda_l}}{H_l^2}-\rho_g\frac{2.0(1.0-H_l)(1.0-\lambda_l)+(1-\lambda_l)^2\frac{\partial H_L}{\partial \lambda_l}}{(1.0-H_l)^2}$ ?

Neither of these formulations give the same analytical value of $\frac{\partial H_L}{\partial P}$ as a numerical perturbation though, so I'm wondering if I am doing this all correctly.

1

There are 1 best solutions below

0
On

It turns out the first formulation for $\frac{\partial \rho_k}{\partial \lambda_l}$ is correct, that is:

$\rho_l\frac{2.0\lambda_l}{H_l}-\rho_g\frac{2.0(1.0-\lambda_l)}{1.0-H_l}$

The errors with $\frac{\partial H_L}{\partial P}$ were in the derivatives I was calculating for $H_l=f(Re,\lambda_l)$. This is a graph which I was using Bezier functions to interpolate. This works well in 1d, but 2d Bezier interpolation causes noise, resulting in erroneous derivatives.