Skip to content

Commit c138f35

Browse files
committed
Make it work for n = 3
We need to prime the pump a bit by calling the time stepper first with n = 1 and continue up to 3 but otherwise it works and with a longer timestep than with clamping.
1 parent 201ac76 commit c138f35

File tree

1 file changed

+52
-15
lines changed

1 file changed

+52
-15
lines changed

notebooks/rainier-monolithic.ipynb

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,7 @@
248248
"ρ_I = Constant(ice_density)\n",
249249
"g = Constant(gravity)\n",
250250
"\n",
251-
"\n",
252-
"#n = Constant(glen_flow_law)\n",
253-
"n = Constant(1.0)\n",
254-
"\n",
251+
"n = Constant(glen_flow_law)\n",
255252
"\n",
256253
"P = ρ_I * g * h\n",
257254
"S_n = inner(grad(s), grad(s))**((n - 1) / 2)\n",
@@ -412,7 +409,7 @@
412409
"\n",
413410
"sparams = {\n",
414411
" \"solver_parameters\": {\n",
415-
" \"snes_monitor\": \":rainier-output-monolothic.txt\",\n",
412+
" \"snes_monitor\": \":rainier-output-initial.log\",\n",
416413
" \"snes_type\": \"newtonls\",\n",
417414
" \"snes_max_it\": 200,\n",
418415
" \"snes_linesearch_type\": \"nleqerr\",\n",
@@ -462,13 +459,10 @@
462459
"metadata": {},
463460
"outputs": [],
464461
"source": [
465-
"\"\"\"\n",
466462
"num_continuation_steps = 5\n",
467463
"for exponent in np.linspace(1.0, 3.0, num_continuation_steps):\n",
468464
" n.assign(exponent)\n",
469-
" momentum_solver.solve()\n",
470-
"\"\"\"\n",
471-
"momentum_solver.solve()"
465+
" momentum_solver.solve()"
472466
]
473467
},
474468
{
@@ -586,7 +580,7 @@
586580
"source": [
587581
"tableau = irksome.BackwardEuler()\n",
588582
"t = Constant(0.0)\n",
589-
"dt = Constant(1.0 / 12)\n",
583+
"dt = Constant(1.0 / 6)\n",
590584
"\n",
591585
"lower = firedrake.Function(W)\n",
592586
"upper = firedrake.Function(W)\n",
@@ -597,7 +591,7 @@
597591
"\n",
598592
"bparams = {\n",
599593
" \"solver_parameters\": {\n",
600-
" \"snes_vi_monitor\": None,\n",
594+
" \"snes_monitor\": \":rainier-output-vi.log\",\n",
601595
" \"snes_type\": \"vinewtonrsls\",\n",
602596
" \"snes_max_it\": 200,\n",
603597
" #\"snes_linesearch_type\": \"nleqerr\",\n",
@@ -621,6 +615,39 @@
621615
"The good part: run the model for 500 years of simulation time."
622616
]
623617
},
618+
{
619+
"cell_type": "code",
620+
"execution_count": null,
621+
"id": "ffbd91d3-b0e4-416d-822d-2dd8f5f78a89",
622+
"metadata": {},
623+
"outputs": [],
624+
"source": [
625+
"n.assign(1.0)\n",
626+
"solver.advance(bounds=bounds)"
627+
]
628+
},
629+
{
630+
"cell_type": "code",
631+
"execution_count": null,
632+
"id": "f360f81b-5c4f-4615-8937-b8f316099a0d",
633+
"metadata": {},
634+
"outputs": [],
635+
"source": [
636+
"n.assign(2.0)\n",
637+
"solver.advance(bounds=bounds)"
638+
]
639+
},
640+
{
641+
"cell_type": "code",
642+
"execution_count": null,
643+
"id": "3b9f978b-d4ca-4c74-82c8-cf159e527c50",
644+
"metadata": {},
645+
"outputs": [],
646+
"source": [
647+
"n.assign(glen_flow_law)\n",
648+
"solver.advance(bounds=bounds)"
649+
]
650+
},
624651
{
625652
"cell_type": "code",
626653
"execution_count": null,
@@ -633,11 +660,9 @@
633660
"\n",
634661
"final_time = 500.0\n",
635662
"num_steps = int(final_time / float(dt))\n",
636-
"progress_bar = trange(num_steps)\n",
637-
"for step in progress_bar:\n",
663+
"for step in trange(num_steps):\n",
638664
" solver.advance(bounds=bounds)\n",
639665
" h = w.subfunctions[3]\n",
640-
" progress_bar.set_description(str(h.dat.data_ro.min()))\n",
641666
" s.interpolate(b + h)\n",
642667
" a.interpolate(smb(s))\n",
643668
"\n",
@@ -678,7 +703,7 @@
678703
"metadata": {},
679704
"outputs": [],
680705
"source": [
681-
"u, M, τ = z.subfunctions\n",
706+
"u, M, τ, h = w.subfunctions\n",
682707
"\n",
683708
"fig, axes = plt.subplots()\n",
684709
"axes.set_aspect(\"equal\")\n",
@@ -725,6 +750,18 @@
725750
"from IPython.display import HTML\n",
726751
"HTML(animation.to_html5_video())"
727752
]
753+
},
754+
{
755+
"cell_type": "code",
756+
"execution_count": null,
757+
"id": "53927034-2a55-4391-b0af-ac84f555f26a",
758+
"metadata": {},
759+
"outputs": [],
760+
"source": [
761+
"volumes = [firedrake.assemble(h * dx) for h in hs]\n",
762+
"fig, ax = plt.subplots()\n",
763+
"ax.plot(volumes);"
764+
]
728765
}
729766
],
730767
"metadata": {

0 commit comments

Comments
 (0)