Skip to content

Instantly share code, notes, and snippets.

@schymans
Last active June 30, 2017 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schymans/92f84f1a716be5b26b84f030af739175 to your computer and use it in GitHub Desktop.
Save schymans/92f84f1a716be5b26b84f030af739175 to your computer and use it in GitHub Desktop.
Demo
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import essm
class eq_test(essm.equations.Equation):
expr = 1 == 1
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Import standard variables from physics module\n",
"from essm.variables.physics.thermodynamics import lambda_E, c_pa\n",
"\n",
"# Define custom variables\n",
"class E_w(Variable):\n",
" \"\"\"Wet surface evaporation\n",
" (E in Priestley and Taylor, 1972))\n",
" \"\"\"\n",
" unit = kilogram/meter^2/second\n",
" latex_name = 'E'\n",
" \n",
"class H_w(Variable):\n",
" \"\"\"Wet surface sensible heat flux (positive outwards)\"\"\"\n",
" unit = joule/second/meter^2\n",
" latex_name = 'H'\n",
" \n",
"class q_a(Variable):\n",
" \"\"\"Specific humidity\"\"\"\n",
" unit = kilogram/meter^3\n",
" \n",
"class q_s(Variable):\n",
" \"\"\"Specific humidity at saturation\"\"\"\n",
" unit = kilogram/meter^3\n",
" \n",
"class s_PT(Variable):\n",
" \"\"\"Priestley-Taylor $\\partial q_s/\\partial T$\"\"\"\n",
" unit = kilogram/meter^3/kelvin\n",
" latex_name = 's'\n",
" \n",
"class T(Variable):\n",
" \"\"\"Temperature\"\"\"\n",
" unit = kelvin\n",
"\n",
"# Re-define `lambda_E` as `L_E` to have the same latex representation as in the paper\n",
"class L_E(lambda_E.definition):\n",
" \"\"\"Latent heat\"\"\" \n",
" latex_name = 'L'\n",
" default = lambda_E.definition.default\n",
" unit = lambda_E.definition.unit\n",
" \n",
"# Define `gamma_PT = c_pa/L_E` as in the paper\n",
"class gamma_PT(Variable):\n",
" \"\"\"Priestley-Taylor $\\gamma$\"\"\"\n",
" expr = c_pa/L_E\n",
" latex_name = r'\\gamma'"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath 7.6",
"language": "",
"name": "sagemath"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
},
"nav_menu": {},
"toc": {
"navigate_menu": true,
"number_sections": true,
"sideBar": true,
"threshold": 6,
"toc_cell": false,
"toc_section_display": "block",
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment