underworld.scaling module
The scaling module provides units and scaling capabilities.
Functions
Dimensionalise a value. |
|
Returns the global scaling dictionary. |
|
Non-dimensionalize (scale) provided quantity. |
- underworld.scaling.dimensionalise(value, units)[source]
Dimensionalise a value.
- Parameters:
value (float, int) – The value to be assigned units.
units (pint units) – The units to be assigned.
- Returns:
pint quantity
- Return type:
dimensionalised value.
Example
>>> import underworld as uw >>> A = uw.scaling.dimensionalise(1.0, u.metre)
- underworld.scaling.non_dimensionalise(dimValue)[source]
Non-dimensionalize (scale) provided quantity.
This function uses pint to perform a dimension analysis and return a value scaled according to a set of scaling coefficients.
- Parameters:
dimValue (pint.Quantity) – A pint quantity.
- Returns:
The scaled value.
- Return type:
float
Example
>>> import underworld as uw >>> u = uw.scaling.units
>>> # Characteristic values of the system >>> half_rate = 0.5 * u.centimeter / u.year >>> model_height = 600e3 * u.meter >>> refViscosity = 1e24 * u.pascal * u.second >>> surfaceTemp = 0. * u.kelvin >>> baseModelTemp = 1330. * u.kelvin >>> baseCrustTemp = 550. * u.kelvin
>>> KL_meters = model_height >>> KT_seconds = KL_meters / half_rate >>> KM_kilograms = refViscosity * KL_meters * KT_seconds >>> Kt_degrees = (baseModelTemp - surfaceTemp) >>> K_substance = 1. * u.mole
>>> scaling_coefficients = uw.scaling.get_coefficients() >>> scaling_coefficients["[time]"] = KT_seconds >>> scaling_coefficients["[length]"] = KL_meters >>> scaling_coefficients["[mass]"] = KM_kilograms >>> scaling_coefficients["[temperature]"] = Kt_degrees >>> scaling_coefficients["[substance]"] -= K_substance
>>> # Get a scaled value: >>> gravity = uw.scaling.non_dimensionalise(9.81 * u.meter / u.second**2)