Skip to content
Open
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
72 changes: 72 additions & 0 deletions doc/make_si_html.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import re
from glob import glob

si_units_map = {
r"\meter" : "m",
r"\kilogram" : "kg",
r"\second" : "s",
r"\joule" : "J",
r"\kilo" : "k",
r"\pascal" : "Pa",
r"\kelvin" : "K",
r"\watt" : "W",
r"\mole" : "mol",
}

def get_source_files(source_dir):
pattern = f"{source_dir}/**/*.cc"
return glob(pattern, recursive=True)


def si_to_md(sym, exp):
# define how we want to format the symbol if
# an exponent is there
# put the exponent in braces for -ve exponents
# so that the minus sign is included.
if exp:
return rf"\\text{{{sym}}}^{{{exp}}}"
return rf"\\text{{{sym}}}"


def parse_units(content, units_map):
# we first find all \si{...} occurrences and extract the content inside
si_units = re.findall(r"\\si\{([^}]*)\}", content)

for si_unit in si_units:
# target defines the list of (symbol, exponent) tuples
# we want to convert to markdown
target = []
in_denom = False
units = re.findall(r"\\[a-zA-Z]+", si_unit)

# for each of si_unit, i.e., \\per\\meter\\squared,
# convert tuples, e.g., [("m", "-2")]
for unit in units:
match = units_map.get(unit, None)
if unit == r"\per":
in_denom = True
elif unit in (r"\squared", r"\cubed"):
# apply exponent to the last unit added
# if it is in denominator, make exponent negative
exp = "2" if unit == r"\squared" else "3"
if in_denom:
exp = str(int(exp) * -1)
if target:
target[-1] = (target[-1][0], exp)
elif match:
exp = -1 if in_denom else None
target.append((match, exp))

md_string = "".join(si_to_md(sym, exp) for sym, exp in target)
content = content.replace(f"\\\\si{{{si_unit}}}", f"${md_string}$")

return content

filenames = get_source_files("/home/arushi/opt/aspect/source/")

for filename in filenames:
with open(filename, 'r') as f:
content = f.read()

with open(filename, 'w') as f:
f.write(parse_units(content, si_units_map))
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Because this class simply takes what the initial temperature had described, this

**Pattern:** [MultipleSelection function ]

**Documentation:** A comma-separated list of boundary convective heating models that will be used to determine the heat transfer coefficient across the boundary. The heat transfer coefficient characterises the heat exchange between the solid model interior and an adjacent fluid. In the context of a Robin boundary condition, the heat transfer coefficient governs the strength of the convective coupling: For heat transfer coefficient --> zero, the boundary approaches insulating (Neumann) behaviour; For heat transfer coefficient --> infinity, the boundary approaches a prescribed-temperature (Dirichlet) condition. The unit of the heat transfer coefficient is \si{\watt\per\meter\squared\per\kelvin}.At the moment, this list can only have one entry.
**Documentation:** A comma-separated list of boundary convective heating models that will be used to determine the heat transfer coefficient across the boundary. The heat transfer coefficient characterises the heat exchange between the solid model interior and an adjacent fluid. In the context of a Robin boundary condition, the heat transfer coefficient governs the strength of the convective coupling: For heat transfer coefficient --> zero, the boundary approaches insulating (Neumann) behaviour; For heat transfer coefficient --> infinity, the boundary approaches a prescribed-temperature (Dirichlet) condition. The unit of the heat transfer coefficient is $\text{W}\text{m}^{-2}\text{K}^{-1}$.At the moment, this list can only have one entry.

The following heat transfer coefficient models are available:

Expand Down
12 changes: 6 additions & 6 deletions doc/sphinx/parameters/Boundary_20temperature_20model.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ Because this class simply takes what the initial temperature had described, this

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** Pressure at CMB. Units: \si{\pascal}.
**Documentation:** Pressure at CMB. Units: $\text{Pa}$.
::::

::::{dropdown} __Parameter:__ {ref}`Core conductivity<parameters:Boundary_20temperature_20model/Dynamic_20core/Core_20conductivity>`
Expand Down Expand Up @@ -376,7 +376,7 @@ Because this class simply takes what the initial temperature had described, this

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** The latent heat of core freeze. Units: \si{\joule\per\kilogram}.
**Documentation:** The latent heat of core freeze. Units: $\text{J}\text{kg}^{-1}$.
::::

::::{dropdown} __Parameter:__ {ref}`Max iteration<parameters:Boundary_20temperature_20model/Dynamic_20core/Max_20iteration>`
Expand All @@ -403,7 +403,7 @@ Because this class simply takes what the initial temperature had described, this

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** The heat of reaction. Units: \si{\joule\per\kilogram}.
**Documentation:** The heat of reaction. Units: $\text{J}\text{kg}^{-1}$.
::::

::::{dropdown} __Parameter:__ {ref}`Rho0<parameters:Boundary_20temperature_20model/Dynamic_20core/Rho0>`
Expand All @@ -421,7 +421,7 @@ Because this class simply takes what the initial temperature had described, this

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** Initial inner core radius changing rate. Units: \si{\kilo\meter}/year.
**Documentation:** Initial inner core radius changing rate. Units: $\text{k}\text{m}$/year.
::::

::::{dropdown} __Parameter:__ {ref}`dT over dt<parameters:Boundary_20temperature_20model/Dynamic_20core/dT_20over_20dt>`
Expand Down Expand Up @@ -477,7 +477,7 @@ Because this class simply takes what the initial temperature had described, this

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** Melting curve ({cite}`NPB+04` eq. (40)) parameter Tm1. Units: \si{\per\pascal}.
**Documentation:** Melting curve ({cite}`NPB+04` eq. (40)) parameter Tm1. Units: $\text{Pa}^{-1}$.
::::

::::{dropdown} __Parameter:__ {ref}`Tm2<parameters:Boundary_20temperature_20model/Dynamic_20core/Geotherm_20parameters/Tm2>`
Expand All @@ -486,7 +486,7 @@ Because this class simply takes what the initial temperature had described, this

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** Melting curve ({cite}`NPB+04` eq. (40)) parameter Tm2. Units: \si{\per\pascal\squared}.
**Documentation:** Melting curve ({cite}`NPB+04` eq. (40)) parameter Tm2. Units: $\text{Pa}^{-2}$.
::::

::::{dropdown} __Parameter:__ {ref}`Use BW11<parameters:Boundary_20temperature_20model/Dynamic_20core/Geotherm_20parameters/Use_20BW11>`
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinx/parameters/Boundary_20traction_20model.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,5 @@ If the function you are describing represents a vector-valued function with mult

**Pattern:** [List of <[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]> of length 0...4294967295 (inclusive)]

**Documentation:** The point where the pressure profile will be calculated. Cartesian coordinates $(x,y,z)$ when geometry is a box, otherwise enter radius, longitude, and in 3d latitude. Note that the coordinate related to the depth ($y$ in 2d Cartesian, $z$ in 3d Cartesian and radius in spherical coordinates) is not used. Units: \si{\meter} or degrees.
**Documentation:** The point where the pressure profile will be calculated. Cartesian coordinates $(x,y,z)$ when geometry is a box, otherwise enter radius, longitude, and in 3d latitude. Note that the coordinate related to the depth ($y$ in 2d Cartesian, $z$ in 3d Cartesian and radius in spherical coordinates) is not used. Units: $\text{m}$ or degrees.
::::
42 changes: 21 additions & 21 deletions doc/sphinx/parameters/Geometry_20model.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** X coordinate of box origin. Units: \si{\meter}.
**Documentation:** X coordinate of box origin. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Box origin Y coordinate<parameters:Geometry_20model/Box/Box_20origin_20Y_20coordinate>`
Expand All @@ -69,7 +69,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** Y coordinate of box origin. Units: \si{\meter}.
**Documentation:** Y coordinate of box origin. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Box origin Z coordinate<parameters:Geometry_20model/Box/Box_20origin_20Z_20coordinate>`
Expand All @@ -78,7 +78,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** Z coordinate of box origin. This value is ignored if the simulation is in 2d. Units: \si{\meter}.
**Documentation:** Z coordinate of box origin. This value is ignored if the simulation is in 2d. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`X extent<parameters:Geometry_20model/Box/X_20extent>`
Expand All @@ -87,7 +87,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Extent of the box in x-direction. Units: \si{\meter}.
**Documentation:** Extent of the box in x-direction. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`X periodic<parameters:Geometry_20model/Box/X_20periodic>`
Expand All @@ -114,7 +114,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Extent of the box in y-direction. Units: \si{\meter}.
**Documentation:** Extent of the box in y-direction. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Y periodic<parameters:Geometry_20model/Box/Y_20periodic>`
Expand All @@ -141,7 +141,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Extent of the box in z-direction. This value is ignored if the simulation is in 2d. Units: \si{\meter}.
**Documentation:** Extent of the box in z-direction. This value is ignored if the simulation is in 2d. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Z periodic<parameters:Geometry_20model/Box/Z_20periodic>`
Expand Down Expand Up @@ -170,7 +170,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** X coordinate of box origin. Units: \si{\meter}.
**Documentation:** X coordinate of box origin. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Box origin Y coordinate<parameters:Geometry_20model/Box_20with_20lithosphere_20boundary_20indicators/Box_20origin_20Y_20coordinate>`
Expand All @@ -179,7 +179,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** Y coordinate of box origin. Units: \si{\meter}.
**Documentation:** Y coordinate of box origin. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Box origin Z coordinate<parameters:Geometry_20model/Box_20with_20lithosphere_20boundary_20indicators/Box_20origin_20Z_20coordinate>`
Expand All @@ -188,7 +188,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** Z coordinate of box origin. This value is ignored if the simulation is in 2d. Units: \si{\meter}.
**Documentation:** Z coordinate of box origin. This value is ignored if the simulation is in 2d. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Lithospheric thickness<parameters:Geometry_20model/Box_20with_20lithosphere_20boundary_20indicators/Lithospheric_20thickness>`
Expand All @@ -215,7 +215,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Extent of the box in x-direction. Units: \si{\meter}.
**Documentation:** Extent of the box in x-direction. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`X periodic<parameters:Geometry_20model/Box_20with_20lithosphere_20boundary_20indicators/X_20periodic>`
Expand Down Expand Up @@ -251,7 +251,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Extent of the box in y-direction. Units: \si{\meter}.
**Documentation:** Extent of the box in y-direction. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Y periodic<parameters:Geometry_20model/Box_20with_20lithosphere_20boundary_20indicators/Y_20periodic>`
Expand Down Expand Up @@ -296,7 +296,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Extent of the box in z-direction. This value is ignored if the simulation is in 2d. Units: \si{\meter}.
**Documentation:** Extent of the box in z-direction. This value is ignored if the simulation is in 2d. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Z periodic<parameters:Geometry_20model/Box_20with_20lithosphere_20boundary_20indicators/Z_20periodic>`
Expand Down Expand Up @@ -334,7 +334,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Radius at the bottom surface of the chunk. Units: \si{\meter}.
**Documentation:** Radius at the bottom surface of the chunk. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Chunk maximum latitude<parameters:Geometry_20model/Chunk/Chunk_20maximum_20latitude>`
Expand Down Expand Up @@ -379,7 +379,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Radius at the top surface of the chunk. Units: \si{\meter}.
**Documentation:** Radius at the top surface of the chunk. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Latitude repetitions<parameters:Geometry_20model/Chunk/Latitude_20repetitions>`
Expand Down Expand Up @@ -417,7 +417,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Radius at the bottom surface of the chunk. Units: \si{\meter}.
**Documentation:** Radius at the bottom surface of the chunk. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Chunk maximum latitude<parameters:Geometry_20model/Chunk_20with_20lithosphere_20boundary_20indicators/Chunk_20maximum_20latitude>`
Expand All @@ -444,7 +444,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Radius at the top surface of the lower chunk, where it merges with the upper chunk. Units: \si{\meter}.
**Documentation:** Radius at the top surface of the lower chunk, where it merges with the upper chunk. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Chunk minimum latitude<parameters:Geometry_20model/Chunk_20with_20lithosphere_20boundary_20indicators/Chunk_20minimum_20latitude>`
Expand All @@ -471,7 +471,7 @@ In 3d, inner and outer indicators are treated as in 2d. If the opening angle is

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Radius at the top surface of the chunk. Units: \si{\meter}.
**Documentation:** Radius at the top surface of the chunk. Units: $\text{m}$.
::::

::::{dropdown} __Parameter:__ {ref}`Inner chunk radius repetitions<parameters:Geometry_20model/Chunk_20with_20lithosphere_20boundary_20indicators/Inner_20chunk_20radius_20repetitions>`
Expand Down Expand Up @@ -729,7 +729,7 @@ If the function you are describing represents a vector-valued function with mult

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Radius of the sphere. Units: \si{\meter}.
**Documentation:** Radius of the sphere. Units: $\text{m}$.
::::

(parameters:Geometry_20model/Spherical_20shell)=
Expand Down Expand Up @@ -771,7 +771,7 @@ In either case, this parameter is ignored unless the opening angle of the domain

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Inner radius of the spherical shell. Units: \si{\meter}.
**Documentation:** Inner radius of the spherical shell. Units: $\text{m}$.

:::{note}
The default value of 3,481,000 m equals the radius of a sphere with equal volume as Earth (i.e., 6371 km) minus the average depth of the core-mantle boundary (i.e., 2890 km).
Expand All @@ -784,7 +784,7 @@ The default value of 3,481,000 m equals the radius of a sphere with equal volume

**Pattern:** [List of <[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]> of length 0...4294967295 (inclusive)]

**Documentation:** List of radial values for the custom mesh scheme. Units: $\si{m}$. A list of radial values subdivides the spherical shell at specified radii. The list must be strictly ascending, and the first value must be greater than the inner radius while the last must be less than the outer radius.
**Documentation:** List of radial values for the custom mesh scheme. Units: $\text{m}$. A list of radial values subdivides the spherical shell at specified radii. The list must be strictly ascending, and the first value must be greater than the inner radius while the last must be less than the outer radius.
::::

::::{dropdown} __Parameter:__ {ref}`Number of slices<parameters:Geometry_20model/Spherical_20shell/Number_20of_20slices>`
Expand All @@ -811,7 +811,7 @@ The default value of 3,481,000 m equals the radius of a sphere with equal volume

**Pattern:** [Double 0...MAX_DOUBLE (inclusive)]

**Documentation:** Outer radius of the spherical shell. Units: \si{\meter}.
**Documentation:** Outer radius of the spherical shell. Units: $\text{m}$.

:::{note}
The default value of 6,336,000 m equals the radius of a sphere with equal volume as Earth (i.e., 6371 km) minus the average depth of the mantle-crust interface (i.e., 35 km).
Expand Down
4 changes: 2 additions & 2 deletions doc/sphinx/parameters/Gravity_20model.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ If the function you are describing represents a vector-valued function with mult

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** Magnitude of the radial gravity vector at the bottom of the domain. &lsquo;Bottom&rsquo; means themaximum depth in the chosen geometry, and for example represents the core-mantle boundary in the case of the &lsquo;spherical shell&rsquo; geometry model, and the center in the case of the &lsquo;sphere&rsquo; geometry model. Units: \si{\meter\per\second\squared}.
**Documentation:** Magnitude of the radial gravity vector at the bottom of the domain. &lsquo;Bottom&rsquo; means themaximum depth in the chosen geometry, and for example represents the core-mantle boundary in the case of the &lsquo;spherical shell&rsquo; geometry model, and the center in the case of the &lsquo;sphere&rsquo; geometry model. Units: $\text{m}\text{s}^{-2}$.
::::

::::{dropdown} __Parameter:__ {ref}`Magnitude at surface<parameters:Gravity_20model/Radial_20linear/Magnitude_20at_20surface>`
Expand All @@ -123,7 +123,7 @@ If the function you are describing represents a vector-valued function with mult

**Pattern:** [Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]

**Documentation:** Magnitude of the radial gravity vector at the surface of the domain. Units: \si{\meter\per\second\squared}.
**Documentation:** Magnitude of the radial gravity vector at the surface of the domain. Units: $\text{m}\text{s}^{-2}$.
::::

(parameters:Gravity_20model/Vertical)=
Expand Down
Loading
Loading