giantlayers 0.1.0a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. giantlayers-0.1.0a1/.readthedocs.yaml +11 -0
  2. giantlayers-0.1.0a1/LICENSE +21 -0
  3. giantlayers-0.1.0a1/MANIFEST.in +6 -0
  4. giantlayers-0.1.0a1/PKG-INFO +47 -0
  5. giantlayers-0.1.0a1/README.md +29 -0
  6. giantlayers-0.1.0a1/docs/index.md +8 -0
  7. giantlayers-0.1.0a1/docs/model.md +15 -0
  8. giantlayers-0.1.0a1/docs/quickstart.md +389 -0
  9. giantlayers-0.1.0a1/docs/requirements.txt +1 -0
  10. giantlayers-0.1.0a1/docs/spherical.md +23 -0
  11. giantlayers-0.1.0a1/docs/validation.md +252 -0
  12. giantlayers-0.1.0a1/mkdocs.yml +13 -0
  13. giantlayers-0.1.0a1/pyproject.toml +8 -0
  14. giantlayers-0.1.0a1/setup.cfg +47 -0
  15. giantlayers-0.1.0a1/setup.py +24 -0
  16. giantlayers-0.1.0a1/src/giantlayers/__init__.py +11 -0
  17. giantlayers-0.1.0a1/src/giantlayers/__main__.py +4 -0
  18. giantlayers-0.1.0a1/src/giantlayers/atlas9_odf.py +102 -0
  19. giantlayers-0.1.0a1/src/giantlayers/atlas_writer.py +118 -0
  20. giantlayers-0.1.0a1/src/giantlayers/audit_resolution.py +116 -0
  21. giantlayers-0.1.0a1/src/giantlayers/benchmark_sampling.py +86 -0
  22. giantlayers-0.1.0a1/src/giantlayers/cli.py +555 -0
  23. giantlayers-0.1.0a1/src/giantlayers/collision_induced.py +94 -0
  24. giantlayers-0.1.0a1/src/giantlayers/compare_atmospheres.py +58 -0
  25. giantlayers-0.1.0a1/src/giantlayers/compare_marcs_chemistry.py +72 -0
  26. giantlayers-0.1.0a1/src/giantlayers/compare_marcs_flux.py +101 -0
  27. giantlayers-0.1.0a1/src/giantlayers/data/__init__.py +1 -0
  28. giantlayers-0.1.0a1/src/giantlayers/data/barklem_collet.json +121 -0
  29. giantlayers-0.1.0a1/src/giantlayers/examples/__init__.py +1 -0
  30. giantlayers-0.1.0a1/src/giantlayers/examples/continuum-wavelengths.dat +81 -0
  31. giantlayers-0.1.0a1/src/giantlayers/examples/solar-gs98.json +94 -0
  32. giantlayers-0.1.0a1/src/giantlayers/exomol_import.py +115 -0
  33. giantlayers-0.1.0a1/src/giantlayers/gray_atmosphere.py +98 -0
  34. giantlayers-0.1.0a1/src/giantlayers/hminus.py +106 -0
  35. giantlayers-0.1.0a1/src/giantlayers/kernel_module.c +15 -0
  36. giantlayers-0.1.0a1/src/giantlayers/kurucz_atomic_lines.py +79 -0
  37. giantlayers-0.1.0a1/src/giantlayers/lte_chemistry.py +265 -0
  38. giantlayers-0.1.0a1/src/giantlayers/lte_opacity.py +296 -0
  39. giantlayers-0.1.0a1/src/giantlayers/marcs_atomic_lines.py +60 -0
  40. giantlayers-0.1.0a1/src/giantlayers/marcs_model.py +70 -0
  41. giantlayers-0.1.0a1/src/giantlayers/marcs_opacity.py +66 -0
  42. giantlayers-0.1.0a1/src/giantlayers/marcs_writer.py +154 -0
  43. giantlayers-0.1.0a1/src/giantlayers/mixing_length.py +206 -0
  44. giantlayers-0.1.0a1/src/giantlayers/molecular_cross_section.py +92 -0
  45. giantlayers-0.1.0a1/src/giantlayers/native_marcs.py +118 -0
  46. giantlayers-0.1.0a1/src/giantlayers/native_transfer.py +224 -0
  47. giantlayers-0.1.0a1/src/giantlayers/nonlinear_atmosphere.py +139 -0
  48. giantlayers-0.1.0a1/src/giantlayers/odf_transfer.py +269 -0
  49. giantlayers-0.1.0a1/src/giantlayers/opacity_table.py +66 -0
  50. giantlayers-0.1.0a1/src/giantlayers/spherical_heating.py +1071 -0
  51. giantlayers-0.1.0a1/src/giantlayers/spherical_hydrostatic.py +213 -0
  52. giantlayers-0.1.0a1/src/giantlayers/spherical_kernel.c +179 -0
  53. giantlayers-0.1.0a1/src/giantlayers/spherical_kernel.py +44 -0
  54. giantlayers-0.1.0a1/src/giantlayers/spherical_kernel_loader.py +58 -0
  55. giantlayers-0.1.0a1/src/giantlayers/spherical_transfer.py +155 -0
  56. giantlayers-0.1.0a1/src/giantlayers/transfer_cache.py +66 -0
  57. giantlayers-0.1.0a1/src/giantlayers/two_group_atmosphere.py +145 -0
  58. giantlayers-0.1.0a1/src/giantlayers.egg-info/PKG-INFO +47 -0
  59. giantlayers-0.1.0a1/src/giantlayers.egg-info/SOURCES.txt +79 -0
  60. giantlayers-0.1.0a1/src/giantlayers.egg-info/dependency_links.txt +1 -0
  61. giantlayers-0.1.0a1/src/giantlayers.egg-info/entry_points.txt +2 -0
  62. giantlayers-0.1.0a1/src/giantlayers.egg-info/requires.txt +3 -0
  63. giantlayers-0.1.0a1/src/giantlayers.egg-info/top_level.txt +1 -0
  64. giantlayers-0.1.0a1/tests/__init__.py +0 -0
  65. giantlayers-0.1.0a1/tests/check_wheel.py +45 -0
  66. giantlayers-0.1.0a1/tests/test_adaptive_jacobian.py +17 -0
  67. giantlayers-0.1.0a1/tests/test_atlas_writer.py +84 -0
  68. giantlayers-0.1.0a1/tests/test_audit_resolution.py +22 -0
  69. giantlayers-0.1.0a1/tests/test_bottom_flux_bracket.py +36 -0
  70. giantlayers-0.1.0a1/tests/test_compare_marcs_flux.py +21 -0
  71. giantlayers-0.1.0a1/tests/test_exomol_doppler_kernel.py +31 -0
  72. giantlayers-0.1.0a1/tests/test_exomol_import.py +15 -0
  73. giantlayers-0.1.0a1/tests/test_mixing_length.py +35 -0
  74. giantlayers-0.1.0a1/tests/test_molecular_cross_section.py +32 -0
  75. giantlayers-0.1.0a1/tests/test_native_atmosphere.py +210 -0
  76. giantlayers-0.1.0a1/tests/test_spherical_hydrostatic.py +53 -0
  77. giantlayers-0.1.0a1/tests/test_spherical_transfer.py +278 -0
  78. giantlayers-0.1.0a1/tests/test_transfer_cache.py +35 -0
  79. giantlayers-0.1.0a1/tools/exomol_doppler.c +89 -0
  80. giantlayers-0.1.0a1/tools/exomol_doppler.py +101 -0
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ build:
3
+ os: ubuntu-24.04
4
+ tools:
5
+ python: "3.12"
6
+ python:
7
+ install:
8
+ - requirements: docs/requirements.txt
9
+ mkdocs:
10
+ configuration: mkdocs.yml
11
+ fail_on_warning: true
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 David Nidever
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ include LICENSE
2
+ include mkdocs.yml .readthedocs.yaml
3
+ recursive-include tests *.py
4
+ recursive-include docs *.md *.txt
5
+ include tools/exomol_doppler.c tools/exomol_doppler.py
6
+ include src/giantlayers/kernel_module.c
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: giantlayers
3
+ Version: 0.1.0a1
4
+ Summary: Experimental spherical LTE model atmospheres for cool giant stars
5
+ Home-page: https://github.com/dnidever/giantlayers
6
+ License: MIT
7
+ Project-URL: Documentation, https://giantlayers.readthedocs.io/
8
+ Project-URL: Issues, https://github.com/dnidever/giantlayers/issues
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Provides-Extra: exomol
16
+ Requires-Dist: h5py; extra == "exomol"
17
+ Dynamic: license-file
18
+
19
+ # GiantLayers
20
+
21
+ GiantLayers is an experimental spherical LTE stellar atmosphere solver for cool giants. It starts from effective temperature, surface gravity, stellar mass, and an elemental abundance mixture. The solver couples hydrostatic structure, LTE chemistry, wavelength-dependent radiative transfer with continuum scattering, and mixing-length convection. It writes a CSV with the luminosity residual at each layer and can export MARCS, ATLAS9, and ATLAS12 atmosphere files.
22
+
23
+ ## Install and run
24
+
25
+ GiantLayers requires Python 3.9 or later. Install from a repository checkout with `python -m pip install .` or install a built wheel with `python -m pip install PATH_TO_WHEEL`.
26
+
27
+ Binary wheels use the included C transfer kernel automatically, with no compiler required to install or run the wheel. Use `--python-kernel` to select Python transfer or `--kernel PATH` for a custom shared library. On platforms without a matching binary wheel, pip can install the universal wheel and GiantLayers uses Python transfer.
28
+
29
+ The package includes a small solar-composition example. Run it from any directory after installing.
30
+
31
+ ```sh
32
+ EXAMPLE_DIR=$(python -c "from importlib.resources import files; print(files('giantlayers.examples'))")
33
+ giantlayers "$EXAMPLE_DIR/continuum-wavelengths.dat" "$EXAMPLE_DIR/solar-gs98.json" \
34
+ --teff 3500 --logg 1 --mass 1 --layers 12 --upper-knots 4 \
35
+ --steps 1 --output-model trial.mod > trial.csv
36
+ ```
37
+
38
+ This continuum-only example exercises the solver and exporter. For a line-blanketed calculation, provide an atomic transition CSV with `--lines` and molecular cross sections with repeatable `--molecular-cross-section` options. The output identifies unconverged profiles. Check the maximum luminosity error and sensitivity to wavelength and depth resolution before using a model.
39
+
40
+ See the [quickstart](docs/quickstart.md) for input formats, opacity sources, and the optional compiled transfer kernel. The gray Eddington benchmark is available through `python -m giantlayers.gray_atmosphere`. Run the regression tests with `python -m unittest discover`.
41
+
42
+ ## Documentation
43
+
44
+ ```sh
45
+ python3 -m pip install -r docs/requirements.txt
46
+ python3 -m mkdocs serve
47
+ ```
@@ -0,0 +1,29 @@
1
+ # GiantLayers
2
+
3
+ GiantLayers is an experimental spherical LTE stellar atmosphere solver for cool giants. It starts from effective temperature, surface gravity, stellar mass, and an elemental abundance mixture. The solver couples hydrostatic structure, LTE chemistry, wavelength-dependent radiative transfer with continuum scattering, and mixing-length convection. It writes a CSV with the luminosity residual at each layer and can export MARCS, ATLAS9, and ATLAS12 atmosphere files.
4
+
5
+ ## Install and run
6
+
7
+ GiantLayers requires Python 3.9 or later. Install from a repository checkout with `python -m pip install .` or install a built wheel with `python -m pip install PATH_TO_WHEEL`.
8
+
9
+ Binary wheels use the included C transfer kernel automatically, with no compiler required to install or run the wheel. Use `--python-kernel` to select Python transfer or `--kernel PATH` for a custom shared library. On platforms without a matching binary wheel, pip can install the universal wheel and GiantLayers uses Python transfer.
10
+
11
+ The package includes a small solar-composition example. Run it from any directory after installing.
12
+
13
+ ```sh
14
+ EXAMPLE_DIR=$(python -c "from importlib.resources import files; print(files('giantlayers.examples'))")
15
+ giantlayers "$EXAMPLE_DIR/continuum-wavelengths.dat" "$EXAMPLE_DIR/solar-gs98.json" \
16
+ --teff 3500 --logg 1 --mass 1 --layers 12 --upper-knots 4 \
17
+ --steps 1 --output-model trial.mod > trial.csv
18
+ ```
19
+
20
+ This continuum-only example exercises the solver and exporter. For a line-blanketed calculation, provide an atomic transition CSV with `--lines` and molecular cross sections with repeatable `--molecular-cross-section` options. The output identifies unconverged profiles. Check the maximum luminosity error and sensitivity to wavelength and depth resolution before using a model.
21
+
22
+ See the [quickstart](docs/quickstart.md) for input formats, opacity sources, and the optional compiled transfer kernel. The gray Eddington benchmark is available through `python -m giantlayers.gray_atmosphere`. Run the regression tests with `python -m unittest discover`.
23
+
24
+ ## Documentation
25
+
26
+ ```sh
27
+ python3 -m pip install -r docs/requirements.txt
28
+ python3 -m mkdocs serve
29
+ ```
@@ -0,0 +1,8 @@
1
+ # GiantLayers
2
+
3
+ GiantLayers is an experimental stellar atmosphere solver for cool giants. It can start a spherical LTE calculation from stellar parameters, a chemical abundance mixture, and opacity data. It provides depth-resolved luminosity diagnostics and MARCS-format output.
4
+
5
+ - [Quickstart](quickstart.md) covers installation, atmosphere calculations, and reference benchmarks.
6
+ - [Spherical model](spherical.md) describes the coupled structure and transfer.
7
+ - [Validation](validation.md) describes the fiducial MARCS benchmark.
8
+ - [Gray atmosphere model](model.md) describes the analytic transfer benchmark.
@@ -0,0 +1,15 @@
1
+ # Gray atmosphere model
2
+
3
+ The prototype assumes a static, plane-parallel atmosphere in local thermodynamic equilibrium. Gravity and gray absorption opacity are constant. Radiation carries the entire flux.
4
+
5
+ ## Structure and transfer
6
+
7
+ With column mass *m* increasing inward from the surface, gray optical depth is τ = κ*m* and hydrostatic equilibrium gives gas pressure *P* = *gm*. Here κ is the absorption opacity and *g* is surface gravity.
8
+
9
+ The two-stream quadrature uses outward and inward rays with direction cosines ±1/√3. Radiative equilibrium fixes the bolometric flux to σ times the fourth power of the effective temperature. The solver derives the temperature profile from the gray moment equations with zero incident intensity at the surface.
10
+
11
+ ## Numerical checks
12
+
13
+ The formal ray sweep integrates the transfer equation across each depth interval using a linear source function. It uses the surface vacuum boundary for the incoming ray and the diffusion boundary for the outgoing ray at the bottom. The flux residual compares the resulting flux with the prescribed bolometric flux at every depth. The hydrostatic residual checks the pressure gradient with respect to column mass against the input gravity.
14
+
15
+ This model provides a benchmark for future frequency-dependent opacity, convection, and spherical geometry.
@@ -0,0 +1,389 @@
1
+ # Quickstart
2
+
3
+ Clone the repository and run the prototype with Python 3. The solver uses the Python standard library.
4
+
5
+ ```sh
6
+ git clone https://github.com/dnidever/giantlayers.git
7
+ cd giantlayers
8
+ python -m pip install .
9
+ python -m giantlayers.gray_atmosphere --teff 4300 --logg 1.5 > atmosphere.csv
10
+ ```
11
+
12
+ This sets the effective temperature to 4300 K and the base-10 logarithm of surface gravity to 1.5 in cgs units. The default grid has 81 layers, extends to gray optical depth 100, and uses a constant opacity of 0.1 cm²/g.
13
+
14
+ ## Model output
15
+
16
+ | CSV column | Meaning |
17
+ | --- | --- |
18
+ | `tau` | Gray optical depth, increasing inward from zero |
19
+ | `column_mass_g_cm2` | Column mass in g/cm² |
20
+ | `temperature_K` | Temperature in K |
21
+ | `pressure_dyn_cm2` | Gas pressure in dyn/cm² |
22
+ | `flux_erg_cm2_s` | Net outward radiative flux in erg/(cm² s) |
23
+ | `relative_flux_residual` | Fractional difference between the ray-sweep flux and the prescribed flux |
24
+
25
+ The program prints maximum relative flux and hydrostatic residuals to standard error, so they stay visible when the CSV goes to a file. For grid and opacity options, run:
26
+
27
+ ```sh
28
+ python -m giantlayers.gray_atmosphere --help
29
+ ```
30
+
31
+ ## Run with a two-group opacity table
32
+
33
+ The nonlinear prototype can read both mass opacities from a CSV file.
34
+
35
+ ```sh
36
+ python -m giantlayers.nonlinear_atmosphere --opacity-table opacities.csv > atmosphere.csv
37
+ ```
38
+
39
+ Use the following header and provide one row for each temperature–pressure pair on a complete rectangular grid with at least two values on each axis. All input values must be positive and finite. Opacities are in cm²/g.
40
+
41
+ ```csv
42
+ temperature_K,pressure_dyn_cm2,group1_opacity_cm2_g,group2_opacity_cm2_g
43
+ ```
44
+
45
+ The solver interpolates in log temperature, log pressure, and log opacity. Pressures below the lowest grid point, including the vacuum surface, use the lowest-pressure row. A temperature outside the table or a pressure above its upper limit stops the run. Make sure the table covers the temperatures encountered during iteration as well as the final profile.
46
+
47
+ The two groups retain equal Planck weights. Tables supplied here should contain the group means appropriate to that simplified model.
48
+
49
+ ## Compare with a MARCS atmosphere
50
+
51
+ Use a matching MARCS model structure, continuum table, and sampled surface flux from the same grid point. Keep the published MARCS wavelength grid alongside the flux file. [MARCS downloads](https://marcs.astro.uu.se/data.html) · [File formats and wavelength grid](https://marcs.astro.uu.se/docs.html)
52
+
53
+ ```sh
54
+ python -m giantlayers.odf_transfer p00big2.bdf --marcs-model model.mod.gz \
55
+ --marcs-continuum model.opa.gz > bands.csv
56
+ python -m giantlayers.compare_marcs_flux bands.csv flx_wavelengths.vac.gz model.flx.gz > comparison.csv
57
+ ```
58
+
59
+ GiantLayers uses the MARCS true continuum absorption with ATLAS9 line opacity on the fixed temperature and pressure structure. The transfer uses plane-parallel two-stream geometry. Add `--continuum-scattering` to include isotropic coherent scattering from the MARCS table. The comparison integrates published flux samples only over bands fully covered by the MARCS wavelength grid.
60
+
61
+ ### Inspect radiative heating
62
+
63
+ Add `--heating-output heating.csv` to write the heating profile while keeping the band flux CSV on standard output. The profile includes column mass, local net heating per gram, integrated heating in each depth cell, and net outward radiative flux. A positive heating rate means the matter absorbs more energy than it emits. The diagnostic uses the conservative two-stream solver and prints the closure error between the summed cell heating and the change in radiative flux across the atmosphere.
64
+
65
+ ## Write a MARCS atmosphere file
66
+
67
+ The exporter writes a complete MARCS model as plain text or gzip. The command below reads an existing model and re-exports its header, 92 elemental abundances, structure, thermodynamics, and partial pressures.
68
+
69
+ ```sh
70
+ python -m giantlayers.marcs_writer input.mod.gz output.mod
71
+ ```
72
+
73
+ From Python, call `marcs_writer.write_document(model, path)` with a complete `MarcsDocument`. Supply every table and the abundance pattern for the same physical model. The gray and two-group CSV outputs contain only a subset of the fields required for export.
74
+
75
+ ## Calculate opacities for a custom composition
76
+
77
+ Run the native LTE opacity solver with Python 3.9 or later. It uses the Python standard library and the thermochemistry data included in the checkout.
78
+
79
+ Save a composition as JSON. The optional metal offset shifts every element heavier than helium in dex relative to the input MARCS atmosphere. Individual values override the shifted abundances on the absolute scale where hydrogen is 12.
80
+
81
+ ```json
82
+ {
83
+ "metallicity_offset": -0.3,
84
+ "log_epsilon": {"C": 8.72, "N": 7.92, "O": 8.83}
85
+ }
86
+ ```
87
+
88
+ Supply a transition CSV with vacuum wavelength in Å, species, lower excitation energy in eV, and log gf. Use element symbols for neutral atoms, append `+` for singly ionized atoms, and use formulas such as `CO` for molecules. An optional `damping_s` column supplies the total Lorentz damping rate in s⁻¹. With no damping rate, the profile is Doppler broadened.
89
+
90
+ ```csv
91
+ wavelength_vacuum_A,species,lower_energy_eV,log_gf
92
+ 15570.299575,CO,6.996,-6.129123
93
+ ```
94
+
95
+ ```sh
96
+ python -m giantlayers.lte_opacity model.mod.gz transitions.csv mixture.json 15570 15585 0.05 opacity.csv --vmic 2
97
+ ```
98
+
99
+ The reference MARCS structure supplies the temperature and gas pressure. The solver recomputes the mass density, electron density and species populations at each layer. The output contains sampled line absorption, continuum absorption, and continuum scattering in cm²/g. For isotopologue lines, include the isotopic fraction in the oscillator strength used in the transition CSV.
100
+
101
+ The bundled data cover 1,000–10,000 K and include neutral atoms, first ions, H⁻, 20 neutral diatomic molecules, and H₂O. Water equilibrium uses the NASA Glenn data through 6,000 K. Continuum terms include H⁻ bound-free and free-free absorption, hydrogenic H I bound-free absorption, electron–ion free-free absorption, and Thomson scattering. The hydrogenic continuum terms use unit Gaunt factors. Additional polyatomic and charged molecules, higher ionization stages, metal photoionization, and calculated collisional line damping are future extensions.
102
+
103
+ [Atomic and diatomic thermochemistry data](https://doi.org/10.1051/0004-6361/201526961) · [H⁻ continuum data in the ATLAS9 HMINOP routine](https://wwwuser.oats.inaf.it/fiorella.castelli/sources/atlas9g/atlas9mem.for) · [APOGEE DR17 line data reference](https://ui.adsabs.harvard.edu/abs/2021AJ....161..254S/abstract)
104
+
105
+ ### Evaluate radiative heating with native opacities
106
+
107
+ Provide a text file containing increasing vacuum wavelengths in Å. The transfer uses the same grid for all layers and integrates in frequency using trapezoidal weights. Include broad wavelength coverage and enough samples to resolve the lines when interpreting the result as a bolometric energy balance.
108
+
109
+ ```sh
110
+ python -m giantlayers.native_transfer model.mod.gz transitions.csv mixture.json wavelengths.txt heating.csv
111
+ ```
112
+
113
+ Add `--adjust-layers 6 --steps 3` to try up to three damped temperature corrections in the outermost six layers. Gas pressure and column mass stay fixed. Each trial recomputes LTE equilibrium, opacity, and transfer, and is accepted only if it reduces the maximum outer-layer net heating relative to thermal emission. Deeper layers supply a fixed lower structure.
114
+
115
+ The CSV reports initial and corrected temperature, radiative flux, local heating, and integrated cell heating. These corrections are a radiative test on a fixed pressure structure. A converged atmosphere also requires adequate opacity coverage, a flux constraint, and treatment of convective energy transport.
116
+
117
+ ### Use the fiducial cool giant
118
+
119
+ Use the spherical MARCS GS98 model at 3,500 K, log g 1.0, one solar mass, and 2 km/s microturbulence for the cool-giant benchmark. The model header reports [Fe/H] = +0.05 and [α/Fe] = +0.11 on the MARCS reference scale.
120
+
121
+ Extract this member from the MARCS GS98 structure archive. Use an empty JSON object for the published abundance pattern. [MARCS GS98 archive](https://marcs.astro.uu.se/data.html)
122
+
123
+ ```text
124
+ s3500_g+1.0_m1.0_t02_gs_z+0.05_a+0.11_c+0.08_n+0.09_o+0.12_r+0.00_s+0.00.mod.gz
125
+ ```
126
+
127
+ The energy-balance CSV includes the radiative flux, published MARCS convective contribution, and total flux error at each depth. The reference flux is scaled by the inverse square of the model radius for spherical models. The transfer still uses plane-parallel geometry. Add `--flux-guard` to a temperature trial to reject steps that reduce the local heating imbalance while worsening the surface flux error. The diagnostic keeps the MARCS convective flux fixed.
128
+
129
+ ### Add tabulated TiO and water absorption
130
+
131
+ Both native opacity and transfer commands accept repeatable `--molecular-cross-section FILE` options. A portable JSON or gzip-compressed JSON table has the following fields.
132
+
133
+ | Field | Contents |
134
+ | --- | --- |
135
+ | `species` | Chemistry species such as `TiO` or `H2O` |
136
+ | `isotopologue` | Optional data identifier |
137
+ | `isotope_fraction` | Fraction of the parent species represented by the table. Defaults to 1. |
138
+ | `temperature_K`, `pressure_dyn_cm2`, `wavelength_vacuum_A` | Increasing grid axes |
139
+ | `cross_section_cm2` | Three-dimensional array ordered by temperature, pressure, and wavelength. Values are in cm² per isotopologue. |
140
+
141
+ The code scales each cross section by the molecule population and isotope fraction. It interpolates in temperature, log pressure, and wavelength, using endpoint temperature or pressure values outside those axes. Wavelengths outside the table contribute zero absorption. Represent each isotopologue once by choosing either its cross section or its transitions on overlapping wavelengths.
142
+
143
+ The first fiducial experiment sampled ExoMol ToTo and POKAZATEL cross sections over 0.3–50 μm on a 2,200–3,400 K grid. Deeper, hotter layers use the hottest tabulated cross section for each molecule that remains in the chemistry calculation. Use the same wavelength grid when comparing runs. [TiO ToTo](https://exomol.com/data/data-types/opacity/TiO/48Ti-16O/Toto/) · [H₂O POKAZATEL](https://zenodo.org/records/5722861) · [NASA Glenn thermochemistry](https://ntrs.nasa.gov/citations/20020085330)
144
+
145
+ ### Check wavelength sampling
146
+
147
+ Run the sampling benchmark with cross-section tables on a common wavelength axis. It keeps the reference atmosphere fixed and reports surface flux, the maximum total-flux error with depth, and the heating/flux closure error on each nested grid. Supply any additional wavelengths outside the tabulated range or in line windows through `--supplemental-wavelengths`.
148
+
149
+ ```sh
150
+ python -m giantlayers.benchmark_sampling model.mod.gz transitions.csv mixture.json tio.json.gz h2o.json.gz --strides 4 2 1 > sampling.csv
151
+ ```
152
+
153
+ For expanded optical and infrared coverage, include ExoMol HyVO and Li2015 CO tables on the same grid. If the CO table replaces the explicit CO transitions, remove those transitions from the input CSV. A header-only transition CSV is valid when using cross sections alone. These files add molecular opacity over the common sampled range and inherit the temperature and pressure coverage of the source tables. [VO HyVO](https://exomol.com/data/molecules/VO/51V-16O/HyVO/) · [CO Li2015](https://www.exomol.com/data/molecules/CO/12C-16O/Li2015/)
154
+
155
+ ### Run on the published MARCS wavelength grid
156
+
157
+ Pass the published vacuum grid directly to native transfer with `--quadrature wavelength`. The reader accepts the original gzip file, and the transfer processes the opacity in wavelength blocks while retaining quadrature weights across block boundaries.
158
+
159
+ ```sh
160
+ python -m giantlayers.native_transfer model.mod.gz transitions.csv mixture.json flx_wavelengths.vac.gz full-grid.csv --quadrature wavelength --molecular-cross-section tio.json.gz
161
+ ```
162
+
163
+ To compare coarse startup sampling with the full published grid, pass the same input file to the sampling benchmark. Stride 10 retains every tenth sample and both endpoints. Stride 1 uses all 100,724 wavelengths.
164
+
165
+ ```sh
166
+ python -m giantlayers.benchmark_sampling model.mod.gz transitions.csv mixture.json tio.json.gz --reference-wavelengths flx_wavelengths.vac.gz --strides 10 1 --quadrature wavelength > marcs-sampling.csv
167
+ ```
168
+
169
+ Use the native-resolution opacity tables when comparing the grids. The transfer evaluates the available opacities at the MARCS sample positions. This matches the published wavelength axis and the wavelength integration convention. The geometry, opacity inventory, and convection model also affect how closely the calculated atmosphere reproduces MARCS. [MARCS wavelength download](https://marcs.astro.uu.se/docs.html) · [MARCS methods](https://arxiv.org/abs/0805.0554)
170
+
171
+ ### Compare spherical and plane-parallel surface transfer
172
+
173
+ Convert the published MARCS oscillator-strength revisions from VALD air wavelengths into the native vacuum-wavelength transition format. These files provide a subset of the atomic lines used by MARCS. The converted transitions use Doppler broadening. [MARCS auxiliary atomic data](https://marcs.astro.uu.se/docs.html#Auxiliary)
174
+
175
+ ```sh
176
+ python -m giantlayers.marcs_atomic_lines astroph_gfVALD1.dat astroph_gfVALD2.dat > revised-atomic-lines.csv
177
+ ```
178
+
179
+ An atomic transition CSV can supply `damping_s` for a density-independent Lorentz damping rate in s⁻¹. Add `electron_damping_cm3_s` and `neutral_h_damping_cm3_s` for rate coefficients at 10,000 K. The optional `electron_damping_exponent` and `neutral_h_damping_exponent` multiply those coefficients by a power of `T / 10,000 K`. GiantLayers multiplies each coefficient by its local perturber number density and adds the three rates before computing the line profile. Missing coefficients and exponents default to zero. Convert logarithmic coefficients to linear units when preparing the CSV.
180
+
181
+ Convert a Kurucz wavelength-format GFALL or per-ion `.pos` list with `python3 -m kurucz_atomic_lines gf2600.pos --wavelength-nm 400 700 > iron.csv`. The converter accepts neutral and singly ionized atoms and uses the rates supplied in the line records. It assumes temperature-independent electron coefficients and a neutral H exponent of 0.3 for this conversion. Use `--vacuum` for a list supplied entirely in vacuum or `--doppler-only` for a coverage-only comparison. When combining line lists, replace overlapping transitions to avoid counting them twice.
182
+
183
+ Use a spherical model and the same opacity inputs to compare surface transfer in both geometries. Pass several `--molecular-cross-section` options to include multiple absorbers. The spherical solver traces rays through atmospheric shells and integrates the emergent intensity over the apparent disk. The plane-parallel case uses the same surface angles and quadrature weights. Both modes use LTE true absorption and fixed temperatures and gas pressures for this benchmark.
184
+
185
+ ```sh
186
+ python -m giantlayers.spherical_transfer model.mod.gz revised-atomic-lines.csv mixture.json flx_wavelengths.vac.gz --stride 50 --core-rays 24 --molecular-cross-section tio.json.gz > spherical-comparison.csv
187
+ ```
188
+
189
+ The CSV contains monochromatic surface fluxes per Hz and frequency weights. The printed spherical ratio normalizes the flux to the MARCS reference radius. The planar ratio uses the corresponding target flux at the outer boundary. Reduce `--stride` and increase `--core-rays` to test sensitivity to the wavelength and ray grids.
190
+
191
+ ### Compute spherical heating with scattering
192
+
193
+ Use the same spherical model and opacity inputs with the depth-resolved solver. It iterates the isotropic coherent continuum scattering source on the shared impact-parameter rays. Net heating is calculated from true absorption and the difference between the mean intensity and the LTE Planck function. Use `--absorption-only` to isolate the effect of scattering.
194
+
195
+ ```sh
196
+ python -m giantlayers.spherical_heating model.mod.gz revised-atomic-lines.csv mixture.json flx_wavelengths.vac.gz --stride 100 --core-rays 24 --molecular-cross-section tio.json.gz > spherical-heating.csv
197
+ ```
198
+
199
+ The CSV reports integrated radiative flux, luminosity, and pointwise true-absorption heating at each layer. The shell columns give the mean net heating and energy gain between the current layer and the next deeper layer, calculated from the luminosity difference and shell mass. Positive heating means the gas gains energy. The shell values balance the luminosity change by construction. Standard error reports how far a separate trapezoidal integration of the pointwise rates departs from that budget. Use that difference to assess whether pointwise heating is suitable for a temperature update. The MARCS temperature, pressure, and convection profiles are held fixed.
200
+
201
+ ### Try spherical temperature corrections
202
+
203
+ Add `--adjust-layers 3 --steps 2` to the spherical heating command to try two damped temperature corrections in the outer three layers. Each trial recomputes LTE chemistry, opacities, and spherical scattering. The correction uses finite differences to reduce the change in radiative plus convective luminosity across the selected shells. The deeper temperature profile, radii, gas pressure and published MARCS convective contribution stay fixed.
204
+
205
+ The solver reports the maximum outer-shell luminosity residual and the surface total-flux error separately. The correction targets local shell balance. Fitting the absolute emergent flux requires a separate constraint. The CSV includes the initial and corrected temperature.
206
+
207
+ ### Fit the absolute luminosity and check the full wavelength grid
208
+
209
+ Add `--luminosity-target` to fit the MARCS surface luminosity alongside the outer-shell luminosity differences. The correction adds one smooth temperature mode centered at Rosseland optical depth one. It tapers to zero at log optical depths −1.5 and +1.5. Gas pressure, radii, and the reference convective flux stay fixed.
210
+
211
+ With a coarse startup stride, `--verify-full` reevaluates the accepted profile on every input wavelength and writes the full-grid diagnostics. The verification holds the accepted temperatures fixed. For larger runs, the optional C99 kernel accelerates the ray solve while chemistry and opacity remain in Python.
212
+
213
+ The main `giantlayers` command automatically uses the C kernel when installed from a binary wheel. The commands below compile a custom library from a source checkout for the heating diagnostic, which takes an explicit `--kernel` path.
214
+
215
+ ```sh
216
+ cc -O3 -std=c99 -shared -fPIC src/giantlayers/spherical_kernel.c -o spherical_kernel.so -lm
217
+ python -m giantlayers.spherical_heating model.mod.gz revised-atomic-lines.csv mixture.json flx_wavelengths.vac.gz --stride 400 --adjust-layers 3 --steps 5 --luminosity-target --verify-full --kernel ./spherical_kernel.so --molecular-cross-section tio.json.gz > luminosity-check.csv
218
+ ```
219
+
220
+ ### Solve pressure and radius on a fixed temperature profile
221
+
222
+ Run the spherical hydrostatic benchmark on a MARCS reference model.
223
+
224
+ ```sh
225
+ python -m giantlayers.spherical_hydrostatic model.mod.gz > hydrostatic.csv
226
+ ```
227
+
228
+ The benchmark takes the temperature, composition, and outer gas pressure from MARCS. It integrates the published density over radial distance to define a comparison column-mass grid. GiantLayers then computes its own gas pressure, density, and radius at each depth using spherical gravity and its native LTE equation of state. The reference radius is set by the input mass and gravity at the layer with Rosseland optical depth one. This version solves gas-pressure balance. Radiation and turbulent pressure are outside that equation.
229
+
230
+ The Python `solve` function also accepts a radial column-mass grid and boundary values supplied independently of MARCS.
231
+
232
+ ### Compare transfer after hydrostatic reconstruction
233
+
234
+ Add `--hydrostatic` to the spherical heating command to rebuild pressure, electron pressure, density, and radii before evaluating transfer. The reconstruction and transfer use the same input abundance pattern. The temperatures and reference convective fractions stay fixed. Run the command with and without the option using identical wavelength, line, and cross-section inputs to isolate the effect of hydrostatic reconstruction.
235
+
236
+ The reconstructed CSV reports radial column mass measured from the upper boundary. The original comparison reports the model's published column mass. Match rows by layer index. The reconstructed radius at Rosseland depth one follows the input mass and gravity, so its reference luminosity normalization uses that radius.
237
+
238
+ ### Couple the hydrostatic and temperature updates
239
+
240
+ Combine `--hydrostatic` with `--adjust-layers` to solve hydrostatic balance before each temperature trial, including the finite-difference perturbations and the line-search evaluations. The original radial mass grid, surface gas pressure, stellar mass, and gravity define the boundary throughout the run. Each trial recomputes pressure, electron pressure, density, radius, opacities, and scattering. With `--luminosity-target`, it also fits the target at the reconstructed reference radius.
241
+
242
+ ```sh
243
+ python -m giantlayers.spherical_heating model.mod.gz revised-atomic-lines.csv mixture.json flx_wavelengths.vac.gz --hydrostatic --adjust-layers 3 --steps 2 --luminosity-target --stride 400 --molecular-cross-section tio.json.gz > coupled-trial.csv
244
+ ```
245
+
246
+ The output includes the updated temperatures and hydrostatic structure. The Rosseland layer labels and convective luminosity fractions are carried over from MARCS for this benchmark.
247
+
248
+ ### Calculate mixing-length convection
249
+
250
+ Run the Henyey mixing-length calculation on the fiducial pressure and temperature profile. GiantLayers computes the logarithmic temperature gradient, estimates the heat capacity and thermal expansion from its native LTE chemistry, and reports the convective velocity and flux beside the MARCS values. The default benchmark uses the published MARCS Rosseland opacities to isolate the convection calculation. [MARCS mixing-length equations](https://arxiv.org/abs/0805.0554)
251
+
252
+ ```sh
253
+ python -m giantlayers.mixing_length model.mod.gz > convection.csv
254
+ ```
255
+
256
+ Pass `--wavelengths flx_wavelengths.vac.gz` to compute the Rosseland mean from GiantLayers opacities. Add the atomic transition list with `--lines` and molecular tables with repeatable `--molecular-cross-section` arguments. Use `--hydrostatic` to evaluate convection on the reconstructed pressure and radius profile. These commands diagnose convection on a fixed temperature structure.
257
+
258
+ ### Recompute convection during the coupled solve
259
+
260
+ Add `--native-convection` to use the Henyey flux in place of the benchmark's published convection. Each trial computes a Rosseland mean from the same line and continuum opacities used by spherical transfer. It then recomputes the convective flux from the trial temperature and gas pressure gradients and the native LTE equation of state.
261
+
262
+ ```sh
263
+ python -m giantlayers.spherical_heating model.mod.gz revised-atomic-lines.csv mixture.json flx_wavelengths.vac.gz --hydrostatic --native-convection --adjust-layers 3 --adjust-deep 2 --steps 1 --luminosity-target --stride 400 --molecular-cross-section tio.json.gz > coupled-convection.csv
264
+ ```
265
+
266
+ The outer temperature variables target adjacent-shell luminosity balance. The photospheric mode targets absolute surface luminosity, and `--adjust-deep` varies the deepest temperatures individually to target total luminosity at those layers. The solver reports these errors separately. This trial adjusts selected depths and retains the original radial mass grid and outer pressure.
267
+
268
+
269
+ ### Fit the total luminosity at every layer
270
+
271
+ Use `--global-balance` to solve for the temperature profile with native spherical transfer, hydrostatic balance, and Henyey mixing-length convection. The target is the same total luminosity at every radius. Each trial recomputes the gas structure, chemistry, wavelength-dependent opacities, and radiative and convective fluxes on the input model's radial mass grid. The input mass, gravity, and surface gas pressure set the boundaries.
272
+
273
+ GiantLayers identifies the contiguous region extending inward to the model's deepest layer where convection carries at least 0.01% of the target luminosity. Each layer in that region gets its own temperature variable. Above it, fractional temperature corrections are interpolated in the input model's log Rosseland depth between five control points by default. Change that number with `--upper-knots`. The solver evaluates the total luminosity error at every layer. Its line search accepts a step when the RMS error plus one quarter of the maximum absolute error decreases.
274
+
275
+ ```sh
276
+ python -m giantlayers.spherical_heating model.mod.gz revised-atomic-lines.csv mixture.json flx_wavelengths.vac.gz --global-balance --stride 400 --core-rays 24 --steps 1 --kernel ./spherical_kernel.so --molecular-cross-section tio.json.gz > global-luminosity.csv
277
+ ```
278
+
279
+ The CSV contains the corrected structure and the relative total-flux error at every layer. Increase `--steps` to attempt additional corrections. For a wavelength-resolution check, add `--verify-full` to reevaluate the resulting profile across the full input wavelength grid.
280
+
281
+ ### Start from stellar parameters
282
+
283
+ From a repository checkout, install with `python3 -m pip install .`. The `giantlayers` command takes a vacuum wavelength grid in Å and a JSON mapping from element symbols to absolute logarithmic abundances. For an element X, the abundance is log10(N_X/N_H) + 12. Include hydrogen as `"H": 12`. Edit a copy of `src/giantlayers/examples/solar-gs98.json` to set the abundances of your star. The example is the solar mixture tabulated in the GS98 MARCS grid; omitted elements are initialized to the trace abundance sentinel. [MARCS model grids](https://marcs.astro.uu.se/)
284
+
285
+ ```sh
286
+ giantlayers src/giantlayers/examples/continuum-wavelengths.dat src/giantlayers/examples/solar-gs98.json \
287
+ --teff 3500 --logg 1 --mass 1 --layers 12 --upper-knots 4 \
288
+ --steps 1 --output-model trial.mod > trial.csv
289
+ ```
290
+
291
+ The continuum-only example starts from an analytic gray temperature profile and an independent radial column-mass grid. Pass the published MARCS wavelength grid, an atomic transition CSV via `--lines`, and molecular tables via `--molecular-cross-section` for opacity sampling. The compiled kernel is especially helpful as the grid grows. `--stride` subsamples the supplied grid and `--verify-full` reevaluates the result on every input wavelength. Convergence is assessed against the maximum fractional luminosity error, with a default threshold of 1%. Use `--require-flux-convergence` in batch jobs to return status 2 when the final profile exceeds that threshold. Use repeatable `--refine-stride` options to solve sequentially on denser grids. `--steps` is the correction budget per grid. For long runs, `--checkpoint-csv` saves the accepted profile at each step. Use `--restart-csv` with the same mass-grid parameters to resume and `--steps 0` to evaluate the profile without temperature corrections.
292
+
293
+ Use the experimental `--heating-transition-tau 0.01` option to fit local radiative balance at shallower Rosseland depths and total luminosity deeper down. This option replaces `--outer-heating-weight` and retains a surface luminosity constraint. The partition is set at the start of each fitting stage. The final report gives both the luminosity error and the peak normalized heating over the final optically thin layers. With a 100,724-point input grid, `--stride 120 --refine-stride 12 --full-grid-correction` uses about 840 and 8,400 points for successive temperature fits and verifies the result on the full grid. Add a final `--refine-stride 1` to fit on the full grid when that compute cost is practical. [MARCS energy-balance methods](https://www.aanda.org/articles/aa/pdf/2008/30/aa09724-08.pdf)
294
+
295
+ The MARCS-format export contains native thermochemical partial pressures, Rosseland and 5000 Å optical depth, convection, and the calculated gas structure. By default the radius is anchored at the fixed mass coordinate selected from the seed. Use `--photospheric-anchor` to update the reference radius coordinate to the computed Rosseland photosphere. The export uses an isotropic LTE estimate for radiation pressure and zero turbulent pressure. The H₂⁺ column uses the absent-species sentinel, and the Other column sums the unlisted supported molecules. Files with large residuals are labeled unconverged.
296
+
297
+ Use `--output-atlas trial.dat` to export the same solution as an ATLAS9 `READ DECK6` atmosphere. Use a `.gz` suffix for gzip compression. You can request both formats in one run.
298
+
299
+ ```sh
300
+ giantlayers src/giantlayers/examples/continuum-wavelengths.dat src/giantlayers/examples/solar-gs98.json \
301
+ --teff 3500 --logg 1 --mass 1 --steps 1 \
302
+ --output-model trial.mod --output-atlas trial.dat.gz > trial.csv
303
+ ```
304
+
305
+ The ATLAS export includes the input abundance mixture and all native depth points. The title identifies the spherical solution and its luminosity convergence status. The deck stores column mass and omits shell radii. Consumers that require a plane-parallel atmosphere or exactly 72 layers need to account for those assumptions. The `PRADK` field estimates surface radiation pressure from the emergent radiative flux assuming isotropic intensity over the outgoing hemisphere. [Published ATLAS9 grid files](https://wwwuser.oats.inaf.it/fiorella.castelli/grids/gridp00k2odfnew/ap00k2tab.html)
306
+
307
+ Use `--output-atlas trial.dat --atlas-format atlas12` for the Castelli ATLAS12 punch layout. It uses the same `READ DECK6` depth convention with nine columns and includes a separate `ABUNDANCE TABLE` with the model's uniform mixture. The reference ATLAS12 reader supports at most 72 depth points. Give ATLAS12 the uncompressed file with `READ PUNCH`. The export describes the GiantLayers atmosphere and retains its native depth grid. [ATLAS12 source and input examples](https://wwwuser.oats.inaf.it/fiorella.castelli/sources/atlas12.html)
308
+
309
+ Use the reference atmosphere runs above to benchmark differences from MARCS. The experimental solver uses a limited species and opacity set and a prescribed radial column-mass grid. Inspect sensitivity to the chosen outer pressure, bottom mass, and transfer grids before using the result quantitatively.
310
+
311
+
312
+ ### Diagnose radiative equilibrium in the outer layers
313
+
314
+ The native CSV includes the Rosseland mean and the ratio of net radiative heating to LTE thermal emission at each layer. An optically thin layer can have substantial local heating while barely changing the total luminosity. Set `--outer-heating-weight 0.1` to include that local balance in the trial objective. The weight falls exponentially with the initial Rosseland depth on a scale of 0.03. The luminosity status printed by the command is based on total flux. Check the heating column as well when fitting both terms.
315
+
316
+ The continuum includes coherent electron scattering and Rayleigh scattering by H I, H₂, and He I. The Rayleigh terms use long-wavelength expansions on the red side of the first resonance. The transfer solves those opacities with an isotropic coherent source. When accelerated scattering iterations reach their budget, GiantLayers solves the linear source equation directly. [H I cross section](https://adsabs.harvard.edu/pdf/1964ApJ...140.1381S) · [H₂ cross section](https://adsabs.harvard.edu/pdf/1962apj...136..690d) · [He I cross section](https://arxiv.org/abs/1601.01005)
317
+
318
+ ### Convert ExoMolOP opacity tables
319
+
320
+ Download a TauREx HDF5 cross-section table for the desired isotopologue and convert it into the JSON format used by the solver. The optional h5py dependency is used by the converter. The transfer command reads the resulting table using Python's standard library.
321
+
322
+ ```sh
323
+ python3 -m pip install '.[exomol]'
324
+ python3 -m exomol_import TiO.xsec.TauREx.h5 tio.json.gz --species TiO \
325
+ --isotope-fraction 0.7372 --temperature-range 2200 3400 --pressure-range 10 10000
326
+ ```
327
+
328
+ The output keeps the native wavelength samples in increasing vacuum Å and converts pressure from bar to dyn/cm². The temperature and pressure ranges select tabulated points inclusively. Each selected axis needs at least two points. The solver clamps values outside the supplied temperature and pressure range. Provide tables that cover the line-forming layers and include the contributing isotopologues for your mixture. [ExoMolOP data and formats](https://arxiv.org/abs/2009.00687)
329
+
330
+
331
+ ### Update the spherical hydrostatic boundary
332
+
333
+ With `--photospheric-anchor`, GiantLayers integrates the native Rosseland opacity through the radial column mass and locates optical depth one between layers. The solver sets the gravity specified by `--logg` at that interpolated radius. The grid must bracket the photosphere.
334
+
335
+ The native CSV also contains the radiative acceleration from the frequency integral of flux times mass extinction divided by the speed of light. With `--radiative-force`, GiantLayers subtracts that acceleration from gravity when it updates gas pressure and the mixing-length pressure scale. The solver requires positive effective gravity on the mass grid. By default, the acceleration is reported and hydrostatic balance uses gravity alone.
336
+
337
+ The optional boundary updates use the latest solved profile between wavelength stages. After the final wavelength stage, GiantLayers iterates the boundary and hydrostatic structure at fixed temperature and reports the resulting luminosity error.
338
+
339
+ ### Check depth resolution and compare with a reference
340
+
341
+ Use `--restart-csv` with `--interpolate-restart` to move a solved temperature profile to a different number of layers. The previous mass grid must cover the new one. GiantLayers recomputes the gas structure and transfer on the new grid. The solver reports how many final layers used molecular cross sections clamped to the edge of their temperature or pressure axes.
342
+
343
+ Compare the exported model with a published model at the same stellar parameters. The comparison interpolates only over the shared Rosseland depth range and reports the temperature difference in kelvin and the pressure differences in dex.
344
+
345
+ ```sh
346
+ python3 -m compare_atmospheres published.mod.gz trial.mod.gz > structure-comparison.csv
347
+ ```
348
+
349
+ ### Carbon-rich mixtures
350
+
351
+ Change the carbon abundance in the input JSON to set C/O. The native LTE equation of state includes CO, CN, C₂, HCN, and acetylene. HCN and acetylene use NASA Glenn Gibbs energies for the dissociation equilibrium and ExoMol partition functions for explicit line strengths. The tabulated dissociation constants cover 1,000–6,000 K. Above the available partition-function temperatures (4,000 K for HCN and 5,000 K for acetylene), the line-strength partition function uses the closest tabulated value. [NASA Glenn thermochemistry](https://ntrs.nasa.gov/citations/20020085330) · [HCN partition function](https://exomol.com/data/data-types/opacity/HCN/1H-12C-14N/Harris/) · [Acetylene line list](https://academic.oup.com/mnras/article/493/2/1531/5716685)
352
+
353
+ To include carbon-bearing molecular absorption, convert the published CN and C₂ cross sections and add them with `--molecular-cross-section`. The abundance inputs independently set the molecular number densities used to convert the cross sections to mass opacity. [CN MoLLIST](https://www.exomol.com/data/data-types/linelist/CN/12C-14N/MoLLIST-CN/) · [C₂ 8states](https://exomol.com/data/data-types/opacity/C2/12C2/8states/)
354
+
355
+ Use `--adaptive-knots 4` to allow up to four additional temperature controls at layers with large luminosity residuals during each stage. `--peak-error-weight` changes the weight assigned to the maximum residual in the acceptance criterion. The final CSV records the luminosity error of every layer.
356
+
357
+ For mixtures that strongly change the line blanketing, start with reduced line opacity using `--opacity-ramp 0.1 0.5`. GiantLayers solves on the startup wavelength grid at each supplied fraction, then at full line opacity. The continuum and LTE chemistry are evaluated throughout. The optional finer wavelength stages use full opacity.
358
+
359
+ Use `--workers 4` to distribute finite-difference temperature perturbations among processes. For a fixed-profile `--steps 0` or `--verify-full` evaluation, the processes integrate separate wavelength bands and combine the flux, Rosseland moments, and radiative acceleration. Spectrum output uses a serial sweep.
360
+
361
+ Use `--full-grid-correction` to calibrate the last sampled stage against a transfer on the complete input grid. The solver holds the initial difference between the sampled and full-grid luminosity residuals fixed while it computes temperature corrections on the sampled grid. The command then recomputes the final luminosity on the full grid and reports the measured residual.
362
+
363
+ ### Export the emergent spectrum
364
+
365
+ Pass `--output-spectrum spectrum.csv` to evaluate the final atmosphere and write the outgoing surface flux on the final wavelength grid. The spectrum reports flux per Hz and per Å at the model's reference radius, plus the integration weight of each sample. Summing flux per Hz times its weight recovers the integrated radiative surface flux at the reference radius.
366
+
367
+ ### Add hydrogen and helium collision-induced absorption
368
+
369
+ Download the rectangular H₂–H₂, H₂–He, H₂–H, and He–H files from HITRAN and pass each selected pair with `--cia FILE.cia`. The reader also accepts gzip-compressed tables. It interpolates in temperature and wavenumber, then multiplies the coefficient by the two LTE species number densities and divides by mass density. CIA is continuum absorption and retains its full weight during an opacity ramp. Temperature outside a table's axis uses the nearest tabulated value. Wavenumbers outside the tabulated range contribute zero. [HITRAN CIA files](https://hitran.org/cia/) · [Format and reference data](https://hitran.org/data/CIA/CIA_Readme_2024.pdf)
370
+
371
+
372
+ ### Use the solver from Python
373
+
374
+ ```python
375
+ import json
376
+ from giantlayers import initialize
377
+ from giantlayers.native_transfer import read_wavelengths
378
+ from giantlayers.spherical_heating import balance_all_layers
379
+
380
+ with open("src/giantlayers/examples/solar-gs98.json") as stream:
381
+ abundances = json.load(stream)
382
+ seed, boundary = initialize(3500, 1, 1, abundances, layers=12)
383
+ wavelengths = read_wavelengths("src/giantlayers/examples/continuum-wavelengths.dat")
384
+ model, diagnostics, history, knots, convective_start = balance_all_layers(
385
+ seed, wavelengths, (), {}, boundary=boundary, core_rays=12, steps=1
386
+ )
387
+ ```
388
+
389
+ This example makes one correction with continuum extinction. Pass loaded atomic transitions through the third argument and loaded molecular tables through `tables`. When supplying your own initial seed and boundary, use the same abundance mixture in the structure and opacity calculations.
@@ -0,0 +1 @@
1
+ mkdocs==1.6.1
@@ -0,0 +1,23 @@
1
+ # Spherical LTE atmosphere model
2
+
3
+ GiantLayers begins with an analytic gray temperature profile on a radial column-mass grid. Its inputs are effective temperature, surface gravity, stellar mass, a chemical abundance mixture, and opacity data. A reference radius follows from R = √(GM/g). The optional photospheric update locates this radius at Rosseland optical depth one.
4
+
5
+ ## Hydrostatic structure and chemistry
6
+
7
+ The radial column mass increases inward. GiantLayers integrates the gas-pressure gradient dP/dm = GM/r² − g_rad and the depth gradient dr/dm = −1/ρ. The outer gas pressure is a boundary input. Set `--radiative-force` to update g_rad from the calculated radiation field. The pressure solution requires positive effective gravity.
8
+
9
+ LTE chemistry enforces each element's abundance, charge neutrality, and the ideal-gas particle pressure. The network uses neutral and singly ionized atoms, H⁻, and supported molecules. Partition functions and equilibrium constants determine the species populations. Those populations set the electron pressure, mass density, molecular absorption, and relevant thermodynamic derivatives. [Atomic and diatomic data](https://doi.org/10.1051/0004-6361/201526961) · [NASA Glenn polyatomic equilibrium](https://ntrs.nasa.gov/citations/20020085330)
10
+
11
+ ## Transfer, convection, and luminosity balance
12
+
13
+ The transfer sweeps incoming and outgoing rays on their spherical impact parameters. The outer boundary has zero incident radiation. A smooth transition from a thermal inner boundary to diffusion uses the optical thickness of each ray. The solver uses LTE emissivity, isotropic coherent scattering, and a linear source function in each ray segment.
14
+
15
+ Atomic transitions, molecular cross sections, and continuum extinction are evaluated at each supplied wavelength. The continuum includes hydrogen absorption, electron–ion free-free absorption, electron and Rayleigh scattering, and optional collision-induced absorption. The same transfer calculates the Rosseland mean for Henyey mixing-length convection. [MARCS methods and convection](https://arxiv.org/abs/0805.0554)
16
+
17
+ The temperature solver targets L = 4πr²(F_rad + F_conv) = 4πR²σT_eff⁴ at each layer. It perturbs the temperatures at selected depths, recomputes the hydrostatic and radiation solutions, and updates the temperatures from the response of the luminosity residuals. An optional normalized heating constraint supplies information about optically thin layers where luminosity varies little with local temperature. Temperature corrections are bounded and tested before acceptance.
18
+
19
+ ## Interpreting a result
20
+
21
+ Use the CSV maximum luminosity residual to check convergence at every layer. Surface flux, agreement with a published temperature profile, and a low RMS residual each provide different information. Compare the same model on finer wavelength and depth grids and inspect the molecular table coverage report.
22
+
23
+ The scientific scope is static, dust-free atmospheres in LTE. The result depends on the supplied opacity inventory and on the pressure and mass endpoints. The MARCS-format export includes an isotropic LTE estimate of radiation pressure and uses zero turbulent pressure. See the [Quickstart](quickstart.md) for the benchmark and export commands.