From 9aa18fb8377c2c992a0a63745e28d307d80b5293 Mon Sep 17 00:00:00 2001 From: Boris Kaus Date: Wed, 28 Feb 2024 17:03:17 +0100 Subject: [PATCH] update --- docs/Project.toml | 4 - docs/src/Subduction3D.md | 8 +- docs/src/assets/LaMEM_ModelFunctions.md | 7 - docs/src/assets/installation.md | 27 - docs/src/assets/installation_HPC.md | 67 --- docs/src/assets/juliasetup_LaPalma.md | 213 ------- docs/src/assets/juliasetup_TMSubduction.md | 556 ------------------- docs/src/assets/juliasetup_example_sphere.md | 172 ------ docs/src/assets/juliasetup_pluto.md | 18 - docs/src/assets/juliasetups.md | 144 ----- docs/src/assets/listfunctions.md | 13 - docs/src/assets/readtimesteps.md | 58 -- docs/src/assets/runlamem.md | 55 -- docs/src/listfunctions.md | 3 +- 14 files changed, 6 insertions(+), 1339 deletions(-) delete mode 100644 docs/src/assets/LaMEM_ModelFunctions.md delete mode 100644 docs/src/assets/installation.md delete mode 100644 docs/src/assets/installation_HPC.md delete mode 100644 docs/src/assets/juliasetup_LaPalma.md delete mode 100644 docs/src/assets/juliasetup_TMSubduction.md delete mode 100644 docs/src/assets/juliasetup_example_sphere.md delete mode 100644 docs/src/assets/juliasetup_pluto.md delete mode 100644 docs/src/assets/juliasetups.md delete mode 100644 docs/src/assets/listfunctions.md delete mode 100644 docs/src/assets/readtimesteps.md delete mode 100644 docs/src/assets/runlamem.md diff --git a/docs/Project.toml b/docs/Project.toml index 932879f6..8fc3e907 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,11 +1,7 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -GeophysicalModelGenerator = "3700c31b-fa53-48a6-808a-ef22d5a84742" -Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] Documenter = "1" Test = "1" -GeophysicalModelGenerator = "0.4 - 0.6" -Plots = "1" \ No newline at end of file diff --git a/docs/src/Subduction3D.md b/docs/src/Subduction3D.md index 90198445..e8843484 100644 --- a/docs/src/Subduction3D.md +++ b/docs/src/Subduction3D.md @@ -54,10 +54,10 @@ AddBox!(model, xlim=(-1000,-810), ylim=(0,1000), zlim=(-80,0), phase=Lithospheri There is a simple way to have a quick look at this setup by using the `Plots.jl` package: -````@example Subduction3D +```julia using Plots plot_cross_section(model, y=100, field=:phase) -```` +``` Which will give the following plot: ![2D cross section](assets/SubductionSetup_3D.png) @@ -100,9 +100,9 @@ LaMEM Model setup ## 4. Run the model Add this stage, we are ready to run the simulation. On my machine it takes around 4 seconds per timestep on 8 cores: -````@example Subduction3D +```julia run_lamem(model, 8) -```` +``` The results looks like this with paraview: ![3D subduction paraview](assets/Subduction_3D_pv.png) diff --git a/docs/src/assets/LaMEM_ModelFunctions.md b/docs/src/assets/LaMEM_ModelFunctions.md deleted file mode 100644 index 8cd85cfb..00000000 --- a/docs/src/assets/LaMEM_ModelFunctions.md +++ /dev/null @@ -1,7 +0,0 @@ -# List functions -These are all the functions that are provided for the LaMEM Julia Setup interface -```@autodocs -Modules = [LaMEM.LaMEM_Model] -``` - - diff --git a/docs/src/assets/installation.md b/docs/src/assets/installation.md deleted file mode 100644 index ac933cda..00000000 --- a/docs/src/assets/installation.md +++ /dev/null @@ -1,27 +0,0 @@ -# Installation - -Installing LaMEM can simply be done through the package manager: -```julia -julia>] -pkg>add LaMEM -``` -which will download the binaries along with PETSc and mpiexec for your system. - -You can test if it works on your machine with -```julia -pkg> test LaMEM -``` - -### Running LaMEM from the julia REPL -Running LaMEM from within julia can be done with the `run_lamem` function: - -```@docs -LaMEM.run_lamem -``` - -### Running LaMEM from outside julia -If you, for some reason, do not want to run LaMEM through julia but instead directly from the terminal or powershell, you will have to add the required dynamic libraries and executables. -Do this with: -```@docs -LaMEM.show_paths_LaMEM -``` \ No newline at end of file diff --git a/docs/src/assets/installation_HPC.md b/docs/src/assets/installation_HPC.md deleted file mode 100644 index 902397e5..00000000 --- a/docs/src/assets/installation_HPC.md +++ /dev/null @@ -1,67 +0,0 @@ -# Installation on HPC systems - -Installing LaMEM on high performance computer (HPC) systems can be complicated, because you will have to compile PETSc with the correct dependencies for that system. -The reason is that HPC systems use MPI versions that are specifically tailored/compiled for that system. - -> Warning: the explanation below is still somewhat experimental and may not work on your system -> The best approach of running LaMEM on large HPC systems remains to install the correct version of PETSc using the locally recommended MPI libraries and install the correct version of LaMEM with that. You can still save the input setup to file, for the correct number or processors using LaMEM.jl. The locally generated `*.dat` file will still work. - -Luckily there is a solution thanks to the great work of `@eschnett` and colleagues, who developed [MPITrampoline](https://github.com/eschnett/MPItrampoline) which is an intermediate layer between the HPC-system-specific MPI libraries and the precompiled `LaMEM` binaries. - -It essentially consists of two steps: - 1) compile a small package ([MPIwrapper](https://github.com/eschnett/MPIwrapper)) - 2) make sure that you download the version of `MAGEMin` that was compiled versus `MPItrampoline`. - -Here step-by-step instructions (for Linux, as that is what essentially all HPC systems use): - - -* Download [MPIwrapper](https://github.com/eschnett/MPIwrapper): -```bash -$git clone https://github.com/eschnett/MPIwrapper.git -$cd MPIwrapper -``` - -* Install it after making sure that `mpiexec` points to the one you want (you may have to load some modules, depending on your system): -```bash -$cmake -S . -B build -DMPIEXEC_EXECUTABLE=mpiexec -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=$HOME/mpiwrapper -$cmake --build build -$cmake --install build -``` -At this stage, `MPItrampoline` is installed in `$HOME/mpiwrapper` - -* Set the correct wrapper: -``` -$export MPITRAMPOLINE_LIB=$HOME/mpiwrapper/lib64/libmpiwrapper.so -``` -Depending on the system it may be called `lib` instead of `lib64` (check!). - -* Start julia and install the `MPI` and `MPIPreferences` packages: -```julia -$julia -julia> ] -pkg>add MPI, MPIPreferences -``` - -* Set the preference to use `MPItrampoline` -```julia -julia> using MPIPreferences; MPIPreferences.use_jll_binary("MPItrampoline_jll") -┌ Info: MPIPreferences unchanged -└ binary = "MPItrampoline_jll" -``` - -* Load `MPI` and verify it is the correct one -```julia -julia> using MPI -julia> MPI.Get_library_version() -"MPIwrapper 2.10.3, using MPIABI 2.9.0, wrapping:\nOpen MPI v4.1.4, package: Open MPI boris@Pluton Distribution, ident: 4.1.4, repo rev: v4.1.4, May 26, 2022" -``` -After this, restart julia (this only needs to be done once, next time all is fine). - -* Now load `LaMEM` and check that it uses the `mpitrampoline` version: -```julia -julia> using MPI,LaMEM -julia> LaMEM.LaMEM_jll.host_platform -Linux x86_64 {cxxstring_abi=cxx11, julia_version=1.8.1, libc=glibc, libgfortran_version=5.0.0, mpi=mpitrampoline} -``` - -At this stage the precompiled version of `LaMEM` should be useable on that system. diff --git a/docs/src/assets/juliasetup_LaPalma.md b/docs/src/assets/juliasetup_LaPalma.md deleted file mode 100644 index 014e940b..00000000 --- a/docs/src/assets/juliasetup_LaPalma.md +++ /dev/null @@ -1,213 +0,0 @@ -# La Palma Volcano setup - -In this example, we will show how to create a 3D model setup for the 2020 La Palma eruption. We mainly focus on the LaMEM part; see the [GeophysicalModelGenerator](https://github.com/JuliaGeodynamics/GeophysicalModelGenerator.jl) package for more details on how to plot earthquake data etc. - -#### 1. Load packages & topography -Let's start with what we need: -```julia -julia> using LaMEM, GeophysicalModelGenerator, GMT, Plots -Loading GMT routines within GMG -WARNING: using GMT.meshgrid in module GeophysicalModelGenerator conflicts with an existing identifier. -adding Plots.jl plotting extensions for LaMEM -``` - -Load the topography, choose a projection point & project the topography to cartesian coordinates: -```julia -julia> Topo = ImportTopo(lon = [-18.7, -17.1], lat=[28.0, 29.2], file="@earth_relief_03s.grd"); -julia> proj = ProjectionPoint(Lon=-17.84, Lat=28.56); -julia> Topo_cart = Convert2CartData(Topo, proj) -CartData - size : (1921, 1441, 1) - x ϵ [ -86.09445705828863 : 73.67229892155609] - y ϵ [ -63.5531883197492 : 73.28446155584604] - z ϵ [ -4.38352685546875 : 2.414] - fields : (:Topography,) - attributes: ["note"] -``` -This shows the dimensions of our domain in kilometers. The issue is that this projected topography is not an orthogonal grid, but (slightly) distorted. In any case, we see the approximate dimensions of the grid (in horizontal directions), so we can create an orthogonal grid on which to project this: - -```julia -julia> Topo_LaMEM = CartData(XYZGrid(-70:.2:70,-60:.2:70,0)); -julia> Topo_LaMEM = ProjectCartData(Topo_LaMEM, Topo, proj) -``` - -We can plot it with: -```julia -julia> plot_topo(Topo_LaMEM, clim=(-4,4)) -``` - -![LaPalma_topo](LaPalma_topo.png) - - -#### 2. LaMEM Model setup - -Next, we generate a model setup for LaMEM with: -```julia -julia> model = Model(Grid(x=[-50.,50.], y=[-40.,40.], z=[-80,15] , nel=(64,64,32)), - BoundaryConditions(temp_bot=1350, open_top_bound=1), - Scaling(GEO_units(stress=1e9Pa, length=1km)), - Time(nstep_max=20) ) -LaMEM Model setup -| -|-- Scaling : GeoParams.Units.GeoUnits{GEO} -|-- Grid : nel=(64, 64, 32); xϵ(-50.0, 50.0), yϵ(-40.0, 40.0), zϵ(-80.0, 15.0) -|-- Time : nstep_max=20; nstep_out=1; time_end=1.0; dt=0.05 -|-- Boundary conditions : noslip=[0, 0, 0, 0, 0, 0] -|-- Solution parameters : eta_min=1.0e18; eta_max=1.0e25; eta_ref=1.0e20; act_temp_diff=0 -|-- Solver options : direct solver; superlu_dist; penalty term=10000.0 -|-- Model setup options : Type=files; -|-- Output options : filename=output; pvd=1; avd=0; surf=0 -|-- Materials : 0 phases; -``` - -##### Set geotherm and phases -We can set an initial constant, linear, geotherm with: -```julia -julia> Z = model.Grid.Grid.Z; -julia> Geotherm=30 -julia> model.Grid.Temp = -Z.*Geotherm; -``` -We will cutoff extreme values with: -```julia -julia> model.Grid.Temp[model.Grid.Temp.<20] .= 20; -julia> model.Grid.Temp[model.Grid.Temp.>1350] .= 1350; -julia> model.Grid -LaMEM grid with constant Δ: - nel : ([64], [64], [32]) - marker/cell : (3, 3, 3) - x ϵ [-50.0 : 50.0] - y ϵ [-40.0 : 40.0] - z ϵ [-80.0 : 15.0] - Phases : range ϵ [0 - 0] - Temp : range ϵ [20.0 - 1350.0] -``` - -Set `Phases` to two everywhere: -```julia -julia> model.Grid.Phases .= 2; -``` - -Now set points above the topography to zero (will be air later), the ones above the topography but below zero to 'water` and below 40 km to mantle (if we had a Moho surface we could use that): -```julia - julia> AboveSurface!(model, Topo_LaMEM, phase=0, T=0) - julia> model.Grid.Phases[Z.<-0 .&& model.Grid.Phases .== 0] .= 1; - julia> model.Grid.Phases[Z.<-40] .= 3; -``` - -Finally, we define some magma chambers: -```julia -julia> AddSphere!(model, cen=(0,0,-35), radius=5, phase=ConstantPhase(5), T=ConstantTemp(1200)); -julia> AddEllipsoid!(model, cen=(-1,0,-11), axes=(3,3,8), StrikeAngle=225, DipAngle=45, phase=ConstantPhase(5), T=ConstantTemp(1200)); -julia> AddEllipsoid!(model, cen=(-0,0,-23), axes=(8,8,2), StrikeAngle=0, DipAngle=0, phase=ConstantPhase(5), T=ConstantTemp(1200)); -``` - - We can plot a cross-section through the model: -```julia - julia> plot_cross_section(model, x=0, field=:phase) -``` - ![LaPalma_CrossSection](LaPalma_CrossSection.png) - - -##### Set material properties - -First, we set air and water properties: -```julia -julia> air = set_air(alpha=3e-5, G=1e10, nu=0.2, ch=10e6, fr=30) -Phase 0 (air): - rho = 100.0 - eta = 1.0e17 - G = 1.0e10 - nu = 0.2 - ch = 1.0e7 - fr = 30.0 - alpha = 3.0e-5 - Cp = 1000.0 - k = 30.0 -julia> water=deepcopy(air); water.Name="water"; water.ID=1 -``` -Next, we set the crust: -```julia -julia> crust = Phase(Name="Crust", ID=2, rho=2900, alpha=3e-5, disl_prof="Mafic_Granulite-Ranalli_1995", - G=3e10, nu=0.2, k=3, Cp=1000, ch=10e6, fr=30) -Phase 2 (Crust): - rho = 2900.0 - disl_prof = Mafic_Granulite-Ranalli_1995 - G = 3.0e10 - nu = 0.2 - ch = 1.0e7 - fr = 30.0 - alpha = 3.0e-5 - Cp = 1000.0 - k = 3.0 -``` -The mantle is done as a copy of that, while changing a few parameters: -```julia - julia> mantle = copy_phase(crust, Name="Mantle", ID=3, rho=3320.0, disl_prof="Dry_Olivine-Ranalli_1995", G=6.5e10, k=3.3); -``` -And we define two different types of magma: -```julia -julia> andesite = Phase(Name="andesitic_magma",ID=4,rho=2700, alpha=3e-5, eta=1e18, G=1.5e10, nu=0.2, k=3, Cp=1000, T=980, ch=1e7, fr=30); -julia> dacite = copy_phase(andesite,Name="dacite_magma", ID=5, rho=2575.0, eta=1e19, T=800.0) -``` - -Now we add all of this to the model: -```julia -julia> rm_phase!(model) -julia> add_phase!(model, air, water, crust, mantle, andesite, dacite) -``` -And check that we indeed have 6 phases: -```julia -julia> model -LaMEM Model setup -| -|-- Scaling : GeoParams.Units.GeoUnits{GEO} -|-- Grid : nel=(64, 64, 32); xϵ(-50.0, 50.0), yϵ(-40.0, 40.0), zϵ(-80.0, 15.0) -|-- Time : nstep_max=50; nstep_out=1; time_end=1.0; dt=0.05 -|-- Boundary conditions : noslip=[0, 0, 0, 0, 0, 0] -|-- Solution parameters : eta_min=1.0e18; eta_max=1.0e25; eta_ref=1.0e20; act_temp_diff=0 -|-- Solver options : direct solver; superlu_dist; penalty term=10000.0 -|-- Model setup options : Type=files; -|-- Output options : filename=output; pvd=1; avd=0; surf=0 -|-- Materials : 0 phases; -``` - -##### Add topography to model -We can add the topography grid that we created earlier to the model with: -```julia -julia> add_topography!(model, Topo_LaMEM) -``` - -##### Set solver options - -You will want to use a multigrid solver in this case: -```julia -julia> model.Solver = Solver(SolverType="multigrid", MGLevels=4) -``` - -### 3. Run LaMEM -Running LaMEM is simple; here on 4 processors: -```julia -julia> run_lamem(model, 4) -Saved file: Model3D.vts -Written LaMEM topography file: topography.txt -Writing LaMEM marker file -> ./markers/mdb.00000000.dat -Writing LaMEM marker file -> ./markers/mdb.00000001.dat -Writing LaMEM marker file -> ./markers/mdb.00000002.dat -Writing LaMEM marker file -> ./markers/mdb.00000003.dat --------------------------------------------------------------------------- - Lithosphere and Mantle Evolution Model - Compiled: Date: Apr 7 2023 - Time: 22:11:23 - Version : 1.2.4 --------------------------------------------------------------------------- - STAGGERED-GRID FINITE DIFFERENCE CANONICAL IMPLEMENTATION --------------------------------------------------------------------------- -Parsing input file : output.dat -Finished parsing input file : output.dat --------------------------------------------------------------------------- -Scaling parameters: - Temperature : 1000. [C/K] - Length : 1000. [m] - Viscosity : 1e+20 [Pa*s] - Stress : 1e+09 [Pa] --------------------------------------------------------------------------- -``` \ No newline at end of file diff --git a/docs/src/assets/juliasetup_TMSubduction.md b/docs/src/assets/juliasetup_TMSubduction.md deleted file mode 100644 index a4c20589..00000000 --- a/docs/src/assets/juliasetup_TMSubduction.md +++ /dev/null @@ -1,556 +0,0 @@ -# 2D Thermomechanical subduction model - -In this example, we will show how to create a 2D thermomechanical model of subduction. Here the setup is saved into a julia script. First create a textfile called `TM_Subduction_example.jl` in your current directory. The easiest is to use [Visual Studio Code](https://code.visualstudio.com) for this, but you can in principle use any text editor. - -#### 1. Load necessary packages -Next start julia in the directory where you saved `TM_Subduction_example.jl`, or go to correct directory within julia - -Note that you can do the following steps directy from the julia `REPL` (command prompt), or you can write them in `TM_Subduction_example.jl` and run that file by typing - -```julia -julia> include("TM_Subduction_example.jl") -``` - -We get started by loading the required packages: - -``` -using LaMEM, GeophysicalModelGenerator, Plots -``` - -#### 2. LaMEM model setup - -The setup will include 6 different materials with the following ID's: - -``` -# material id's -# 0: asthenosphere -# 1: oceanic crust -# 2: oceanic lithosphere -# 3: continental crust -# 4: continental lithosphere -# 5: air layer -``` - -``` -model = Model(Grid( x = [-2000.,2000.], - y = [-2.5,2.5], # <- model is 2D, size in y-direction is choosen to be close to a cube shape for the cell - z = [-660,40] , - nel = (512,1,128) ), - - BoundaryConditions( temp_bot = 1565.0, - temp_top = 20.0, - open_top_bound = 1), - Scaling(GEO_units( temperature = 1000, - stress = 1e9Pa, - length = 1km, - viscosity = 1e20Pa*s) ), - Time(nstep_max=20) ) -``` - -This initializes the initial LaMEM model setup with a number of default options. On the `REPL` it will show the following info - -```julia -LaMEM Model setup -| -|-- Scaling : GeoParams.Units.GeoUnits{GEO} -|-- Grid : nel=(512, 1, 128); xϵ(-2000.0, 2000.0), yϵ(-8.0, 8.0), zϵ(-660.0, 40.0) -|-- Time : nstep_max=20; nstep_out=1; time_end=1.0; dt=0.05 -|-- Boundary conditions : noslip=[0, 0, 0, 0, 0, 0] -|-- Solution parameters : eta_min=1.0e18; eta_max=1.0e25; eta_ref=1.0e20; act_temp_diff=0 -|-- Solver options : direct solver; superlu_dist; penalty term=10000.0 -|-- Model setup options : Type=files; -|-- Output options : filename=output; pvd=1; avd=0; surf=0 -|-- Materials : 0 phases; -``` - -In this case we assume that we have dimensions in kilometers and times in million years (the default). - -##### Inspecting/modifying parameters -Each of the parameters in this model setup can be modified. The easiest way to see what is available is by using the `REPL`. If you type - -```julia -julia> model. -``` - -and now use your `TAB` button, you will see all the fields within the `model` structure: - -```julia -julia> model. -BoundaryConditions FreeSurface Grid Materials ModelSetup Output Scaling SolutionParams -Solver Time -``` - -If you want to see which timestepping parameters are set, you type: - -``` -julia> model.Time -LaMEM Timestepping parameters: - time_end = 1.0 - dt = 0.05 - dt_min = 0.01 - dt_max = 0.2 - dt_out = 0.2 - inc_dt = 0.1 - CFL = 0.5 - CFLMAX = 0.8 - nstep_max = 20 - nstep_out = 1 - nstep_rdb = 100 - nstep_ini = 1 - time_tol = 1.0e-8 -``` - -The parameters that are changed from the default settings are highlighted in blue (not visible on this markdown document, but visible in the REPL). - -If you want to see what each of these parameters mean, you can get some basic help with: - -```julia -help?> Time -search: Time time Timer time_ns timedwait mtime ctime @time @timev @timed @time_imports @showtime optimize_ticks optimize_datetime_ticks Read_LaMEM_timestep - - Structure that contains the LaMEM timestepping information. An explanation of the paramneters is given in the struct `Time_info` - • time_end::Float64: simulation end time - • dt::Float64: initial time step - • dt_min::Float64: minimum time step (declare divergence if lower value is attempted) - • dt_max::Float64: maximum time step - • dt_out::Float64: output step (output at least at fixed time intervals) - • inc_dt::Float64: time step increment per time step (fraction of unit) - • CFL::Float64: CFL (Courant-Friedrichs-Lewy) criterion - • CFLMAX::Float64: CFL criterion for elasticity - • nstep_max::Int64: maximum allowed number of steps (lower bound: timeend/dtmax) - • nstep_out::Int64: save output every n steps; Set this to -1 to deactivate saving output - • nstep_rdb::Int64: save restart database every n steps - • num_dt_periods::Int64: number of time stepping periods - • time_dt_periods::Vector{Int64}: timestamps where timestep should be fixed (first entry has to 0) - • step_dt_periods::Vector{Float64}: target timesteps ar timestamps above - • nstep_ini::Int64: save output for n initial steps - • time_tol::Float64: relative tolerance for time comparisons -``` - -If you want to change one of the parameters, say the maximum number of timesteps, you can do that with: - -```julia -julia> model.Time.nstep_max=100 -100 -``` - -You can verify that this has been changed with: - -```julia -julia> model.Time -LaMEM Timestepping parameters: - time_end = 1.0 - dt = 0.05 - dt_min = 0.01 - dt_max = 0.2 - dt_out = 0.2 - inc_dt = 0.1 - CFL = 0.5 - CFLMAX = 0.8 - nstep_max = 100 - nstep_out = 1 - nstep_rdb = 100 - nstep_ini = 1 - time_tol = 1.0e-8 -``` - -##### Set timestepping parameters -Ok, lets change a few parameters at the same time. Here the maximum time (`time_end`) is set to a large value (2000 Myrs) as we want to limit the simulation using `nstep_max = 400`, which implies that we will perform 400 timesteps - -```julia -model.Time = Time( time_end = 2000.0, - dt = 0.001, - dt_min = 0.000001, - dt_max = 0.1, - nstep_max = 400, - nstep_out = 10 - ) -``` - -Note that you can achieve the same results with: - -```julia -model.Time.time_end = 2000.0 -model.Time.dt = 0.001 -model.Time.dt_min = 0.000001 -model.Time.dt_max = 0.1 -model.Time.nstep_max = 400 -model.Time.nstep_out = 10 -``` - -##### Set solution parameters -We activate shear heating and adiabatic heating, as well as thermal diffusion, and set the minimum and maximum viscosities of the model as: - -```julia -model.SolutionParams = SolutionParams( shear_heat_eff = 1.0, - Adiabatic_Heat = 1.0, - act_temp_diff = 1, - eta_min = 5e18, - eta_ref = 1e21, - eta_max = 1e25, - min_cohes = 1e3 - ) -``` - -##### Set surface topography -In our simulation, we want to take a free surface into account. In LaMEM that is done with a sticky air layer (phase 5 here), combined with a mesh that tracks the location of the free surface. You need to activate the free surface, tell LaMEM which phase is the sticky air phase and what the initial free surface level is at the beginning of the simulation (0 km). -Do that with: - -```julia -model.FreeSurface = FreeSurface( surf_use = 1, # free surface activation flag - surf_corr_phase = 1, # air phase ratio correction flag (due to surface position) - surf_level = 0.0, # initial level - surf_air_phase = 5, # phase ID of sticky air layer - surf_max_angle = 40.0 # maximum angle with horizon (smoothed if larger)) - ) -``` - -##### Set model output -We update the list of fields saved as output: - -```julia -model.Output = Output( out_density = 1, - out_j2_strain_rate = 1, - out_surf = 1, - out_surf_pvd = 1, - out_surf_topography = 1, - out_j2_dev_stress = 1, - out_pressure = 1, - out_temperature = 1, ) -``` - -##### Set some background properties, later overwritten -The model geometry in LaMEM is defined by two arrays: `model.Grid.Temp` and `model.Grid.Phase` which sets the initial temperature and phase at every point. These are 3D arrays that can be modified; in the usual case temperatures are assumed to be in Celcius, and the phases are integers (0-5 here). - -Lets specify a few helpful parameters, such as the adiabatic temperature throughout the model (0.4°C/km) and the mantle potential temperature at the surface 1280°C: - -```julia -Tair = 20.0; -Tmantle = 1280.0; -Adiabat = 0.4 -``` - -Next, we set the temperature everwhere to (will be overwrittem later) and all phases to 0 with - -```julia -model.Grid.Temp .= Tmantle .+ 1.0; # set mantle temperature (without adiabat at first) -model.Grid.Phases .= 0; # Set Phases to 0 everywhere (0 is/will be asthenosphere in this setup): -``` - -##### Setup temperature of the air to be 20°C -Next we set all "air" particles to `Tair`: - -```julia -model.Grid.Temp[model.Grid.Grid.Z .> 0] .= Tair; -``` - -We can quickly verify that this has been done on the `REPL` with: - -```julia -julia>julia> model.Grid -LaMEM grid with constant Δ: - nel : ([512], [1], [128]) - marker/cell : (3, 3, 3) - x ϵ [-2000.0 : 2000.0] - y ϵ [-8.0 : 8.0] - z ϵ [-660.0 : 40.0] - Phases : range ϵ [0 - 0] - Temp : range ϵ [20.0 - 1281.0] -``` - -##### Setup the air layer (id = 5) if Z > 0.0 -Set the air particles to 5: - -```julia -model.Grid.Phases[model.Grid.Grid.Z .> 0.0 ] .= 5; -``` - -##### Add left oceanic plate -An oceanic plate can be added using the `AddBox!()` function of the `GeophysicalModelGenerator` package (see `?GeophysicalModelGenerator.AddBox!` for more information, or check out the online [help](https://juliageodynamics.github.io/GeophysicalModelGenerator.jl/dev/man/lamem/) of the package). The lithosphere to asthenosphere temperature is set to 1250°C. If temperature of the plate is > 1250°C then the material is turned to asthenosphere. The temperature profile of the plate is set using a half space cooling temperature and a spreading rate velocity of 0.5 cm/yr with the ridge prescribed to be at the "left" of the box. - -```julia -AddBox!(model; xlim = (-2000.0, 0.0), - ylim = (model.Grid.coord_y...,), - zlim = (-660.0, 0.0), - Origin = nothing, StrikeAngle=0, DipAngle=0, - phase = LithosphericPhases(Layers=[20 80], Phases=[1 2 0] ), - T = SpreadingRateTemp( Tsurface = Tair, - Tmantle = Tmantle, - MORside = "left", - SpreadingVel= 0.5, - AgeRidge = 0.01; - maxAge = 80.0 ) ) -``` - -##### Add right oceanic plate -Same for the plate on the right: - -```julia -AddBox!(model; xlim = (1500, 2000), - ylim = (model.Grid.coord_y..., ), - zlim = (-660.0, 0.0), - Origin = nothing, StrikeAngle=0, DipAngle=0, - phase = LithosphericPhases(Layers=[20 80], Phases=[1 2 0] ), - T = SpreadingRateTemp( Tsurface = Tair, - Tmantle = Tmantle, - MORside = "right", - SpreadingVel= 0.5, - AgeRidge = 0.01; - maxAge = 80.0 ) ) -``` - -##### Add overriding plate margin -For the overriding plate margin the age is fixed to 90 Ma using `HalfspaceCoolingTemp()`. - -```julia -AddBox!(model; xlim = (0.0, 400.0), - ylim = (model.Grid.coord_y[1], model.Grid.coord_y[2]), - zlim = (-660.0, 0.0), - Origin = nothing, StrikeAngle=0, DipAngle=0, - phase = LithosphericPhases(Layers=[25 90], Phases=[3 4 0] ), - T = HalfspaceCoolingTemp( Tsurface = Tair, - Tmantle = Tmantle, - Age = 80 ) ) -``` - -##### Add overriding plate craton - -```julia -AddBox!(model; xlim = (400.0, 1500.0), - ylim = (model.Grid.coord_y...,), - zlim = (-660.0, 0.0), - Origin = nothing, StrikeAngle=0, DipAngle=0, - phase = LithosphericPhases(Layers=[35 100], Phases=[3 4 0] ), - T = HalfspaceCoolingTemp( Tsurface = Tair, - Tmantle = Tmantle, - Age = 120 ) ) -``` - -##### Add pre-subducted slab -Here we change the dip angle of the box to 30° to initiates subduction: - -```julia -AddBox!(model; xlim = (0.0, 300), - ylim = (model.Grid.coord_y...,), - zlim = (-660.0, 0.0), - Origin = nothing, StrikeAngle=0, DipAngle=30, - phase = LithosphericPhases(Layers=[30 80], Phases=[1 2 0], Tlab=1250 ), - T = HalfspaceCoolingTemp( Tsurface = Tair, - Tmantle = Tmantle, - Age = 80 ) ) -``` - -##### Impose approximate adiabat -We can add a mantle adiabatic temperature to the model with - -```julia -model.Grid.Temp = model.Grid.Temp - model.Grid.Grid.Z.*Adiabat; -``` - -##### Plot preview of the setup -Cross-sections of the model setup showing the temperature and the phase fields can be visualized as follows: - -```julia -plot_cross_section(model, y=0, field=:temperature) -plot_cross_section(model, y=0, field=:phase) -``` -which gives: - ![Subduction_CrossSection](sub_field.png) - ![Subduction_CrossSection](sub_temp.png) - -#### 3. Define material parameters - -At this stage, we defined the geometry and thermal structures of the model, but we did yet assign material properties to each of the rocktypes. - -##### Softening law -We assume that rocks weaken/soften when they becomes damaged, which can be defined by a softening law. Post-softening strength is defined as 0.05 the initial strength - -```julia -softening = Softening( ID = 0, # softening law ID - APS1 = 0.1, # begin of softening APS - APS2 = 0.5, # end of softening APS - A = 0.95, # reduction ratio - ) -``` - -##### Material thermal and rheological properties -*Mantle* -For the mantle, we use a dry olivine rheology: - -```julia -dryPeridotite = Phase( Name = "dryPeridotite", - ID = 0, # phase id [-] - rho = 3300.0, # density [kg/m3] - alpha = 3e-5, # coeff. of thermal expansion [1/K] - disl_prof = "Dry_Olivine_disl_creep-Hirth_Kohlstedt_2003", - Vn = 14.5e-6, - diff_prof = "Dry_Olivine_diff_creep-Hirth_Kohlstedt_2003", - Vd = 14.5e-6, - G = 5e10, # elastic shear module [MPa] - k = 3, # conductivity - Cp = 1000.0, # heat capacity - ch = 30e6, # cohesion [Pa] - fr = 20.0, # friction angle - A = 6.6667e-12, # radiogenic heat production [W/kg] - chSoftID = 0, # cohesion softening law ID - frSoftID = 0, # friction softening law ID - ) -``` - -*Oceanic crust* -For the oceanic crust we use a low cohesion and a frictional angle equal to 0. The goal is to make the oceanic crust weak enough to lubricate the interface with the overriding plate and allow for self-sustained subduction. Moreover, as density is not pressure and temperature dependent, it is set to be the same as the mantle (3300) in order to be neutrally buoyant with respect to the rest of the lithosphere. - -```julia -oceanicCrust = Phase( Name = "oceanCrust", - ID = 1, # phase id [-] - rho = 3300.0, # density [kg/m3] - alpha = 3e-5, # coeff. of thermal expansion [1/K] - disl_prof = "Plagioclase_An75-Ranalli_1995", - G = 5e10, # elastic shear module [MPa] - k = 3, # conductivity - Cp = 1000.0, # heat capacity - ch = 5e6, # cohesion [Pa] - fr = 0.0, # friction angle - A = 2.333e-10, # radiogenic heat production [W/kg] - ) -``` - -*Oceanic mantle lithosphere* -The oceanic mantle lithosphere has the same properties as the mantle but a different name and different phase. To simplify your life, you can use the `copy_phase` function for that: - -```julia -oceanicLithosphere = copy_phase( dryPeridotite, - Name = "oceanicLithosphere", - ID = 2 - ) -``` - -*Continental crust* -```julia -continentalCrust = copy_phase( oceanicCrust, - Name = "continentalCrust", - ID = 3, - disl_prof = "Quarzite-Ranalli_1995", - rho = 2700.0, - ch = 30e6, - fr = 20.0, - A = 5.3571e-10, - chSoftID = 0, - frSoftID = 0, - ) -``` -*Continental lithosphere* - -```julia -continentalLithosphere = copy_phase( dryPeridotite, - Name = "continentalLithosphere", - ID = 4 - ) -``` - -*Sticky air* -Finally, the "air" in our model is a layer with low density and low viscosity, such that it essentially gives very low stresses compared to those within the lithosphere. We cannot give it the viscosity of real air, as this results in a too large viscosity jump at the surface (geodynamic codes cannot handle that). We therefore also often call this "sticky air". Note that we also give it a very high thermal conductivity to ensure that the temperature within the air layer remains more or less constant throughout a simulation (and equal to the temperature at the upper boundary of the model): - -```julia -air = Phase( Name = "air", - ID = 5, # phase id [-] - rho = 50.0, # density [kg/m3] # coeff. of thermal expansion [1/K] - eta = 1e19, - G = 5e10, # elastic shear module [MPa] - k = 100, # conductivity - Cp = 1e6, # heat capacity - ch = 10e6, # cohesion [MPa] - fr = 0.0, # friction angle - ) -``` - -##### Add phases to the model -Finally, we can add all these phases to the model with: - -```julia -rm_phase!(model) -add_phase!( model, - dryPeridotite, - oceanicCrust, - oceanicLithosphere, - continentalCrust, - continentalLithosphere, - air - ) -``` - -##### Add softening law -Same with the softening law: - -```julia -add_softening!( model, - softening - ) -``` - -##### Set solver options -The PETSc command ```-da_refine_y 1``` allow to run the model as 2D - -```julia -model.Solver = Solver( SolverType = "multigrid", - MGLevels = 3, - MGCoarseSolver = "superlu_dist", - PETSc_options = [ "-snes_ksp_ew", - "-snes_ksp_ew_rtolmax 1e-4", - "-snes_rtol 5e-3", - "-snes_atol 1e-4", - "-snes_max_it 200", - "-snes_PicardSwitchToNewton_rtol 1e-3", - "-snes_NewtonSwitchToPicard_it 20", - "-js_ksp_type fgmres", - "-js_ksp_max_it 20", - "-js_ksp_atol 1e-8", - "-js_ksp_rtol 1e-4", - "-snes_linesearch_type l2", - "-snes_linesearch_maxstep 10", - "-da_refine_y 1" - ] - ) -``` - -#### 4. Perform the simulation -Here we run LaMEM on 8 cores (if you have them; use less otherwise): - -```julia -julia> run_lamem(model, 8) -Saved file: Model3D.vts -(Nprocx, Nprocy, Nprocz, xc, yc, zc, nNodeX, nNodeY, nNodeZ) = (4, 1, 2, [-2000.0, -1000.0, 0.0, 1000.0, 2000.0], [-8.0, 8.0], [-660.0, -310.0, 40.0], 513, 2, 129) -Writing LaMEM marker file -> ./markers/mdb.00000000.dat -Writing LaMEM marker file -> ./markers/mdb.00000001.dat -Writing LaMEM marker file -> ./markers/mdb.00000002.dat -Writing LaMEM marker file -> ./markers/mdb.00000003.dat -Writing LaMEM marker file -> ./markers/mdb.00000004.dat -Writing LaMEM marker file -> ./markers/mdb.00000005.dat -Writing LaMEM marker file -> ./markers/mdb.00000006.dat -Writing LaMEM marker file -> ./markers/mdb.00000007.dat --------------------------------------------------------------------------- - Lithosphere and Mantle Evolution Model - Compiled: Date: Apr 7 2023 - Time: 22:11:23 - Version : 1.2.4 --------------------------------------------------------------------------- - STAGGERED-GRID FINITE DIFFERENCE CANONICAL IMPLEMENTATION --------------------------------------------------------------------------- -Parsing input file : output.dat -Finished parsing input file : output.dat --------------------------------------------------------------------------- -Scaling parameters: - Temperature : 1000. [C/K] - Length : 1000. [m] - Viscosity : 1e+20 [Pa*s] - Stress : 1e+09 [Pa] -``` - - -The results will be saved in the directory where you performed the simulation and can be visualized in Paraview by opening the file `output.pvd`: - ![2D thermomechanical subduction](subduction_ts25.png) - - -##### Remark on performing parallel simulations -Using more processors or cores does not necessarily imply that the simulation will be faster. There is a tradeoff between the number of processors, the resolution, the number of multigrid levels, the machine you use and the speed of the simulation. At some stage it actually becomes slower! - -Unfortunately, it is hard to predict when this happens as this is setup- and machine-dependent. We can thus not automatize this, and our recommendation is therefore that you experiment with this. Run the simulation for a limited number of timesteps (say 5 or so) and check its speed for different number of cores. diff --git a/docs/src/assets/juliasetup_example_sphere.md b/docs/src/assets/juliasetup_example_sphere.md deleted file mode 100644 index f7ab6b25..00000000 --- a/docs/src/assets/juliasetup_example_sphere.md +++ /dev/null @@ -1,172 +0,0 @@ -# 1. Example 1: Falling sphere -This is a first example that illustrates how to build a setup using the LaMEM.jl package, run it and visualize the results, all without leaving julia. - -We start with loading the packages we need: -```julia -julia> using LaMEM, GeophysicalModelGenerator, Plots -``` -The [GeophysicalModelGenerator](https://github.com/JuliaGeodynamics/GeophysicalModelGenerator.jl) package can be used to generate model setups and [Plots](https://github.com/JuliaPlots/Plots.jl) for plotting. - -#### 1.1 Define model setup - -Next, we define a general model setup, in which we specify the units with which we work (for most cases, you'll want to use the default `GEO` units), the size of the computational box and various timestepping parameters. In this case, we use a multigrid solver. - -```julia -julia> model = Model(Grid(nel=(16,16,16), x=[-1,1], y=[-1,1], z=[-1,1]), - Time(nstep_max=20, dt_min=1e-3, dt=1, dt_max=10, time_end=100), - Solver(SolverType="multigrid", MGLevels=2), - Output(out_dir="example_1")) -LaMEM Model setup -| -|-- Scaling : GeoParams.Units.GeoUnits{GEO} -|-- Grid : nel=(16, 16, 16); xϵ(-1.0, 1.0), yϵ(-1.0, 1.0), zϵ(-1.0, 1.0) -|-- Time : nstep_max=20; nstep_out=1; time_end=100.0; dt=1.0 -|-- Boundary conditions : noslip=[0, 0, 0, 0, 0, 0] -|-- Solution parameters : eta_min=1.0e18; eta_max=1.0e25; eta_ref=1.0e20; act_temp_diff=0 -|-- Solver options : multigrid solver; coarse grid solver=direct; 2 levels -|-- Model setup options : Type=files; -|-- Output options : filename=output; pvd=1; avd=0; surf=0 -|-- Materials : 0 phases; -``` - -Note that each of the fields within `Model` has many additional and adjustable parameters. You can view that by typing: -```julia -julia> model.Time -LaMEM Timestepping parameters: - time_end = 100.0 - dt = 1.0 - dt_min = 0.001 - dt_max = 10.0 - dt_out = 0.2 - inc_dt = 0.1 - CFL = 0.5 - CFLMAX = 0.8 - nstep_max = 20 - nstep_out = 1 - nstep_rdb = 100 - nstep_ini = 1 - time_tol = 1.0e-8 -``` - -#### 1.2 Specify material properties -Once this is specified, we need to set material properties for each of the `Phases` we will consider in the simulation. This can be done with the `Phase` structure. First, we define two phases -```julia -julia> rm_phase!(model) -julia> matrix = Phase(ID=0,Name="matrix",eta=1e20,rho=3000) -Phase 0 (matrix): - rho = 3000.0 - eta = 1.0e20 -julia> sphere = Phase(ID=1,Name="sphere",eta=1e23,rho=3200) -Phase 1 (sphere): - rho = 3200.0 - eta = 1.0e23 -``` -and add them to the model with: -```julia -julia> add_phase!(model, sphere, matrix) -``` - -#### 1.3 Set initial model geometry -We also need to specify an initial model geometry. The julia package `GeophysicalModelGenerator` has a number of functions for that, which can be used here. For the current setup, we just add a sphere: -```julia -julia> AddSphere!(model,cen=(0.0,0.0,0.0), radius=(0.5, )) -``` -It is often useful to plot the initial model setup. You can do this with the `heatmap` function from the `Plots.jl` package, for which we provide a LaMEM plugin that allows you to specify a cross-section through a 3D LaMEM setup: - -```julia -julia> plot_cross_section(model, field=:phase, y=0) -``` - -![InitialSetupSphere](InitialSetupSphere.png) - -In the initial setup we define two fields: `:phase` which defines the rocktypes and `:temperature` which has the initial temperature. They are stored as 3D arrays in `model.Grid.Phases` and `model.Grid.Temp`: -```julia -julia> model.Grid -LaMEM grid with constant Δ: - nel : ([16], [16], [16]) - marker/cell : (3, 3, 3) - x ϵ [-1.0 : 1.0] - y ϵ [-1.0 : 1.0] - z ϵ [-1.0 : 1.0] - Phases : range ϵ [0 - 1] - Temp : range ϵ [0.0 - 0.0] -``` - -#### 1.4 Run LaMEM - -At this stage we are ready to run a LaMEM simulation which can simply be done with the `run_lamem` command. By default, it will run on one processor. If you want to run this in parallel, you can specify the number of cores you want to use. Please note that running things in parallel is only worth the effort for large resolutions; for smaller setups it will be faster on one processor: - -```julia -julia> run_lamem(model,1) -Saved file: Model3D.vts -Writing LaMEM marker file -> ./markers/mdb.00000000.dat --------------------------------------------------------------------------- - Lithosphere and Mantle Evolution Model - Compiled: Date: Apr 7 2023 - Time: 22:11:23 - Version : 1.2.4 --------------------------------------------------------------------------- - STAGGERED-GRID FINITE DIFFERENCE CANONICAL IMPLEMENTATION --------------------------------------------------------------------------- -Parsing input file : output.dat -Finished parsing input file : output.dat --------------------------------------------------------------------------- -Scaling parameters: - Temperature : 1000. [C/K] - Length : 1e+06 [m] - Viscosity : 1e+20 [Pa*s] - Stress : 10. [Pa] --------------------------------------------------------------------------- -Time stepping parameters: - Simulation end time : 100. [Myr] - Maximum number of steps : 20 - Time step : 1. [Myr] - Minimum time step : 0.001 [Myr] - Maximum time step : 10. [Myr] - Time step increase factor : 0.1 - CFL criterion : 0.5 - CFLMAX (fixed time steps) : 0.8 - Output every [n] steps : 1 - Output [n] initial steps : 1 --------------------------------------------------------------------------- --------------------------------------------------------------------------- -``` - -#### 1.5 Visualize results - -Once the simulation is done, you can look at the results using the same `heatmap` function, but by specifying a timestep, which will read that timestep and plot a cross-section though it: - -```julia -julia> plot_cross_section(model, y=0, timestep=20, field=:phase) -``` - -![FallingSphere_t20](FallingSphere_t20.png) - -Alternatively, you can visualize the results with Paraview. -Change to the directory where you did the simulation: -```julia -julia> cd(model.Output.out_dir) -julia> julia> readdir() -25-element Vector{String}: - "Model3D.vts" - "Timestep_00000000_0.00000000e+00" - "Timestep_00000001_1.10000000e+00" - "Timestep_00000002_2.31000000e+00" - "Timestep_00000003_3.64100000e+00" - "Timestep_00000004_5.10510000e+00" - "Timestep_00000005_6.71561000e+00" - ⋮ - "Timestep_00000017_4.45991731e+01" - "Timestep_00000018_5.01590904e+01" - "Timestep_00000019_5.62749995e+01" - "Timestep_00000020_6.30024994e+01" - "markers" - "output.dat" - "output.pvd" -``` -And you can open `output.pvd` with paraview. If your system recogizes that `*.pvd` files should be opened with paraview, you can do that with -```julia -julia> ; -shell> open output.pvd -``` -Otherwise, start paraview manually and open the file. - diff --git a/docs/src/assets/juliasetup_pluto.md b/docs/src/assets/juliasetup_pluto.md deleted file mode 100644 index 0d92e52a..00000000 --- a/docs/src/assets/juliasetup_pluto.md +++ /dev/null @@ -1,18 +0,0 @@ -# Using Pluto or Jupyter notebooks - -#### Pluto -You can also run LaMEM directly using Pluto notebooks: -```julia -julia> using Pluto -julia> Pluto.run() -``` -we have provided examples in the `notebooks` directory of the `LaMEM.jl` package. - - -#### Jupyter -And for the ones of you that are more used to Jupyter notebooks, we also provide an example. Note that this will require you to install the required packages in julia first and use the `IJulia` package: - -```julia -julia> using IJulia -julia> notebook() -``` \ No newline at end of file diff --git a/docs/src/assets/juliasetups.md b/docs/src/assets/juliasetups.md deleted file mode 100644 index 5e77592b..00000000 --- a/docs/src/assets/juliasetups.md +++ /dev/null @@ -1,144 +0,0 @@ -# Create & run setups from julia - -It is also possible to construct a LaMEM setup directly in julia & run that. You can do the same from within a [Pluto](https://plutojl.org) notebook. The advantage is that it is easier to use, has build-in plotting functions and extensive documentation. - -The main routine to do this is: - -```julia -julia> using LaMEM -julia> model = Model() -LaMEM Model setup -| -|-- Scaling : GeoParams.Units.GeoUnits{GEO} -|-- Grid : nel=(16, 16, 16); xϵ(-10.0, 10.0), yϵ(-10.0, 0.0), zϵ(-10.0, 0.0) -|-- Time : nstep_max=50; nstep_out=1; time_end=1.0; dt=0.05 -|-- Boundary conditions : noslip=[0, 0, 0, 0, 0, 0] -|-- Solution parameters : eta_min=1.0e18; eta_max=1.0e25; eta_ref=1.0e20; act_temp_diff=0 -|-- Solver options : direct solver; superlu_dist; penalty term=10000.0 -|-- Model setup options : Type=files; -|-- Output options : filename=output; pvd=1; avd=0; surf=0 -|-- Materials : 0 phases; -``` - -`Model` is a structure that contains all the information about the LaMEM simulation and consists of the following sub-structures that can all be adjusted. -``` -BoundaryConditions FreeSurface Grid -Materials ModelSetup Output -Scaling SolutionParams Solver -Time -``` - -You can, for example, look at the current `Grid`: -```julia -julia> model.Grid -LaMEM grid with constant Δ: - nel : ([16], [16], [16]) - marker/cell : (3, 3, 3) - x ϵ [-10.0 : 10.0] - y ϵ [-10.0 : 0.0] - z ϵ [-10.0 : 0.0] - Phases : range ϵ [0 - 0] - Temp : range ϵ [0.0 - 0.0] -``` -and change the dimensions and number of grid-cells with: -```julia -julia> model.Grid = Grid(nel=[32,32,32], x=[-20,20]) -LaMEM grid with constant Δ: - nel : ([32], [32], [32]) - marker/cell : (3, 3, 3) - x ϵ [-20.0 : 20.0] - y ϵ [-10.0 : 0.0] - z ϵ [-10.0 : 0.0] - Phases : range ϵ [0 - 0] - Temp : range ϵ [0.0 - 0.0] -``` -or do it by directly accessing the respectyive data field: -```julia -julia> model.Grid.nel_x = [32] -1-element Vector{Int64}: - 32 -``` - -Every LaMEM model setup needs to specify material properties for the different materials. By default it has nothing: -``` -julia> model.Materials -LaMEM Material Properties: - Softening = - PhaseTransition = -``` - -yet, we can specify different materials using the `Phase` structure: -```julia -julia> sphere = Phase(Name="Sphere", ID=1, eta=1e20, rho=2800) -Phase 1 (Sphere): - rho = 2800.0 - eta = 1.0e20 -``` -and add that to the model with: -```julia -julia> add_phase!(model, sphere) -julia> model -LaMEM Model setup -| -|-- Scaling : GeoParams.Units.GeoUnits{GEO} -|-- Grid : nel=(32, 32, 32); xϵ(-20.0, 20.0), yϵ(-10.0, 0.0), zϵ(-10.0, 0.0) -|-- Time : nstep_max=50; nstep_out=1; time_end=1.0; dt=0.05 -|-- Boundary conditions : noslip=[0, 0, 0, 0, 0, 0] -|-- Solution parameters : eta_min=1.0e18; eta_max=1.0e25; eta_ref=1.0e20; act_temp_diff=0 -|-- Solver options : direct solver; superlu_dist; penalty term=10000.0 -|-- Model setup options : Type=files; -|-- Output options : filename=output; pvd=1; avd=0; surf=0 -|-- Materials : 1 phases; -``` -Note that the model now has 1 phase. - -In order to run a simulation, we need to define at least 1 phase and heterogeneities in either the initial temperature field (`model.Grid.Temp`) or the Phases field (`model.Grid.Phases`). -The easiest way to do that is to use routines from the `GeophyicalModelGenerator` package, for which we created simple interfaces to many of the relevant routines: -```julia -julia> using GeophysicalModelGenerator -julia> AddSphere!(model,cen=(0.0,0.0,0.0), radius=(0.5, )) -``` - -For the sake of this example, lets add another phase: -```julia -julia> matrix = Phase(ID=0,Name="matrix",eta=1e20,rho=3000) -Phase 0 (matrix): - rho = 3000.0 - eta = 1.0e20 -julia> add_phase!(model, matrix) -``` - -At this stage you have a model setup with 2 phases and heterogeneities in the `Phases` field, which you can check with: -```julia -julia> model -LaMEM Model setup -| -|-- Scaling : GeoParams.Units.GeoUnits{GEO} -|-- Grid : nel=(32, 32, 32); xϵ(-20.0, 20.0), yϵ(-10.0, 0.0), zϵ(-10.0, 0.0) -|-- Time : nstep_max=50; nstep_out=1; time_end=1.0; dt=0.05 -|-- Boundary conditions : noslip=[0, 0, 0, 0, 0, 0] -|-- Solution parameters : eta_min=1.0e18; eta_max=1.0e25; eta_ref=1.0e20; act_temp_diff=0 -|-- Solver options : direct solver; superlu_dist; penalty term=10000.0 -|-- Model setup options : Type=files; -|-- Output options : filename=output; pvd=1; avd=0; surf=0 -|-- Materials : 2 phases; - - -julia> model.Grid -LaMEM grid with constant Δ: - nel : ([32], [32], [32]) - marker/cell : (3, 3, 3) - x ϵ [-20.0 : 20.0] - y ϵ [-10.0 : 0.0] - z ϵ [-10.0 : 0.0] - Phases : range ϵ [0 - 1] - Temp : range ϵ [0.0 - 0.0] -``` - -Running a model is very simple: -```julia -julia> run_lamem(model,1) -``` - -### More examples -More examples can be found on the left hand side menu. diff --git a/docs/src/assets/listfunctions.md b/docs/src/assets/listfunctions.md deleted file mode 100644 index fbb2bfd1..00000000 --- a/docs/src/assets/listfunctions.md +++ /dev/null @@ -1,13 +0,0 @@ -# List of all functions - -These are all functions that are available in the package, which can roughly be divided into two groups (running & reading LaMEM) - -## Running LaMEM -```@autodocs -Modules = [LaMEM.Run] - -``` -## Reading LaMEM output back into julia -```@autodocs -Modules = [LaMEM.IO_functions] - diff --git a/docs/src/assets/readtimesteps.md b/docs/src/assets/readtimesteps.md deleted file mode 100644 index e21e5332..00000000 --- a/docs/src/assets/readtimesteps.md +++ /dev/null @@ -1,58 +0,0 @@ -# Read timesteps back into LaMEM -If you want to quantitatively do something with the results, there is an easy way to read the output of a LaMEM timestep back into julia. All routines related to that are part of the `LaMEM.IO` module. - -```julia -julia> using LaMEM -``` -You can first read the `*.pvd` file in the directory to see which timesteps are available: -```julia -julia> FileName="FB_multigrid" -julia> DirName ="test" -julia> Timestep, Filenames, Time = Read_LaMEM_simulation(FileName, DirName) -([0, 1], ["Timestep_00000000_0.00000000e+00/FB_multigrid.pvtr", "Timestep_00000001_6.72970343e+00/FB_multigrid.pvtr"], [0.0, 6.729703]) -``` -We can read a particular timestep (say 1) with: -```julia -julia> data, time = Read_LaMEM_timestep(FileName, 1, DirName) -(CartData - size : (33, 33, 33) - x ϵ [ 0.0 : 1.0] - y ϵ [ 0.0 : 1.0] - z ϵ [ 0.0 : 1.0] - fields : (:phase, :visc_total, :visc_creep, :velocity, :pressure, :strain_rate, :j2_dev_stress, :j2_strain_rate) - attributes: ["note"] -, [6.729703]) -``` -The output is in a `CartData` structure (as defined in GeophysicalModelGenerator). - -If you do not indicate a directory name (`DirName`) it'll look in your current directory. The default above will load the main LaMEM simulation output. Alternatively, you can also load the `phase` information by specify the optional keyword `phase=true`: -```julia -julia> data, time = Read_LaMEM_timestep(FileName, 1, DirName, phase=true) -(CartData - size : (96, 96, 96) - x ϵ [ 0.0052083334885537624 : 0.9947916269302368] - y ϵ [ 0.0052083334885537624 : 0.9947916269302368] - z ϵ [ 0.0052083334885537624 : 0.9947916269302368] - fields : (:phase,) - attributes: ["note"] -, [6.729703]) -``` -In the same way, you can load the internal free surface with `surf=true` (if that was saved), or passive tracers (`passive_tracers=true`). -If you don't want to load all the fields in the file back to julia, you can check which fields are available: - -```julia -julia> Read_LaMEM_fieldnames(FileName, DirName) -("phase [ ]", "visc_total [ ]", "visc_creep [ ]", "velocity [ ]", "pressure [ ]", "strain_rate [ ]", "j2_dev_stress [ ]", "j2_strain_rate [ ]") -``` -and load only part of those: -```julia -julia> data, time = Read_LaMEM_timestep(FileName, 1, DirName, fields=("phase [ ]", "visc_total [ ]","velocity [ ]")) -(CartData - size : (33, 33, 33) - x ϵ [ 0.0 : 1.0] - y ϵ [ 0.0 : 1.0] - z ϵ [ 0.0 : 1.0] - fields : (:phase, :visc_total, :velocity) - attributes: ["note"] -, [6.729703]) -``` diff --git a/docs/src/assets/runlamem.md b/docs/src/assets/runlamem.md deleted file mode 100644 index e9821598..00000000 --- a/docs/src/assets/runlamem.md +++ /dev/null @@ -1,55 +0,0 @@ -# Run LaMEM -Go to the package manager & install it with: -```julia -julia>] -pkg>add LaMEM -``` -It will automatically download a binary version of LaMEM which runs in parallel (along with the correct PETSc version). This will work on linux, mac and windows. - -### Starting a simulation -If you have a LaMEM (`*.dat`) input file, you can run in parallel (here on 4 cores) with: -```julia -julia> ParamFile="input_files/FallingBlock_Multigrid.dat"; -julia> run_lamem(ParamFile, 4,"-time_end 1") --------------------------------------------------------------------------- - Lithosphere and Mantle Evolution Model - Compiled: Date: Sep 10 2022 - Time: 06:21:30 --------------------------------------------------------------------------- - STAGGERED-GRID FINITE DIFFERENCE CANONICAL IMPLEMENTATION --------------------------------------------------------------------------- -Parsing input file : input_files/FallingBlock_Multigrid.dat - Adding PETSc option: -snes_type ksponly - Adding PETSc option: -js_ksp_monitor - Adding PETSc option: -crs_pc_type bjacobi -Finished parsing input file : input_files/FallingBlock_Multigrid.dat --------------------------------------------------------------------------- -Time stepping parameters: - Simulation end time : 1. [ ] - Maximum number of steps : 10 - Time step : 10. [ ] - Minimum time step : 1e-05 [ ] - Maximum time step : 100. [ ] - Time step increase factor : 0.1 - CFL criterion : 0.5 - CFLMAX (fixed time steps) : 0.5 - Output time step : 0.2 [ ] - Output every [n] steps : 1 - Output [n] initial steps : 1 --------------------------------------------------------------------------- -``` -The last parameter are optional PETSc command-line options. By default it runs on one processor. - -Please note that you will have to be in the correct directory or indicate where that directory is. If you are in a different directory, the easiest way to change to the correct one is by using the `changefolder` function (on Windows and Mac): -```julia -julia> changefolder() -``` - -Alternatively, you can use the build-in terminal/shell in julia, which you can access with: -```julia -julia>; -shell>cd ~/LaMEM/input_models/BuildInSetups/ -``` -use the Backspace key to return to the julia REPL. - - -Once you have performed a simulation, you can look at the results by opening the `*.pvd` files with Paraview. In this example, that would be `FB_multigrid.pvd` and `FB_multigrid_phase.pvd`. diff --git a/docs/src/listfunctions.md b/docs/src/listfunctions.md index 4652324f..02c05eb5 100644 --- a/docs/src/listfunctions.md +++ b/docs/src/listfunctions.md @@ -10,8 +10,9 @@ Modules = [ LaMEM.LaMEM_Model] ## Running LaMEM ```@autodocs Modules = [LaMEM.Run] - ``` + + ## Reading LaMEM output back into julia ```@autodocs Modules = [LaMEM.IO_functions]