-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_00_minimal.jl
71 lines (56 loc) · 1.93 KB
/
example_00_minimal.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using Pkg
# this will be replace by the module load in the future
Pkg.activate("PiCLES/") # Activate the PiCLES package
using PiCLES
using PiCLES.Operators.core_2D: ParticleDefaults
using PiCLES.Models.WaveGrowthModels2D: WaveGrowth2D
using PiCLES.Simulations
using PiCLES.ParticleMesh: TwoDGrid, TwoDGridNotes, TwoDGridMesh
using PiCLES.ParticleSystems: particle_waves_v5 as PW
using Oceananigans.Units
# just for simple plotting
import Plots as plt
# Parameters
U10, V10 = 10.0, 10.0
DT = 10minutes
r_g0 = 0.85 # ratio of c / c_g (phase velocity/ group velocity).
# Define wind functions
u(x, y, t) = U10
v(x, y, t) = V10
winds = (u=u, v=v)
# Define grid
grid = TwoDGrid(100e3, 51, 100e3, 51)
gn = TwoDGridNotes(grid)
# Define ODE parameters
ODEpars, Const_ID, Const_Scg = PW.ODEParameters(r_g=r_g0)
# Define particle equations
particle_system = PW.particle_equations(u, v, γ=Const_ID.γ, q=Const_ID.q);
# Calculate minimal windsea based on characteristic winds
WindSeamin = FetchRelations.MinimalWindsea(U10, V10, DT)
# Define default particle
default_particle = ParticleDefaults(WindSeamin["lne"], WindSeamin["cg_bar_x"], WindSeamin["cg_bar_y"], 0.0, 0.0)
# Define ODE settings
ODE_settings = PW.ODESettings(
Parameters=ODEpars,
log_energy_minimum=WindSeamin["lne"], # define mininum energy threshold
saving_step=DT,
timestep=DT,
total_time=T = 6days,
dt=1e-3, #60*10,
dtmin=1e-4, #60*5,
force_dtmin=true)
# Build wave model
wave_model = WaveGrowth2D(; grid=grid,
winds=winds,
ODEsys=particle_system,
ODEsets=ODE_settings,
periodic_boundary=false,
minimal_particle=FetchRelations.MinimalParticle(U10, V10, DT),
movie=true)
# Build simulation
wave_simulation = Simulation(wave_model, Δt=DT, stop_time=2hour)#1hours)
# Run simulation
run!(wave_simulation, cash_store=true)
# Plot initial state
istate = wave_simulation.store.store[end];
p1 = plt.heatmap(gn.x / 1e3, gn.y / 1e3, istate[:, :, 1])