[go: up one dir, main page]

Menu

Tree [9a5978] master / src /
 History

HTTPS access


File Date Author Commit
 CMakeLists.txt 2025-09-21 Alan W. Irwin Alan W. Irwin [165610] Build system: Remove unneeded FreeEOS library i...
 README.derivatives 2022-02-27 Alan W. Irwin Alan W. Irwin [835c83] Doxygen documentation: Implement that documenta...
 README.developers 2021-02-25 Alan W. Irwin Alan W. Irwin [0cb541] Update src/README.developers
 allascii.txt 2020-04-25 Alan W. Irwin Alan W. Irwin [e5f966] Update allascii.txt to CODATA 2018
 aux_to_traditional.f90 2022-04-16 Alan W. Irwin Alan W. Irwin [7bff2e] Fix the final uninitialized issue discovered wi...
 bfgs_iterate.f90 2023-04-14 Alan W. Irwin Alan W. Irwin [23c51a] Replace the traditional Fortran 77 code in the ...
 coulomb.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 coulomb_adjust.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 deriv_product.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 deriv_ratio.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 effective_radius.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 effsum_calc.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 eos_bfgs.f90 2023-04-14 Alan W. Irwin Alan W. Irwin [23c51a] Replace the traditional Fortran 77 code in the ...
 eos_bfgs_callback_interface.f90 2023-04-14 Alan W. Irwin Alan W. Irwin [23c51a] Replace the traditional Fortran 77 code in the ...
 eos_calc.f90 2022-04-14 Alan W. Irwin Alan W. Irwin [6335a0] Solve *_dv array initialization issues that hav...
 eos_cold_start.f90 2022-04-16 Alan W. Irwin Alan W. Irwin [7bff2e] Fix the final uninitialized issue discovered wi...
 eos_free_calc.f90 2023-04-14 Alan W. Irwin Alan W. Irwin [23c51a] Replace the traditional Fortran 77 code in the ...
 eos_free_calc_extra_argument_documentation.f90 2023-04-14 Alan W. Irwin Alan W. Irwin [23c51a] Replace the traditional Fortran 77 code in the ...
 eos_free_calc_extra_argument_types.f90 2023-04-14 Alan W. Irwin Alan W. Irwin [23c51a] Replace the traditional Fortran 77 code in the ...
 eos_free_calc_extra_arguments.f90 2023-04-14 Alan W. Irwin Alan W. Irwin [23c51a] Replace the traditional Fortran 77 code in the ...
 eos_jacobian.f90 2023-01-02 Alan W. Irwin Alan W. Irwin [5da44c] Change partial_aux size from naux to n_partial_...
 eos_tqft.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 eos_warm_step.f90 2023-01-02 Alan W. Irwin Alan W. Irwin [5da44c] Change partial_aux size from naux to n_partial_...
 exchange_coeff.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 exchange_gcpf.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 excitation_pi.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 excitation_pi_end.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 excitation_sum.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 exct_calc.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 f_psi.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 fermi_dirac.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 fermi_dirac_coeff.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 fermi_dirac_ct.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 fermi_dirac_direct.f90 2022-10-01 Alan W. Irwin Alan W. Irwin [8d79b6] Use Fortran preprocessor directives to implemen...
 fermi_dirac_integrator.f90 2022-10-01 Alan W. Irwin Alan W. Irwin [8d79b6] Use Fortran preprocessor directives to implemen...
 fermi_dirac_minusnr_coeff.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 fermi_dirac_original_coeff.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 fermi_dirac_recursion.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 fjs_pi.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 fp12_calc.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 free_eos.c 2020-03-24 Alan W. Irwin Alan W. Irwin [78993e] Remove trailing whitespace
 free_eos_detailed.f90 2023-01-02 Alan W. Irwin Alan W. Irwin [5da44c] Change partial_aux size from naux to n_partial_...
 free_eos_interpolated.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 free_non_ideal_calc.f90 2023-01-02 Alan W. Irwin Alan W. Irwin [5da44c] Change partial_aux size from naux to n_partial_...
 included_fortran_types.f90.in 2020-08-10 Alan W. Irwin Alan W. Irwin [adde78] Move included_fortran_types.f90.in from the inc...
 included_tainting_control.f90.in 2021-09-11 Alan W. Irwin Alan W. Irwin [90e030] Implement configurable version of programmed ta...
 ionize.f90 2022-04-14 Alan W. Irwin Alan W. Irwin [6335a0] Solve *_dv array initialization issues that hav...
 lnx_calc.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mass_1.mas20.txt 2021-06-03 Alan W. Irwin Alan W. Irwin [fb87d8] Update isotopic masses to AME2020
 master_coulomb.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 master_exchange.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mdh_pi.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_aux_scale.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_bfgs.f90 2023-04-14 Alan W. Irwin Alan W. Irwin [23c51a] Replace the traditional Fortran 77 code in the ...
 mod_coulomb.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_diagnostics.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_eos_bfgs.f90 2022-03-26 Alan W. Irwin Alan W. Irwin [861c4c] Fix most nagfor 7.1 compiler warnings
 mod_eos_calc.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_eos_jacobian.f90 2022-03-26 Alan W. Irwin Alan W. Irwin [861c4c] Fix most nagfor 7.1 compiler warnings
 mod_exchange.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_excitation.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_excitation_block.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_fermi_dirac.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_fermi_dirac_integrator.f90 2022-10-01 Alan W. Irwin Alan W. Irwin [8d79b6] Use Fortran preprocessor directives to implemen...
 mod_flow_data.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_free_eos.f90 2023-04-14 Alan W. Irwin Alan W. Irwin [23c51a] Replace the traditional Fortran 77 code in the ...
 mod_free_eos_constants.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_free_eos_debug.f90 2022-03-26 Alan W. Irwin Alan W. Irwin [861c4c] Fix most nagfor 7.1 compiler warnings
 mod_free_eos_detailed.f90 2021-11-21 Alan W. Irwin Alan W. Irwin [0e7ee0] doxygen documentation: work around two doxygen ...
 mod_free_eos_types.f90 2021-11-21 Alan W. Irwin Alan W. Irwin [0e7ee0] doxygen documentation: work around two doxygen ...
 mod_helium1_data.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_info_data.f90 2023-04-14 Alan W. Irwin Alan W. Irwin [23c51a] Replace the traditional Fortran 77 code in the ...
 mod_ionization_data.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_isotopic_mass_data.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_lapack.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_molecular_hydrogen.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_nuvar.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_pi.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_pi_fit.f90 2022-01-18 Alice Faure Alice Faure [cfdc5c] Remove workaround for ifort spread function bug
 mod_pl.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_poly_sum.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 mod_statistical_weight_data.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 plsum.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 plsum_approx.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 pteh_pi.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 pteh_theta.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 qmhd_calc.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 qryd_approx.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 qryd_calc.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 qstar_calc.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 round_ln.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 solve_linear_svd.f90 2022-03-26 Alan W. Irwin Alan W. Irwin [861c4c] Fix most nagfor 7.1 compiler warnings
 solve_linear_svd_decomposed.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...
 tau_calc.f90 2022-03-31 Alan W. Irwin Alan W. Irwin [2cf066] Update Copyright information to 2022 for all fi...

Read Me

The input arguments to the generic free_eos routine include abundance
and option suite information that together specify the free-energy
model that is calculated by the free_eos library.  And the results of
the EOS calculation depend on certain first and second partial
derivatives of that free-energy model.  I have derived those partial
derivatives based on the principles of calculus, e.g., the chain rule,
implicit differentiation, etc., and, in particular those derivatives
are *not* based on numerical difference approximations.  Thus, if the
derivation *and* implementation of that derivation of all relevant
partial derivatives is correct for a given free-energy model, then
subject to small significance loss limits the iterative Newton-Raphson
solution of the EOS should converge quadratically to the exact
solution corresponding to that free-energy model, and that solution
should exhibit exact thermodynamic consistency.

Thus, when such quadratic convergence of the Newton-Raphson iteration
is not observed or the EOS results are not thermodynamically
consistent, then such symptoms typically imply there is an error in
the derivation or implementation of one of the many partial
derivatives of the free-energy model, and the rest of this file
documents how I use numerical difference tests to find which of the
derivatives is the culprit.

The numerical difference tests I have implemented are the
exchange_test, fermi_dirac_test, and free_eos_test executables which
respectively test partial derivatives of exchange- and
free-electron-related Fermi-Dirac integrals and overall thermodynamic
functions that have been implemented as part of the free_eos library.
(These partial differientation test executables are documented in more
detail in ../test_FreeEOS/README.simple_test and
../test_FreeEOS/README.free_eos_test.)

Assuming for the given free-energy model that free_eos_test shows
there is a derivative error in one or more thermodynamic functions,
then here are further tests that can be applied to help find *which*
derivative that those thermodynamic function derivatives depends on is
the source of the error.

* Test the derivatives of the exchange- and free-electron-related Fermi-Dirac
  integrals *that are adopted for that free-energy model* using exchange_test and
  fermi_dirac test.

* If the test failure is for kif /= 0, then try to replicate the issue for kif = 0

* Try to replicate the issue for simplified abundances, e.g., pure H, pure He,
  or pure Fe.

* Locally modify free_eos_detailed to drop various parts of the free-energy model to
  determine which component of that free-energy has a derivative error.

* Locally hack free_eos_detailed so that free_eos_test effectively ends up
  testing other partial derivative results with different independent variables!

  I classify all such test code as a hack because it closely depends
  on knowledge of the pattern of free_eos calls in free_eos_test (a
  first call evaluating thermodynamic functions and their derivatives
  wrt match_variable and tl and 32 subsequent calls evaluating centred
  numerical differences in match_variable and tl).  The hack is to save
  the initial match_variable and tl from the first of those calls, and
  use the match_variable and tl values from the further 32 calls to
  derive the logarithmic changes in two arbitrary independent
  variables that are being tested with centred numerical differences
  (so 4 calls per set of centred differences in match_variable and tl)
  for 8 different orders of magnitude in those differences.  Note, for
  those 32 calls, match_variable and tl are restored to their initial
  values to provide clean numerical difference results for whatever
  two (specified by itemp[12] in free_eos_detailed) independent
  variables are chosen for these hacked partial derivative tests.

  Currently free_eos_detailed and the subroutines it calls illustrate
  this testing technique for three different mutually exclusive sets
  of partial derivatives where one of the logical parameters
  debug_dv_aux, debug_aux_dv, or debug_jacobian (all of which are
  normally .false.) is locally modified to be .true. in order that the
  hacked test code associated with that logical variable is executed.
  In these three cases that have been implemented, the partial
  derivatives being tested are calculated by eos_jacobian.  Therefore,
  to insure a derivative test that is for independent variables that
  are a fairly good approximation to what would have been the final
  result for the given physical conditions and free-energy model, I
  have chosen to call eos_cold_start before eos_jacobian to provide
  fairly realistic independent variables for these tests.

  Further notes on each of these testing hacks that are labelled by
  the associated logical variable.

  + debug_dv_aux = .true.: this hack uses numerical differences to
    test the partial derivatives of components of dv (designated by
    jtemp[1-6] in free_eos_detailed which corresponds to the species H+,
    He+, He++, C+, H2, and H2+ although other choices are possible)
    wrt to components of aux_old, fl, or tl (designated by itemp[12]
    in free_eos_detailed).  dv(aux_old, fl, tl) is the vector of
    non-ideal equilibrium constants which are needed in eos_calc to
    help calculate number densities of all species; aux_old is the
    vector of old auxiliary variables fl is the EFF logarithmic
    degeneracy parameter, and tl is ln T; and aux_new(dv(aux_old, fl,
    tl), fl, tl) = aux_new(aux_old, fl, tl) is the vector of new
    auxiliary variables which are each defined as a uniquely weighted
    sum over the number densities of species that are calculated by
    eos_calc.  (See the "solution.pdf" paper for further details
    concerning the use of auxiliary variables to determine the EOS
    solution corresponding to non-ideal free-energy minimization.)

    + debug_aux_dv = .true.: this hack uses numerical differences to
      test the partial derivatives of components of aux_new(dv, fl,
      tl) (designated by jtemp[1-6] in free_eos_detailed with sets of
      choices corresponding to all aux components possible with EOS1)
      wrt to components of dv (designated by itemp[12] in
      free_eos_detailed where sets of itemp[12] values correspond to
      the species H+, He+, He++, C+, H2, and H2+ although other
      choices are possible).  See discussion of debug_dv_aux =
      .true. for more discussion of the partial derivatives being
      debugged for this case.

    + debug_jacobian = .true.: this hack uses numerical differences to
      test the partial derivatives of components of faux (the RHS
      vector for the system of linary equations solved in a
      Newton-Raphson step where the components of this vector are
      designated by sets of jtemp[1-6] variables in free_eos_detailed) wrt
      to components of aux_old, fl, or tl (designated by itemp[12] in
      free_eos_detailed).  Except for its last component which is a
      special case, faux depends on the difference between
      aux_new(aux_old, fl, tl) and aux_old so ultimately these partial
      derivatives depend on the partials of aux_new(aux_old, fl, tl) -
      aux_old wrt components of aux_old (whose negative values are
      stored in the jacobian matrix) and the partial derivatives of
      aux_new(aux_old, fl, tl) wrt fl and tl.

      N.B. eos_jacobian normally calculates the partial derivatives of
      aux_new(dv, fl, tl) wrt fl and tl so an extra transformation
      (still not completely debugged, see FIXME notice in
      free_eos_detailed) needs to be applied to determine the desired
      partials of aux_new(aux_old, fl, tl) wrt fl or tl.  Note the
      equivalent calculations in eos_tqft are implemented in a
      completely different (ifnr = 0) way but are done correctly so
      for normal use (i.e., none of the debug_* options are set to
      .true.)  the derivatives tested by free_eos_test are calculated
      correctly.