Mesh
mesh
Mesh subpackage: staggered mesh, fixed mesh, and pressure EOS classes.
AdamsWilliamsonEOS(settings, basic_radii)
Bases: EOS
Adams-Williamson equation of state (EOS).
Matches SPIDER's eos_adamswilliamson.c: exponential density profile
rho(z) = rhos * exp(beta * z)
where z = R_surf - r is depth. The parameter beta [1/m] is passed directly from the config (adams_williamson_beta), NOT derived from the adiabatic bulk modulus K_S. This ensures the density profile is identical to SPIDER's when both codes use the same beta.
The previous implementation used a rational (hyperbolic) form rho = rhos * K_S / (K_S - rhosgdepth) derived from K_S, which differs from SPIDER's exponential by up to 6% at CMB depth, causing a 3% R_int mismatch for the same target planet mass.
Source code in src/aragog/mesh/pressure_eos.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
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 (SPIDER parity):
Matches SPIDER's eos_adamswilliamson.c:GetRho (line 116):
rho = rhos - P * beta / gravity where gravity is negative.
Args: pressure: Pressure
Returns: Density
Source code in src/aragog/mesh/pressure_eos.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
get_density_from_radii(radii)
Computes density from radii using SPIDER-parity exponential form:
where \(\rho_s\) is surface density, \(\beta\) is the Adams-Williamson parameter [1/m], and \(R_s\) is the surface radius. Matches SPIDER's eos_adamswilliamson.c via the chain rho(P(r)).
Args: radii: Radii
Returns Density
Source code in src/aragog/mesh/pressure_eos.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
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 src/aragog/mesh/pressure_eos.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
get_mass_element(radii)
Computes the mass element:
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 src/aragog/mesh/pressure_eos.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
get_mass_within_radii(radii)
Computes mass within radii using SPIDER-parity exponential form:
The antiderivative is (matching SPIDER eos_adamswilliamson.c:191):
where rho(r) = rhos * exp(beta*(R_s - r)).
Args: radii: Radii
Returns: Mass within radii (from inner_boundary to radii)
Source code in src/aragog/mesh/pressure_eos.py
242 243 244 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 271 272 | |
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 src/aragog/mesh/pressure_eos.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
get_pressure_from_radii(radii)
Computes pressure from radii using SPIDER-parity exponential form:
Matches SPIDER's eos_adamswilliamson.c:GetPressureFromRadius. Note: g is positive here (unlike SPIDER where gravity is negative).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radii
|
FloatOrArray
|
Radii at which to compute pressure. |
required |
Returns:
| Type | Description |
|---|---|
NDArray
|
Pressure at the given radii. |
Source code in src/aragog/mesh/pressure_eos.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
get_pressure_gradient(pressure)
Computes the pressure gradient:
where \(\rho\) is density, \(P\) is pressure, and \(g\) is gravitational acceleration.
Args: pressure: Pressure
Returns: Pressure gradient
Source code in src/aragog/mesh/pressure_eos.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
get_radii_from_pressure(pressure)
Computes radii from pressure (SPIDER parity):
Inverse of get_pressure_from_radii.
Args: pressure: Pressure
Returns: Radii
Source code in src/aragog/mesh/pressure_eos.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
set_basic_density(basic_radii)
Set basic-node density based on basic radii.
Refreshing basic_density from the post-mass-coordinate radii keeps get_dxidr_basic consistent with the solved mesh.
Source code in src/aragog/mesh/pressure_eos.py
148 149 150 151 152 153 154 155 156 157 | |
set_basic_pressure(basic_radii)
Set basic pressure based on basic radii.
Source code in src/aragog/mesh/pressure_eos.py
141 142 143 144 145 146 | |
set_staggered_pressure(staggered_radii)
Set staggered pressure based on staggered radii.
Source code in src/aragog/mesh/pressure_eos.py
134 135 136 137 138 139 | |
EOS
Bases: ABC
Generic EOS class
get_mass_within_radii(radii)
abstractmethod
Cumulative mass [kg] inside radii from a class-specific zero point.
The result has the same shape as radii.
Source code in src/aragog/mesh/pressure_eos.py
49 50 51 52 53 54 | |
set_staggered_effective_density(basic_radii)
Set each cell's effective density to its mass over its volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basic_radii
|
NDArray
|
Basic-node radii [m], shape (n, 1), the faces of the cells. |
required |
Source code in src/aragog/mesh/pressure_eos.py
56 57 58 59 60 61 62 63 64 65 66 | |
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 src/aragog/mesh/__init__.py
235 236 237 238 239 240 241 242 243 244 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 271 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 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
dxidr
property
dxi/dr at basic nodes
top_ratio
property
Basic over staggered spacing of the outer cell (the outer row of the transform).
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 src/aragog/mesh/__init__.py
480 481 482 483 484 485 486 487 488 489 490 491 492 | |
entropy_at_basic_nodes(S)
Entropy at the basic nodes, with the top node from top_node_entropy when limited.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
When a limited node with finite cells is not between the top cell and the linear node, or leaves the table with the top cell in it and is not the linear node within 4 ulp of the table. |
Source code in src/aragog/mesh/__init__.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | |
get_constant_spacing()
Constant radius spacing across the mantle
Returns: Radii with constant spacing as a column vector
Source code in src/aragog/mesh/__init__.py
427 428 429 430 431 432 433 434 435 436 437 438 439 440 | |
get_dxidr_basic()
Computes dxidr at basic nodes.
Source code in src/aragog/mesh/__init__.py
415 416 417 418 419 420 421 422 423 424 425 | |
get_planet_density(basic_coordinates)
Computes the mantle average density for mass-coordinate mapping.
Matches SPIDER's EOSAdamsWilliamson_GetMassCoordinateAverageRho
(eos_adamswilliamson.c:249-267): the average density is computed
over the mantle shell only (r_core to r_surface), NOT including
the core. This ensures the mass-coordinate xi grid maps to the
same physical radii as SPIDER's Newton-solved mesh.
The previous implementation used whole-planet density (core + mantle) / r_surface^3, which produced ~3% node position offsets and cascading 12% pressure / 20% density / 17% flux differences.
Args: Basic spatial coordinates
Returns: Mantle average density (for mass-coordinate normalization)
Source code in src/aragog/mesh/__init__.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
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 src/aragog/mesh/__init__.py
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | |
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 src/aragog/mesh/__init__.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | |
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 src/aragog/mesh/pressure_eos.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
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
get_mass_within_radii(radii)
4pi-included cumulative mass M(r), anchored at the inner EOS radius.
Mesh.get_planet_density and the mass-coordinate brentq loop use only differences M(r2) - M(r1), so the anchor cancels.
Source code in src/aragog/mesh/pressure_eos.py
458 459 460 461 462 463 464 | |
get_pressure_from_radii(radii)
Computes pressure from radii by interpolating the user-supplied EOS table.
Args: radii: Radii at which to compute pressure.
Returns: Pressure at the given radii.
Source code in src/aragog/mesh/pressure_eos.py
427 428 429 430 431 432 433 434 435 436 437 438 | |
set_basic_density(basic_radii)
Set basic-node density based on basic radii.
Interpolate the user density table at the post-mass-coordinate basic radii so get_dxidr_basic reads density on the solved mesh.
Source code in src/aragog/mesh/pressure_eos.py
447 448 449 450 451 452 453 454 455 456 | |
set_basic_pressure(basic_radii)
Set basic pressure based on basic radii.
Source code in src/aragog/mesh/pressure_eos.py
440 441 442 443 444 445 | |
set_staggered_pressure(staggered_radii)
Set staggered pressure based on staggered radii.
Source code in src/aragog/mesh/pressure_eos.py
420 421 422 423 424 425 | |
derive_core_density_from_mesh(mesh_file, M_core)
Derive the self-consistent average core density from a mantle mesh file.
Reads the CMB radius from a 5-column ascending-r mantle mesh file
(r, P, rho, g, T) and returns
:math:\rho_\mathrm{core} = M_\mathrm{core} / (\tfrac{4}{3} \pi R_\mathrm{cmb}^3).
The first row of the file is the bottom of the mantle (CMB), matching
the format Zalmoxis writes to zalmoxis_output.dat. This is the
Aragog-side analogue of the SPIDER wrapper's -rho_core echo-back:
the on-disk mesh's :math:R_\mathrm{cmb} and the latest
hf_row['M_core'] give a self-consistent average density that
survives mesh-blending fall-backs and stale-cache cases where
hf_row['core_density'] has drifted from the mesh state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh_file
|
str
|
Path to the Zalmoxis-format mantle mesh file. The first row is
treated as the CMB; only the first column ( |
required |
M_core
|
float
|
Core mass [kg]. Must be positive. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Self-consistent average core density [kg m^-3]. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If |
ValueError
|
If |
Source code in src/aragog/mesh/__init__.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
top_node_entropy(S, ratio, S_min=-np.inf, S_max=np.inf, xp=np, linear=None)
Limited entropy of the top basic node from the top 2 cell entropies.
The linear node is S_N + D with the half step D = (ratio/2)(S_N - S_N-1). The limited
node is S_N + sign(D) M(|D|, b), with b = c (S_N - S_min) for D < 0 and
b = c (S_max - S_N) for D > 0 (0 outside the table), and the smooth minimum
M(a, b) = a b / (a^p + b^p)^(1/p), c = TOP_NODE_SCALE, p = TOP_NODE_POWER.
With the top cell in the table the node keeps at least 1 - c of the top cell's distance
to each edge and lies between the top cell and the linear node (to rounding: where the limiter
acts, a few ulp outside a linear from the matrix row). d node / d S_N lies in
[1 - c, 1 + ratio/2] and d node / d S_N-1 in [-ratio/2, 0], so a cooling top cell
lowers the node. With the top cell in the table the node is C^p across D = 0 and leaves
the linear node by the fraction 1 - (1 + (|D|/b)^p)^(-1/p) of |D|, below 1e-3 for
b >= 4|D| at p = 4. A top cell outside the table whose half step points away from it
is its own node; one whose half step points into it takes b from the far edge. At the
edge the half step points to, the node is continuous with slope 1 outside and 1 - c
inside. An unbounded table gives the linear node. A non-finite cell among the top 2 gives
NaN. Where the limiter does not act (step D, factor k exactly 1) the node is
linear bit for bit, so the statements above hold to its rounding: a flat top on or next
to an edge can lie up to 2 ulp outside the table for ratio < 2, and where k leaves 1
the node fell by at most 1 ulp in the sweeps measured (the tests allow 2). Every Mesh
gives ratio < 2: its staggered nodes are the cell midpoints in the mesh coordinate, so
ratio = 2 h_N / (h_N-1 + h_N) with h the cell widths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
S
|
array
|
Cell entropies, innermost first along axis 0; the last 2 are used [J/kg/K]. |
required |
ratio
|
float
|
Basic over staggered spacing of the outer cell (the outer row of the quantity transform). |
required |
S_min
|
float
|
Entropy range of the table [J/kg/K]. |
-inf
|
S_max
|
float
|
Entropy range of the table [J/kg/K]. |
-inf
|
xp
|
module
|
|
numpy
|
linear
|
float or array
|
The linear node as the caller computes it (the outer row of the quantity transform);
|
None
|
Returns:
| Type | Description |
|---|---|
float or array
|
Top basic-node entropy [J/kg/K]. |
Raises:
| Type | Description |
|---|---|
ValueError
|
With fewer than 2 cells. |
Source code in src/aragog/mesh/__init__.py
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 208 209 210 211 212 213 214 215 216 217 218 219 220 | |