-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce86f1d
commit f58625e
Showing
10 changed files
with
2,027 additions
and
598 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,344 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import warmth\n", | ||
"from pathlib import Path" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"0.03" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"1e-6*30e3" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"0.03" | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"30e-3" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"maps_dir = Path(\"./data/\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"model = warmth.Model()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"inputs = model.builder.input_horizons_template" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#Add surface grids to the table. You can use other method as well\n", | ||
"inputs.loc[0]=[0,\"0.gri\",None,\"Onlap\"]\n", | ||
"inputs.loc[1]=[66,\"66.gri\",None,\"Onlap\"]\n", | ||
"inputs.loc[2]=[100,\"100.gri\",None,\"Onlap\"]\n", | ||
"inputs.loc[3]=[163,\"163.gri\",None,\"Erosive\"]\n", | ||
"inputs.loc[4]=[168,\"168.gri\",None,\"Erosive\"]\n", | ||
"inputs.loc[5]=[170,\"170.gri\",None,\"Onlap\"]\n", | ||
"inputs.loc[6]=[182,\"182.gri\",None,\"Erosive\"]\n", | ||
"model.builder.input_horizons=inputs\n", | ||
"inputs" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"inc = 2000\n", | ||
"model.builder.define_geometry(maps_dir/\"0.gri\",xinc=inc,yinc=inc,fformat=\"irap_binary\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"model.builder.grid.__dict__" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"model.builder.extract_nodes(4,maps_dir)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"model.parameters.time_start" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from warmth.data import haq87\n", | ||
"model.builder.set_eustatic_sea_level(haq87)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"for i in model.builder.iter_node():\n", | ||
" i.rift=[[182,175]]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"model.simulator.simulate_every = 1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"model.builder.n_valid_node" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"model.builder.node" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"model.builder.iter_node()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "NameError", | ||
"evalue": "name 'model' is not defined", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", | ||
"\u001b[1;32m/workspaces/warmth/docs/notebooks/3D_simulation.ipynb Cell 14\u001b[0m line \u001b[0;36m1\n\u001b[0;32m----> <a href='vscode-notebook-cell://codespaces%2Bobscure-meme-qpw4jj4pgvp34j7v/workspaces/warmth/docs/notebooks/3D_simulation.ipynb#X45sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39mfor\u001b[39;00m i \u001b[39min\u001b[39;00m model\u001b[39m.\u001b[39mbuilder\u001b[39m.\u001b[39mnode:\n\u001b[1;32m <a href='vscode-notebook-cell://codespaces%2Bobscure-meme-qpw4jj4pgvp34j7v/workspaces/warmth/docs/notebooks/3D_simulation.ipynb#X45sdnNjb2RlLXJlbW90ZQ%3D%3D?line=1'>2</a>\u001b[0m \u001b[39mprint\u001b[39m(i)\n", | ||
"\u001b[0;31mNameError\u001b[0m: name 'model' is not defined" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"for i in model.builder.node:\n", | ||
" print(i)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%time\n", | ||
"model.simulator.run(save=True,purge=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"\n", | ||
"# interpolate and extrapolate the missing nodes\n", | ||
"# find nearby nodes from the array indexer_full_sim, which is sorted by x-index\n", | ||
"import itertools\n", | ||
"from subsheat3D.fixed_mesh_model import interpolateNode\n", | ||
"for ni in range(len(model.builder.nodes)):\n", | ||
" for nj in range(len(model.builder.nodes[ni])):\n", | ||
" if model.builder.nodes[ni][nj] is False:\n", | ||
" closest_x_up = []\n", | ||
" for j in range(ni,len(model.builder.nodes[nj])):\n", | ||
" matching_x = [ i[0] for i in model.builder.indexer_full_sim if i[0]==j ]\n", | ||
" closest_x_up = closest_x_up + list(set(matching_x))\n", | ||
" if len(matching_x)>0:\n", | ||
" break\n", | ||
" closest_x_down = []\n", | ||
" for j in range(ni-1,-1,-1):\n", | ||
" matching_x = [ i[0] for i in model.builder.indexer_full_sim if i[0]==j ]\n", | ||
" closest_x_down = closest_x_down + list(set(matching_x))\n", | ||
" if len(matching_x)>0:\n", | ||
" break\n", | ||
" closest_y_up = []\n", | ||
" for j in range(nj,len(model.builder.nodes[ni])):\n", | ||
" matching_y = [ i[1] for i in model.builder.indexer_full_sim if (i[1]==j and ((i[0] in closest_x_up) or i[0] in closest_x_down)) ]\n", | ||
" closest_y_up = closest_y_up + list(set(matching_y))\n", | ||
" if len(matching_y)>0:\n", | ||
" break\n", | ||
" closest_y_down = []\n", | ||
" for j in range(nj-1,-1,-1):\n", | ||
" matching_y = [ i[1] for i in model.builder.indexer_full_sim if (i[1]==j and (i[0] in closest_x_up or i[0] in closest_x_down) ) ]\n", | ||
" closest_y_down = closest_y_down + list(set(matching_y))\n", | ||
" if len(matching_y)>0:\n", | ||
" break\n", | ||
"\n", | ||
" interpolationNodes = [ model.builder.nodes[i[0]][i[1]] for i in itertools.product(closest_x_up+closest_x_down, closest_y_up+closest_y_down) ]\n", | ||
" interpolationNodes = [nn for nn in interpolationNodes if nn is not False]\n", | ||
" node = interpolateNode(interpolationNodes)\n", | ||
" node.X, node.Y = model.builder.grid.location_grid[ni,nj,:]\n", | ||
" model.builder.nodes[ni][nj] = node\n", | ||
" else:\n", | ||
" node = interpolateNode([model.builder.nodes[ni][nj]]) # \"interpolate\" the node from itself to make sure the same member variables exist at the end\n", | ||
" model.builder.nodes[ni][nj] = node\n", | ||
" # if (model.builder.nodes[ni][nj].Y>12000):\n", | ||
" # model.builder.nodes[ni][nj].crustRHP = (2e-6) * 4\n", | ||
" # model.builder.nodes[ni][nj].rhp = (2e-6) * 4\n", | ||
" model.builder.nodes[ni][nj].crustRHP = (2e0) * 1\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 15, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Rebuild/reload mesh at tti= 182\n", | ||
"Using 1D Node parameters NodeParameters1D(shf=0.03, hc=30000.0, hw=3600.0, hLith=130000.0, kLith=3.109, kCrust=2.5, kAsth=100, rhp=2, crustliquid=2500.0, crustsolid=2800.0, lithliquid=2700.0, lithsolid=3300.0, asthliquid=2700.0, asthsolid=3200.0, T0=5, Tm=1330.0, qbase=0.03)\n", | ||
"builing\n", | ||
"buildVertices\n" | ||
] | ||
}, | ||
{ | ||
"ename": "", | ||
"evalue": "", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[1;31mThe Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details." | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from warmth.mesh_model import run\n", | ||
"import os\n", | ||
"try:\n", | ||
" os.mkdir('mesh')\n", | ||
"except FileExistsError:\n", | ||
" pass\n", | ||
"try:\n", | ||
" os.mkdir('temp')\n", | ||
"except FileExistsError:\n", | ||
" pass\n", | ||
"run(model,start_time=model.parameters.time_start,end_time=0)\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.