99# format_name: percent
1010# format_version: '1.3'
1111# jupytext_version: 1.11.2
12+ # kernelspec:
13+ # display_name: dolfinx-env
14+ # language: python
15+ # name: python3
1216# ---
1317
1418# %% [markdown]
113117
114118# %%
115119L , H = (1.2 , 1.0 )
116- Nx , Ny = (200 , 200 )
120+ Nx , Ny = (25 , 25 )
117121gamma = 1.0 / 6778
118122domain = mesh .create_rectangle (MPI .COMM_WORLD , [np .array ([0 , 0 ]), np .array ([L , H ])], [Nx , Ny ])
119123
@@ -669,10 +673,11 @@ def F_ext(v):
669673# parameters of the manual Newton method
670674max_iterations , relative_tolerance = 200 , 1e-8
671675
672- load_steps_1 = np .linspace (1.5 , 21 , 40 )
673- load_steps_2 = np .linspace ( 21 , 22.75 , 20 )[ 1 :]
676+ load_steps_1 = np .linspace (2 , 22.9 , 50 )
677+ load_steps_2 = np .array ([ 22.96 , 22.99 ])
674678load_steps = np .concatenate ([load_steps_1 , load_steps_2 ])
675- load_steps = np .concatenate ([np .linspace (1.1 , 22.3 , 100 )[:- 1 ]])
679+
680+ # load_steps = np.concatenate([np.linspace(1.1, 22.3, 100)[:-1]])
676681num_increments = len (load_steps )
677682results = np .zeros ((num_increments + 1 , 2 ))
678683
@@ -702,8 +707,6 @@ def constitutive_update():
702707external_operator_problem = SNESProblem (Du , F_replaced , J_replaced , bcs = bcs , petsc_options = petsc_options , system_update = constitutive_update )
703708
704709# %%
705- timer_total = common .Timer ("Total_timer" )
706- timer_total .start ()
707710for i , load in enumerate (load_steps ):
708711 q .value = load * np .array ([0 , - gamma ])
709712
@@ -721,14 +724,8 @@ def constitutive_update():
721724
722725 if len (points_on_process ) > 0 :
723726 results [i + 1 , :] = (- u .eval (points_on_process , cells )[0 ], load )
724- timer_total .stop ()
725- total_time = timer_total .elapsed ()[0 ]
726727
727728print (f"Slope stability factor: { - q .value [- 1 ]* H / c } " )
728- print (f"Total time: { total_time } " )
729-
730- # %%
731- external_operator_problem .performance_monitor
732729
733730# %% [markdown]
734731# ## Verification
@@ -768,34 +765,6 @@ def constitutive_update():
768765 plt .grid ()
769766 plt .legend ()
770767
771- # %%
772- external_operator_problem .performance_monitor
773-
774- # %%
775- import pickle
776- with open ("performance_monitor_100_100" , "wb" ) as f :
777- pickle .dump (external_operator_problem .performance_monitor , f )
778-
779- # %%
780- # pickle_file = Path("performance_monitor_200_200")
781- with open ("performance_monitor_200_200" , 'rb' ) as f :
782- performance_monitor_200_200 = pickle .load (f )
783-
784- # %%
785- summary_monitor = performance_monitor_200_200 .copy ()
786-
787- cols = ["matrix_assembling" , "vector_assembling" , "linear_solver" , "constitutive_model_update" ]
788- summary_monitor ["linear_solver" ] = summary_monitor ["nonlinear_solver" ] - summary_monitor ["matrix_assembling" ] - summary_monitor ["vector_assembling" ] - summary_monitor ["constitutive_model_update" ]
789-
790- fig , ax = plt .subplots (figsize = (10 , 5 ))
791- summary_monitor .plot (use_index = True , y = cols , kind = "bar" , stacked = True , ax = ax )
792-
793- # %%
794- fig , ax = plt .subplots (figsize = (10 , 5 ))
795- for col in cols :
796- summary_monitor [col ] = summary_monitor [col ] / (summary_monitor ["Newton_iterations" ]+ 1 )
797- summary_monitor .plot (use_index = True , y = cols , kind = "bar" , stacked = True , ax = ax )
798-
799768# %% [markdown]
800769# The slope profile reaching its stability limit:
801770
0 commit comments