Skip to content

aragog.mesh

mesh

Mesh

FloatOrArray = float | npt.NDArray module-attribute

logger = logging.getLogger(__name__) module-attribute

AdamsWilliamsonEOS(settings, basic_radii)

Bases: EOS

Adams-Williamson equation of state (EOS).

EOS due to adiabatic self-compression from the definition of the adiabatic bulk modulus:

\[ \left( \frac{{d\rho}}{{dP}} \right)_S = \frac{{\rho}}{{K_S}} \]

where \(\rho\) is density, \(K_S\) the adiabatic bulk modulus, and \(S\) is entropy.

Source code in aragog/mesh.py
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
def __init__(
    self,
    settings: _MeshParameters,
    basic_radii: npt.NDArray,
):
    self._settings: _MeshParameters = settings
    self._basic_radii: npt.NDArray = basic_radii
    self._outer_boundary = np.max(basic_radii)
    self._inner_boundary = np.min(basic_radii)
    self._surface_density: float = self._settings.surface_density
    self._gravitational_acceleration: float = self._settings.gravitational_acceleration
    self._adiabatic_bulk_modulus: float = self._settings.adiabatic_bulk_modulus
    self._basic_pressure = self.get_pressure_from_radii(basic_radii)
    self._basic_density = self.get_density_from_radii(basic_radii)
    self._staggered_effective_density = self.get_effective_density(basic_radii)

basic_density property

Density at basic nodes

basic_pressure property

Pressure at basic nodes

staggered_effective_density property

Effective density at staggered nodes

staggered_pressure property

Pressure at staggered nodes

get_density(pressure)

Computes density from pressure:

\[ \rho(P) = \rho_s \exp(P/K_S) \]

where \(\rho\) is density, \(P\) is pressure, \(\rho_s\) is surface density, and \(K_S\) is adiabatic bulk modulus.

Args: pressure: Pressure

Returns: Density

Source code in aragog/mesh.py
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
def get_density(self, pressure: FloatOrArray) -> npt.NDArray:
    r"""Computes density from pressure:

    $$
    \rho(P) = \rho_s \exp(P/K_S)
    $$

    where $\rho$ is density, $P$ is pressure, $\rho_s$ is surface density,
    and $K_S$ is adiabatic bulk modulus.

    Args:
        pressure: Pressure

    Returns:
        Density
    """
    density: npt.NDArray = self._surface_density * np.exp(
        pressure / self._adiabatic_bulk_modulus
    )

    return density

get_density_from_radii(radii)

Computes density from radii:

$$ \rho(r) = \frac{\rho_s K_S}{K_S + \rho_s g (r-r_s)} $$ where \(\rho\) is density, \(r\) is radius, \(\rho_s\) is surface density, \(K_S\) is adiabatic bulk modulus, and \(r_s\) is surface radius.

Args: radii: Radii

Returns Density

Source code in aragog/mesh.py
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
def get_density_from_radii(self, radii: FloatOrArray) -> FloatOrArray:
    r"""Computes density from radii:

    $$
        \rho(r) = \frac{\rho_s K_S}{K_S + \rho_s g (r-r_s)}
    $$
    where $\rho$ is density, $r$ is radius, $\rho_s$ is surface density,
    $K_S$ is adiabatic bulk modulus, and $r_s$ is surface radius.

    Args:
        radii: Radii

    Returns
        Density
    """
    density: FloatOrArray = (self._surface_density * self._adiabatic_bulk_modulus) / (
        self._adiabatic_bulk_modulus
        + self._surface_density
        * self._gravitational_acceleration
        * (radii - self._outer_boundary)
    )

    return density

get_effective_density(radii)

Computes effective density using density rho(r) integration over a spherical shell bounded by radii

Args: radii: Radii array

Returns: Effective Density array

Source code in aragog/mesh.py
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
def get_effective_density(self, radii) -> npt.NDArray:
    r"""
    Computes effective density using density rho(r) integration
    over a spherical shell bounded by radii

    Args:
        radii: Radii array

    Returns:
        Effective Density array
    """

    mass_shell = self.get_mass_within_shell(radii)
    volume_shell = 4 / 3 * np.pi  \
        * (np.power(radii[1:],3.0) - np.power(radii[:-1],3.0))

    return mass_shell/volume_shell

get_mass_element(radii)

Computes the mass element:

\[ \frac{\delta m}{\delta r} = 4 \pi r^2 \rho \]

where \(\delta m\) is the mass element, \(r\) is radius, and \(\rho\) is density.

Args: radii: Radii

Returns: The mass element at radii

Source code in aragog/mesh.py
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
def get_mass_element(self, radii: FloatOrArray) -> npt.NDArray:
    r"""Computes the mass element:

    $$
    \frac{\delta m}{\delta r} = 4 \pi r^2 \rho
    $$

    where $\delta m$ is the mass element, $r$ is radius, and $\rho$ is
    density.

    Args:
        radii: Radii

    Returns:
        The mass element at radii
    """
    mass_element: npt.NDArray = (
        4 * np.pi * np.square(radii) * self.get_density_from_radii(radii)
    )

    return mass_element

get_mass_within_radii(radii)

Computes mass within radii:

$$ m(r) = \int 4 \pi r^2 \rho dr $$ where \(m\) is mass, \(r\) is radius, and \(\rho\) is density.

The integral was evaluated using WolframAlpha.

Args: radii: Radii

Returns: Mass within radii

Source code in aragog/mesh.py
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
def get_mass_within_radii(self, radii: FloatOrArray) -> npt.NDArray:
    r"""Computes mass within radii:

    $$
    m(r) = \int 4 \pi r^2 \rho dr
    $$ 
    where $m$ is mass, $r$ is radius, and $\rho$ is density.

    The integral was evaluated using WolframAlpha.

    Args:
        radii: Radii

    Returns:
        Mass within radii
    """
    a: float = self._surface_density
    b: float = self._adiabatic_bulk_modulus
    c: float = self._gravitational_acceleration
    d: float = self._outer_boundary
    beta: float = b / (a * c) - d

    def mass_integral(radii_: FloatOrArray) -> npt.NDArray:
        """Mass within radii including arbitrary constant of integration.

        Args:
            radii_: Radii

        Returns:
            Mass within radii
        """

        mass: npt.NDArray = (
            4
            * np.pi
            * b
            / c
            * (
                -1.5 * beta * beta
                - beta * radii_
                + 0.5 * radii_ * radii_
                + beta * beta * np.log(abs(beta + radii_))
            )
        )
        # + constant

        return mass

    mass: npt.NDArray = mass_integral(radii) - mass_integral(self._inner_boundary)

    return mass

get_mass_within_shell(radii)

Computes the mass within spherical shells bounded by radii.

Args: radii: Radii

Returns: Mass within the bounded spherical shells

Source code in aragog/mesh.py
663
664
665
666
667
668
669
670
671
672
673
674
675
676
def get_mass_within_shell(self, radii: npt.NDArray) -> npt.NDArray:
    """Computes the mass within spherical shells bounded by radii.

    Args:
        radii: Radii

    Returns:
        Mass within the bounded spherical shells
    """
    mass: npt.NDArray = self.get_mass_within_radii(radii[1:]) - self.get_mass_within_radii(
        radii[:-1]
    )

    return mass

get_pressure_from_radii(radii)

Computes pressure from radii:

\[ P(r) = -K_S \ln \left( 1 + \frac{\rho_s g (r-r_s)}{K_S} \right) \]

where \(r\) is radius, \(K_S\) is adiabatic bulk modulus, \(P\) is pressure, \(\rho_s\) is surface density, \(g\) is gravitational acceleration, and \(r_s\) is surface radius.

Args: radii: Radii

Returns: Pressure

Source code in aragog/mesh.py
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
def get_pressure_from_radii(self, radii: FloatOrArray) -> npt.NDArray:
    r"""Computes pressure from radii:

    $$
    P(r) = -K_S \ln \left( 1 + \frac{\rho_s g (r-r_s)}{K_S} \right)
    $$

    where $r$ is radius, $K_S$ is adiabatic bulk modulus, $P$ is pressure,
    $\rho_s$ is surface density, $g$ is gravitational acceleration, and
    $r_s$ is surface radius.

    Args:
        radii: Radii

    Returns:
        Pressure
    """
    pressure: npt.NDArray = -self._adiabatic_bulk_modulus * np.log(
        (
            self._adiabatic_bulk_modulus
            + self._surface_density
            * self._gravitational_acceleration
            * (radii - self._outer_boundary)
        )
        / self._adiabatic_bulk_modulus
    )

    return pressure

get_pressure_gradient(pressure)

Computes the pressure gradient:

\[ \frac{dP}{dr} = -g \rho \]

where \(\rho\) is density, \(P\) is pressure, and \(g\) is gravitational acceleration.

Args: pressure: Pressure

Returns: Pressure gradient

Source code in aragog/mesh.py
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
def get_pressure_gradient(self, pressure: FloatOrArray) -> npt.NDArray:
    r"""Computes the pressure gradient:

    $$
    \frac{dP}{dr} = -g \rho
    $$ 

    where $\rho$ is density, $P$ is pressure, and  $g$ is gravitational
    acceleration.

    Args:
        pressure: Pressure

    Returns:
        Pressure gradient
    """
    dPdr: npt.NDArray = -self._gravitational_acceleration * self.get_density(pressure)

    return dPdr

get_radii_from_pressure(pressure)

Computes radii from pressure:

\[ P(r) = \int \frac{dP}{dr} dr = \int -g \rho_s \exp(P/K_S) dr \]

And apply the boundary condition \(P=0\) at \(r=r_s\) to get:

\[ r(P) = \frac{K_s \left( \exp(-P/K_S)-1 \right)}{\rho_s g} + r_s \]

where \(r\) is radius, \(K_S\) is adiabatic bulk modulus, \(P\) is pressure, \(\rho_s\) is surface density, \(g\) is gravitational acceleration, and \(r_s\) is surface radius.

Args: pressure: Pressure

Returns: Radii

Source code in aragog/mesh.py
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
def get_radii_from_pressure(self, pressure: FloatOrArray) -> npt.NDArray:
    r"""Computes radii from pressure:

    $$
    P(r) = \int \frac{dP}{dr} dr = \int -g \rho_s \exp(P/K_S) dr
    $$ 

    And apply the boundary condition $P=0$ at $r=r_s$ to get:

    $$
    r(P) = \frac{K_s \left( \exp(-P/K_S)-1 \right)}{\rho_s g} + r_s
    $$

    where $r$ is radius, $K_S$ is adiabatic bulk modulus, $P$ is pressure,
    $\rho_s$ is surface density, $g$ is gravitational acceleration, and
    $r_s$ is surface radius.

    Args:
        pressure: Pressure

    Returns:
        Radii
    """
    radii: npt.NDArray = (
        self._adiabatic_bulk_modulus
        * (np.exp(-pressure / self._adiabatic_bulk_modulus) - 1)
        / (self._surface_density * self._gravitational_acceleration)
        + self._outer_boundary
    )

    return radii

set_staggered_pressure(staggered_radii)

Set staggered pressure based on staggered radii.

Source code in aragog/mesh.py
521
522
523
def set_staggered_pressure(self, staggered_radii: npt.NDArray,) -> None:
    """Set staggered pressure based on staggered radii."""
    self._staggered_pressure = self.get_pressure_from_radii(staggered_radii)

EOS

Bases: ABC

Generic EOS class

FixedMesh(settings, radii, mass_radii, outer_boundary, inner_boundary) dataclass

A fixed mesh

Args: settings: Mesh parameters radii: Radii of the mesh mass_radii: Mass coordinates of the mesh outer_boundary: Outer boundary for computing depth below the surface inner_boundary: Inner boundary for computing height above the base

Attributes: settings: Mesh parameters radii: Radii of the mesh mass_radii: Mass coordinates of the mesh outer_boundary: Outer boundary for computing depth below the surface inner_boundary: Inner boundary for computing height above the base area: Surface area delta_mesh: Delta radii in mass coordinates depth: Depth below the outer boundary height: Height above the inner boundary mixing_length: Mixing length mixing_length_squared: Mixing length squared mixing_length_cubed: Mixing length cubed number_of_nodes: Number of nodes volume: Volume of the spherical shells defined between neighbouring radii total_volume: Total volume

area cached property

Area

Mesh(parameters)

A staggered mesh.

The basic mesh is used for the flux calculations and the staggered mesh is used for the volume calculations.

Args: parameters: Parameters

Source code in aragog/mesh.py
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
def __init__(self, parameters: Parameters):

    # STEP 1: Set up the basic mesh
    self.settings: _MeshParameters = parameters.mesh
    basic_coordinates: npt.NDArray = self.get_constant_spacing()
    if self.settings.eos_method == 1:
        self.eos = AdamsWilliamsonEOS(
            self.settings, basic_coordinates
        )
    elif self.settings.eos_method == 2:
        self.eos = UserDefinedEOS(
            self.settings, basic_coordinates
        )
    else:
        msg: str = (f"Unknown method to initialize Equation of State")
        raise ValueError(msg)
    if parameters.mesh.mass_coordinates:
        self._planet_density: float = self.get_planet_density(basic_coordinates)
        basic_mass_coordinates: npt.NDArray = (
            self.get_basic_mass_coordinates_from_spatial_coordinates(basic_coordinates))
        logger.debug("Basic mass coordinates = %s", basic_mass_coordinates)
    else:
        basic_mass_coordinates = basic_coordinates
    self.basic: FixedMesh = FixedMesh(
        self.settings,
        basic_coordinates,
        basic_mass_coordinates,
        np.max(basic_coordinates),
        np.min(basic_coordinates)
    )

    # STEP 2: Set up the staggered mesh
    staggered_mass_coordinates: npt.NDArray = (
        self.basic.mass_radii[:-1] + 0.5 * self.basic.delta_mesh)
    if parameters.mesh.mass_coordinates:
        staggered_coordinates: npt.NDArray = (
            self.get_staggered_spatial_coordinates_from_mass_coordinates(staggered_mass_coordinates))
    else:
        staggered_coordinates = staggered_mass_coordinates
    self.staggered: FixedMesh = FixedMesh(
        self.settings,
        staggered_coordinates,
        staggered_mass_coordinates,
        self.basic.outer_boundary,
        self.basic.inner_boundary,
    )
    self.eos.set_staggered_pressure(self.staggered.radii)

    # STEP 3: Set up the transform matrices
    if parameters.mesh.mass_coordinates:
        self._dxidr: npt.NDArray = self.get_dxidr_basic()
    else:
        self._dxidr: npt.NDArray = np.ones_like(self.basic.radii)
    self._d_dr_transform: npt.NDArray = self._get_d_dr_transform_matrix()
    self._quantity_transform: npt.NDArray = self._get_quantity_transform_matrix()

dxidr property

dxi/dr at basic nodes

d_dr_at_basic_nodes(staggered_quantity)

Determines d/dr at the basic nodes of a quantity defined at the staggered nodes.

Args: staggered_quantity: A quantity defined at the staggered nodes.

Returns: d/dr at the basic nodes

Source code in aragog/mesh.py
370
371
372
373
374
375
376
377
378
379
380
381
382
def d_dr_at_basic_nodes(self, staggered_quantity: npt.NDArray) -> npt.NDArray:
    """Determines d/dr at the basic nodes of a quantity defined at the staggered nodes.

    Args:
        staggered_quantity: A quantity defined at the staggered nodes.

    Returns:
        d/dr at the basic nodes
    """
    d_dr_at_basic_nodes: npt.NDArray = self._d_dr_transform.dot(staggered_quantity)
    logger.debug("d_dr_at_basic_nodes = %s", d_dr_at_basic_nodes)

    return d_dr_at_basic_nodes

get_basic_mass_coordinates_from_spatial_coordinates(basic_coordinates)

Computes the basic mass coordinates from basic spatial coordinates.

Args: Basic spatial coordinates

Returns: Basic mass coordinates

Source code in aragog/mesh.py
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
def get_basic_mass_coordinates_from_spatial_coordinates(self, basic_coordinates: npt.NDArray) -> npt.NDArray:
    """Computes the basic mass coordinates from basic spatial coordinates.

    Args:
        Basic spatial coordinates

    Returns:
        Basic mass coordinates
    """

    # Set the mass coordinates at the inner boundary from the core mass
    basic_mass_coordinates = np.zeros_like(basic_coordinates)
    basic_mass_coordinates[:,:] = (
        self.settings.core_density / self._planet_density
        * np.power(basic_coordinates[0,:], 3.0)
    )

    # Get mass coordinates by adding individual cell contributions to the mantle mass
    basic_volumes = (np.power(basic_coordinates[1:,:],3.0)
        - np.power(basic_coordinates[:-1,:],3.0))
    for i in range(1, self.settings.number_of_nodes):
        basic_mass_coordinates[i:,:] += (
            self.staggered_effective_density[i-1,:] * basic_volumes[i-1,:] / self._planet_density
        )

    return np.power(basic_mass_coordinates, 1.0/3.0)

get_constant_spacing()

Constant radius spacing across the mantle

Returns: Radii with constant spacing as a column vector

Source code in aragog/mesh.py
320
321
322
323
324
325
326
327
328
329
330
331
def get_constant_spacing(self) -> npt.NDArray:
    """Constant radius spacing across the mantle

    Returns:
        Radii with constant spacing as a column vector
    """
    radii: npt.NDArray = np.linspace(
        self.settings.inner_radius, self.settings.outer_radius, self.settings.number_of_nodes
    )
    radii = np.atleast_2d(radii).T

    return radii

get_dxidr_basic()

Computes dxidr at basic nodes.

Source code in aragog/mesh.py
308
309
310
311
312
313
314
315
316
317
318
def get_dxidr_basic(self) -> npt.NDArray:
    """Computes dxidr at basic nodes."""

    dxidr = (
        self.eos.basic_density
        / self._planet_density
        * np.power(self.basic.radii,2.0)
        / np.power(self.basic.mass_radii,2.0)
    )

    return dxidr

get_planet_density(basic_coordinates)

Computes the planet density.

Args: Basic spatial coordinates

Returns: Planet effective density

Source code in aragog/mesh.py
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
def get_planet_density(self, basic_coordinates: npt.NDArray) -> float:
    """Computes the planet density.

    Args:
        Basic spatial coordinates

    Returns:
        Planet effective density
    """
    core_mass = self.settings.core_density *  np.power(basic_coordinates[0,0], 3.0)
    basic_volumes = (np.power(basic_coordinates[1:,0],3.0)
        - np.power(basic_coordinates[:-1,0],3.0))
    mantle_mass = np.sum(
        self.staggered_effective_density[:,0] * basic_volumes
    )
    planet_density = (
        (core_mass + mantle_mass) / (np.power(basic_coordinates[-1,0],3.0)))
    return planet_density.item()

get_staggered_spatial_coordinates_from_mass_coordinates(staggered_mass_coordinates)

Computes the staggered spatial coordinates from staggered mass coordinates.

Args: Staggered mass coordinates

Returns: Staggered spatial coordinates

Source code in aragog/mesh.py
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
def get_staggered_spatial_coordinates_from_mass_coordinates(self, staggered_mass_coordinates: npt.NDArray) -> npt.NDArray:
    """Computes the staggered spatial coordinates from staggered mass coordinates.

    Args:
        Staggered mass coordinates

    Returns:
        Staggered spatial coordinates
    """

    # Initialise the staggered spatial coordinate to the inner boundary
    staggered_coordinates = (np.ones_like(staggered_mass_coordinates)
        * np.power(self.settings.inner_radius,3.0))

    # Add first half cell contribution
    staggered_coordinates += (
        self._planet_density
         * (np.power(staggered_mass_coordinates[0,:],3.0)
        - np.power(self.basic.mass_radii[0,:], 3.0))
        / self.staggered_effective_density[0,:]
    )

    # Get spatial coordinates by adding individual cell contributions to the mantle mass
    shell_effective_density = 0.5*(
        self.staggered_effective_density[1:,:] + self.staggered_effective_density[:-1,:])
    shell_mass_volumes = (np.power(staggered_mass_coordinates[1:,:],3.0)
        - np.power(staggered_mass_coordinates[:-1,:],3.0))
    for i in range(1,self.settings.number_of_nodes-1):
        staggered_coordinates[i:,:] += (
            self._planet_density
            * shell_mass_volumes[i-1,:]
            / shell_effective_density[i-1,:]
        )

    return np.power(staggered_coordinates, 1.0/3.0)

quantity_at_basic_nodes(staggered_quantity)

Determines a quantity at the basic nodes that is defined at the staggered nodes.

Uses backward and forward differences at the inner and outer radius, respectively, to obtain the quantity values of the basic nodes at the innermost and outermost nodes. When using temperature boundary conditions, values at outer boundaries will be overwritten. When using flux boundary conditions, values at outer boundaries will be used to provide estimate of individual components of heat fluxes though the total heat flux is imposed.

Args: staggered_quantity: A quantity defined at the staggered nodes

Returns: The quantity at the basic nodes

Source code in aragog/mesh.py
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
def quantity_at_basic_nodes(self, staggered_quantity: npt.NDArray) -> npt.NDArray:
    """Determines a quantity at the basic nodes that is defined at the staggered nodes.

    Uses backward and forward differences at the inner and outer radius, respectively, to
    obtain the quantity values of the basic nodes at the innermost and outermost nodes.
    When using temperature boundary conditions, values at outer boundaries will be overwritten.
    When using flux boundary conditions, values at outer boundaries will be used to provide
    estimate of individual components of heat fluxes though the total heat flux is imposed.

    Args:
        staggered_quantity: A quantity defined at the staggered nodes

    Returns:
        The quantity at the basic nodes
    """
    quantity_at_basic_nodes: npt.NDArray = self._quantity_transform.dot(staggered_quantity)
    logger.debug("quantity_at_basic_nodes = %s", quantity_at_basic_nodes)

    return quantity_at_basic_nodes

quantity_at_staggered_nodes(basic_quantity)

Determines a quantity at the staggered nodes that is defined at the basic nodes.

Staggered nodes are always located at cell centers, whatever the mesh.

Args: basic_quantity: A quantity defined at the basic nodes

Returns: The quantity at the staggered nodes

Source code in aragog/mesh.py
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
def quantity_at_staggered_nodes(self, basic_quantity: npt.NDArray) -> npt.NDArray:
    """Determines a quantity at the staggered nodes that is defined at the basic nodes.

    Staggered nodes are always located at cell centers, whatever the mesh.

    Args:
        basic_quantity: A quantity defined at the basic nodes

    Returns:
        The quantity at the staggered nodes
    """
    quantity_at_staggered_nodes: npt.NDArray = 0.5 * (
        basic_quantity[:-1, ...] + basic_quantity[1:, ...])
    logger.debug("quantity_at_staggered_nodes = %s", quantity_at_staggered_nodes)

    return quantity_at_staggered_nodes

Parameters(*, boundary_conditions, energy, initial_condition, mesh, phase_solid, phase_liquid, phase_mixed, radionuclides, scalings, solver) dataclass

Assembles all the parameters.

The parameters in each section are scaled here to ensure that all the parameters are scaled (non-dimensionalised) consistently with each other.

from_file(*filenames) classmethod

Parses the parameters in a configuration file(s)

Args: *filenames: Filenames of the configuration data

Source code in aragog/parser.py
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
@classmethod
def from_file(cls, *filenames) -> Self:
    """Parses the parameters in a configuration file(s)

    Args:
        *filenames: Filenames of the configuration data
    """
    parser: ConfigParser = ConfigParser()
    parser.read(*filenames)

    init_dict: dict[str, Any] = {}
    for section_name, dataclass_ in _get_dataclass_from_section_name().items():
        init_dict[section_name] = parser.parse_section(
            using_dataclass=dataclass_, section_name=section_name
        )
    radionuclides: list[_Radionuclide] = []
    for radionuclide_section in cls.radionuclide_sections(parser):
        radionuclide = parser.parse_section(
            using_dataclass=_Radionuclide, section_name=radionuclide_section
        )
        radionuclides.append(radionuclide)

    init_dict["radionuclides"] = radionuclides

    return cls(**init_dict)  # Unpacking gives required arguments so pylint: disable=E1125

radionuclide_sections(parser) staticmethod

Section names relating to radionuclides

Sections relating to radionuclides must have the prefix radionuclide_

Source code in aragog/parser.py
499
500
501
502
503
504
505
506
507
508
509
@staticmethod
def radionuclide_sections(parser: ConfigParser) -> list[str]:
    """Section names relating to radionuclides

    Sections relating to radionuclides must have the prefix radionuclide_
    """
    return [
        parser[section].name
        for section in parser.sections()
        if section.startswith("radionuclide_")
    ]

UserDefinedEOS(settings, basic_radii)

Bases: EOS

User defined equation of state (EOS).

Pressure field and effective density field on staggered nodes provided by the user.

Source code in aragog/mesh.py
765
766
767
768
769
770
771
772
773
774
775
776
777
def __init__(
    self,
    settings: _MeshParameters,
    basic_radii: npt.NDArray,
):
    self._interp_pressure = PchipInterpolator(settings.eos_radius, settings.eos_pressure)
    self._interp_density = PchipInterpolator(settings.eos_radius, settings.eos_density)
    self._basic_pressure = self._interp_pressure(basic_radii).reshape(-1,1)
    basic_effective_density = self._interp_density(basic_radii).reshape(-1,1)
    self._staggered_effective_density = 0.5*(
        basic_effective_density[:-1, :] + basic_effective_density[1:, :])
    # Assumes density and effective density are the same at basic nodes
    self._basic_density = basic_effective_density

basic_density property

Effective density at basic nodes

basic_pressure property

Pressure at basic nodes

staggered_effective_density property

Effective density at staggered nodes

staggered_pressure property

Pressure at staggered nodes

set_staggered_pressure(staggered_radii)

Set staggered pressure based on staggered radii.

Source code in aragog/mesh.py
799
800
801
def set_staggered_pressure(self, staggered_radii: npt.NDArray,) -> None:
    """Set staggered pressure based on staggered radii."""
    self._staggered_pressure = self._interp_pressure(staggered_radii).reshape(-1,1)

_MeshParameters(outer_radius, inner_radius, number_of_nodes, mixing_length_profile, core_density, eos_method=1, surface_density=4000, gravitational_acceleration=9.81, adiabatic_bulk_modulus=260000000000.0, mass_coordinates=False, eos_file='') dataclass

Stores parameters in the mesh section in the configuration data.

scale_attributes(scalings)

Scales the attributes

Args: scalings: scalings

Source code in aragog/parser.py
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
def scale_attributes(self, scalings: _ScalingsParameters) -> None:
    """Scales the attributes

    Args:
        scalings: scalings
    """
    self.scalings_ = scalings
    self.outer_radius /= self.scalings_.radius
    self.inner_radius /= self.scalings_.radius
    self.core_density /= self.scalings_.density
    self.surface_density /= self.scalings_.density
    self.gravitational_acceleration /= self.scalings_.gravitational_acceleration
    self.adiabatic_bulk_modulus /= self.scalings_.pressure

    if self.eos_method == 2:
        if self.eos_file == "":
            msg: str = (f"you must provide a file for setting up equation of state")
            raise ValueError(msg)
        arr = np.loadtxt(self.eos_file)
        self.eos_radius = arr[:,0] / self.scalings_.radius
        self.eos_pressure = arr[:,1] / self.scalings_.pressure
        self.eos_density = arr[:,2] / self.scalings_.density
        self.eos_gravity = arr[:,3] / self.scalings_.gravitational_acceleration
        # Check that provided eos radius roughly match with Aragog mesh
        if ((self.eos_radius[0] < self.inner_radius) or
            (self.eos_radius[-1] > self.outer_radius) or
            (self.eos_radius[-1]-self.eos_radius[0]) < 0.75*(self.outer_radius-self.inner_radius)):
            msg: str = (f"Radius array in EOS file: Values out of range.")
            raise ValueError(msg)

is_monotonic_increasing(some_array)

Returns True if an array is monotonically increasing, otherwise returns False.

Source code in aragog/utilities.py
65
66
67
def is_monotonic_increasing(some_array: npt.NDArray) -> bool:
    """Returns True if an array is monotonically increasing, otherwise returns False."""
    return np.all(np.diff(some_array) > 0)