[mesa-users] change physical constants

Diego Bossini dbossini at bison.ph.bham.ac.uk
Thu May 8 13:21:15 EDT 2014


Hi Bill,

I put  in  'extras_startup' routine this:
         rsol = 6.95508d10
         Rsun = rsol

and it seems work!

Thanks
Diego


2014-05-08 18:34 GMT+02:00 Bill Paxton <paxton at kitp.ucsb.edu>:

>
> On May 8, 2014, at 6:54 AM, Diego Bossini wrote:
>
> > Hi all,
> >
> > I was wondering if is possible change the values of some of the
> constants defined in 'const/public/const_def.f' without, of course, modify
> the standard mesa code.
>
> Wow!! I didn't think anyone would ever ask!  If you take a close look at
> const_def, you see that some things, like pi, are defined as "real(dp),
> parameter".   That means the compiler treats them as fixed values that
> cannot be changed at runtime.The math constants are treated as parameters.
>   (sorry, you can't run mesa with pi = 22/7 unless you modify the code.)
>   But the physical constants are defined simply as "real(dp)" so the
> compiler allocates storage for them that is accessed at runtime.  So if
> your code uses "pi" from const_def, the compiler substitutes the value
> given in the source code.  But if your code uses "Lsun" from const_def,
> then the compiler accesses the value stored in that variable in the
> const_def data at runtime.  When mesa/star starts a run, it calls
> const_init in const/public/const_lib, and that routine stores the default
> values for physical constants like Lsun.   If you come along after
> const_init and change the value, then all the routines that get the value
> from const_def will get your modified value instead of the default.  You
> can do that in your run_star_extras extras_controls routine for example.
>
>
> -B
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.mesastar.org/pipermail/mesa-users/attachments/20140508/0205443a/attachment.html>


More information about the Mesa-users mailing list