Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/io/configuration/components/plasma.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,41 @@ The NLTE configuration currently allows setting ``coronal_approximation``, which
This is useful for debugging with :term:`chianti` for example. Furthermore, one can enable 'classical_nebular' to set all
:math:`\beta_\textrm{Sobolev}` to 1. Both options are used for checking with other codes and should not be enabled in
normal operations.

Type IIP macro-atom reduction
--------------------------------

The ``plasma.continuum_interaction.markov_chain`` section controls how Type IIP
transport samples internal macro-atom transitions. Existing configurations use
``mode: full``, which reduces the whole chain. ``mode: explicit`` samples every
original transition and provides a reference for comparisons. Both modes require
an empty ``elements`` list.

Use ``mode: partial`` with one or more element symbols to reduce internal jumps
between selected atomic states:

.. code-block:: yaml

plasma:
continuum_interaction:
species: [H I]
markov_chain:
mode: partial
elements: [H]
include_thermal_pool: true
include_ionization_pool: false

For a multi-element selection, use ``elements: [H, He, Fe]`` when those elements
are present in the assembled network. Duplicate symbols are harmless. A symbol
selects all represented ions and levels of that element. This list is independent
of continuum ``species`` and ``nlte.species``: selecting an element does not
enable additional continuum processes or change its equilibrium treatment.

Both pool options default to ``false``. Set ``include_thermal_pool: true`` to
include the shared thermal state, ``include_ionization_pool: true`` to include
the shared ionization state, or enable both. Internal transitions between any
selected states are then collapsed, including paths through the enabled pools.
Pool emission/cooling and jumps to unselected states remain explicit exit
channels. These options require ``mode: partial``; full mode already includes
both pools, and explicit mode reduces neither.
See :doc:`../../../physics_walkthrough/montecarlo/partial_absorbing_chain` for more.
3 changes: 2 additions & 1 deletion docs/physics_walkthrough/montecarlo/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ can also be found in various papers by L. Lucy and in the main TARDIS publicatio
initialization
propagation
lineinteraction
estimators
estimators
partial_absorbing_chain
61 changes: 61 additions & 0 deletions docs/physics_walkthrough/montecarlo/partial_absorbing_chain.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Element-selected absorbing chains
=================================

Type IIP transport can skip internal macro-atom jumps while preserving the
probabilities of eventual emission and cooling. In partial mode, let S contain
all represented real atomic levels of the requested elements. Only internal
edges with both endpoints in S are eliminated. For example, this would be
jumping over internal transitions that happen in a specified element.
The shared ionization (i) and thermal (k) pools stay outside S by default.
The independent ``include_ionization_pool`` and ``include_thermal_pool`` options
add their respective pool states to S in partial mode. Either pool or both can
be included without selecting additional atomic elements.

For each cell, Q contains the eliminated transition probabilities, L contains
the original probabilities with just those edges removed, and r is the sum of
each selected state's remaining outgoing channels. The first-exit matrix B and
conditional channel probabilities C satisfy

.. math::

(I-Q)B = \operatorname{diag}(r), \qquad
C_{j,c} = L_{j,c}/r_j, \qquad
(I-Q)^{-1} L = BC.

Rows of B are activation states; columns identify exit-source states.
A draw from B selects the global source of the
next retained channel, followed by an independent draw from C. A retained
internal transition continues the interaction; only a negative transition code
ends it. Each return to S starts a fresh, independent pair of draws. Outside S,
transport samples the original channel probabilities directly.

With k included, selected-atom to k to selected-atom paths are collapsed inside
the matrix. With i included, the analogous ionization/recombination paths are
collapsed. If both are included, internal transfers between the pools also enter
Q. A pool can be the exit-source state selected by B: emission and cooling from
it are retained channels, as are jumps to unselected atoms or an excluded pool.
Those exits are sampled explicitly. Direct activation at an included pool uses
its reduced row; activation at an excluded pool uses its original channels.

Shared pools couple the selected elements into one reduction. The final emission
distribution is preserved, but the explicit history of visits to included pools
is removed.

Emission-only states and global level zero are included. Explicit int64 forward
and inverse maps preserve global identities, including gaps in the level
indices. A zero residual row stays zero and cannot supply an exit. Metadata
and numerical probabilities are rebuilt consistently on every opacity solve;
continuum activation indices and estimator dimensions keep their original
ordering and shell count.

Before recalculating the matrix, the workflow releases the previous iteration's
matrix references from both the macro-atom state and the Numba transport state.

The reduction uses an ordinary sparse LU solve without numerical acceptance
or reachability checks. Input coefficients and reduced entries are not rejected
based on their sign in any reduction mode. Sparse factorization failures
propagate from the solver. Channels are never removed by a numerical probability
threshold. The sampler allows a CDF endpoint
deficit of at most 1e-10 due to floating-point summation; larger deficits or
activations without outgoing probability raise an error.

24 changes: 24 additions & 0 deletions tardis/io/configuration/schemas/plasma.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,30 @@ properties:
default: {}
additionalProperties: false
properties:
markov_chain:
type: object
default: {}
additionalProperties: false
properties:
mode:
type: string
enum: [full, partial, explicit]
default: full
description: Macro-atom internal-transition reduction for Type IIP transport.
elements:
type: array
items:
type: string
default: []
description: Element symbols reduced in partial mode; empty in other modes.
include_thermal_pool:
type: boolean
default: false
description: Include the shared thermal k state in partial reduction.
include_ionization_pool:
type: boolean
default: false
description: Include the shared ionization i state in partial reduction.
nthreads:
type: integer
minimum: 1
Expand Down
2 changes: 2 additions & 0 deletions tardis/opacities/continuum/continuum_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ def to_numba(
photo_ion_activation_idx,
np.int64(macro_atom_state.k_packet_idx),
macro_atom_state.absorbing_probability_matrix,
macro_atom_state.macro_level_to_reduced_idx,
macro_atom_state.reduced_to_macro_level_idx,
)

@property
Expand Down
7 changes: 6 additions & 1 deletion tardis/opacities/continuum/continuum_state_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class ContinuumOpacityStateNumba:
photo_ion_activation_idx: nb.int64[:]
k_packet_idx: nb.int64
absorbing_markov_probabilities: nb.float64[:, :, :]
macro_level_to_reduced_idx: nb.int64[:]
reduced_to_macro_level_idx: nb.int64[:]

def __init__(
self,
Expand All @@ -37,6 +39,8 @@ def __init__(
photo_ion_activation_idx: npt.NDArray[np.int64],
k_packet_idx: int,
absorbing_markov_probabilities: npt.NDArray[np.float64],
macro_level_to_reduced_idx: npt.NDArray[np.int64],
reduced_to_macro_level_idx: npt.NDArray[np.int64],
) -> None:
self.bf_threshold_list_nu = bf_threshold_list_nu
self.p_fb_deactivation = p_fb_deactivation
Expand All @@ -51,4 +55,5 @@ def __init__(
self.photo_ion_activation_idx = photo_ion_activation_idx
self.k_packet_idx = k_packet_idx
self.absorbing_markov_probabilities = absorbing_markov_probabilities

self.macro_level_to_reduced_idx = macro_level_to_reduced_idx
self.reduced_to_macro_level_idx = reduced_to_macro_level_idx
Loading
Loading