[Mesa-users] avg_charge in MESA

Jason Wright astrowright at gmail.com
Thu Feb 27 16:52:49 UTC 2025


thanks!  Working on this.

This section on how to add columns to run_star_extras.f90 seems buggy:

https://docs.mesastar.org/en/r15140/using_mesa/extending_mesa.html

      subroutine data_for_extra_profile_columns(id, n, nz, names, vals,
ierr)
         integer, intent(in) :: id, n, nz
         character (len=maxlen_profile_column_name) :: names(n)
         real(dp) :: vals(nz,n)
         integer, intent(out) :: ierr
         type (star_info), pointer :: s
         integer :: k
         ierr = 0
         call star_ptr(id, s, ierr)
         if (ierr /= 0) return

         ! note: do NOT add the extra names to profile_columns.list
         ! the profile_columns.list is only for the built-in profile column
options.
         ! it must not include the new column names you are adding here.

         ! here is an example for adding a profile column
         !if (n /= 1) stop 'data_for_extra_profile_columns'
         !names(1) = 'beta'
         !do k = 1, nz
         !   vals(k,1) = s% Pgas(k)/s% P(k)
         !end do


I think the pressure (P(k)) has been renamed Peos(k), is that right?

Still, even after successfully making run_star_extras with that change, I
don't see beta showing up in the LOG files.  I'll keep poking around,
though—probably a simple bug, although I'm not getting any error messages.

Jason

On Thu, Feb 27, 2025 at 10:47 AM Farag, Ebraheem <ebraheem.farag at yale.edu>
wrote:

> Hello Jason,
>
> Unfortunately, the EOS in MESA does not calculate ionization directly. In
> previous MESA versions, the ionization module existed which could  estimate
> the ionization fraction. Recently, the ionization module was resurrected
> and re-included in mesa-releases, but consider it still a developmental
> feature (fine for classrooms, but not ready for science).
>
> I can't provide much more details except that in the past, something like
> the "avg_charge_H" was calculated through a call to the ionization module:
>
>                avg_charge_H = get_ion_info(ion_iZ_H,k,chem_isos% Z(ih1))
>
> Where "get_ion_info", is a wrapper for the ionization library:
>
> ---
>          *real*(dp) *function* get_ion_info(id,k,Z)
>             *use* ionization_lib, only: eval_ionization
>             *integer*, *intent*(*in*) :: id, k, Z
>             *integer* :: ierr
>             ierr = 0
>             *if* (ionization_k /= k) *then*
>                *call* eval_ionization( &
>                   s% Z(k), s% X(k), s% Rho(k), s% lnd(k)/ln10, &
>                   s% T(k), s% lnT(k)/ln10, ionization_res, ierr)
>                ionization_k = k
>             *end* *if*
>             *if* (ierr /= 0) *then*
>                get_ion_info = Z
>             *else*
>                get_ion_info = ionization_res(id)
>             *end* *if*
>          *end* *function* get_ion_info
> ---
>
> Feel free to try using this wrapper and calling the ionization module for
> the values you're interested in (for example, by adding this into your
> run_star_extras as an extra profile column).
>
> I hope this is helpful.
>
> -EbF
>
>
> ------------------------------
> *From:* Mesa-users <mesa-users-bounces at lists.mesastar.org> on behalf of
> Jason Wright via Mesa-users <mesa-users at lists.mesastar.org>
> *Sent:* Thursday, February 27, 2025 10:11 AM
> *To:* mesa-users <mesa-users at lists.mesastar.org>
> *Subject:* [Mesa-users] avg_charge in MESA
>
> Hi, all!  I'm once again using MESA to teach stellar structure and I've
> run into some curiosities and problems from my assignments four years ago.
>
> The first is that a few output parameters I was relying on seem to have
> disappeared.  I was using the profile outputs
>
> avg_charge [isotope]
>
> but this no longer seems to be an allowed output.  The reason I want this
> number is to calculate the Coulomb pressure as part of an assignment to
> explore the EOS used by MESA.
>
> Is there a way I can access these values? I tried the advertised profile
> outputs:
>
> typical_charge [isotope]
>
> but they are all zero.
>
> Thanks,
>
> --
>                                                 -
> ---------------
> Jason T Wright
> Professor of Astronomy and Astrophysics
> Director, Penn State Extraterrestrial Intelligence Center
> he/him/his
> *https://sites.psu.edu/astrowright/ <https://sites.psu.edu/astrowright/>*
> *https://bsky.app/profile/astrowright.bsky.social
> <https://bsky.app/profile/astrowright.bsky.social>*
>


-- 
                                                -
---------------
Jason T Wright
Professor of Astronomy and Astrophysics
Director, Penn State Extraterrestrial Intelligence Center
he/him/his
*https://sites.psu.edu/astrowright/ <https://sites.psu.edu/astrowright/>*
*https://bsky.app/profile/astrowright.bsky.social
<https://bsky.app/profile/astrowright.bsky.social>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.mesastar.org/pipermail/mesa-users/attachments/20250227/64408430/attachment.htm>


More information about the Mesa-users mailing list