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
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 | |
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
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
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
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
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
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
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
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
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
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 221 222 223 | |
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
225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
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
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 | |
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
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
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
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 | |
set_staggered_pressure(staggered_radii)
Set staggered pressure based on staggered radii.
Source code in src/aragog/mesh/pressure_eos.py
103 104 105 106 107 108 | |
EOS
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
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 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 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
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 src/aragog/mesh/__init__.py
431 432 433 434 435 436 437 438 439 440 441 442 443 | |
get_basic_mass_coordinates_from_spatial_coordinates(basic_coordinates)
Computes mass coordinates matching SPIDER's definition.
SPIDER's mass coordinate (eos_adamswilliamson.c:296-311):
xi(r)^3 = r_core^3 + 3 * M_AW(r_core, r) / rho_avg_mantle
where M_AW is the A-W mass integral from r_core to r (without 4pi), and rho_avg_mantle is the mantle-only average density. At the CMB: xi = r_core. At the surface: xi = r_surface (by construction of rho_avg_mantle).
Args: Basic spatial coordinates
Returns: Basic mass coordinates
Source code in src/aragog/mesh/__init__.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 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
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
377 378 379 380 381 382 383 384 385 386 387 388 389 390 | |
get_dxidr_basic()
Computes dxidr at basic nodes.
Source code in src/aragog/mesh/__init__.py
365 366 367 368 369 370 371 372 373 374 375 | |
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
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 | |
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 src/aragog/mesh/__init__.py
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 362 363 | |
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
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | |
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
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | |
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
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
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
378 379 380 381 382 383 384 | |
set_staggered_pressure(staggered_radii)
Set staggered pressure based on staggered radii.
Source code in src/aragog/mesh/pressure_eos.py
371 372 373 374 375 376 | |
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
32 33 34 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 | |