[Mesa-users] Noisy derivatives for structure quantities
Walter van Rossem
walter_v_rossem at hotmail.com
Fri Oct 18 06:21:06 EDT 2019
Hi Giovanni,
This is happening because some quantities are defined at the centre of a cell and others at the outer cell boundaries. Try using
def cell2face(val, dm, dm_is_m=False, m_center=0):
if dm_is_m:
dm = np.diff(dm, append=m_center)
face = np.zeros_like(val)
face[0] = val[0]
face[1:] = (val[:-1]*dm[1:] + val[1:]*dm[:-1]) / (dm[1:] + dm[:-1])
return face
to convert to outer face values.
Cheers,
Walter
On 18/10/2019 09:04, Giovanni Mirouh via Mesa-users wrote:
Dear all,
I come to you with a pretty trivial question, sorry for that.
I am computing models, and for some calculations I need to compute d
ln(rho)/ dx. I read the data in python using the py_mesa_reader package
and derive logRho using numpy.gradient. What I obtain is noisy, with a
lot of spikes in the derivative: does anyone have advice on how to avoid
this? is there a way to compute/smooth the derivatives while running the
code? should I use better tolerances?
Attached is a series of plots for a 4Msun star at center_h1 = 0.6, and
the associated inlist, to give you an idea.
Thank you in advance,
Best.
_______________________________________________
mesa-users at lists.mesastar.org<mailto:mesa-users at lists.mesastar.org>
https://lists.mesastar.org/mailman/listinfo/mesa-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.mesastar.org/pipermail/mesa-users/attachments/20191018/3c680d2a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dlnrho_dx.png
Type: image/png
Size: 33741 bytes
Desc: dlnrho_dx.png
URL: <https://lists.mesastar.org/pipermail/mesa-users/attachments/20191018/3c680d2a/attachment-0001.png>
More information about the Mesa-users
mailing list