Comments (1)
The next thing we're trying is
grid = RectilinearGrid(size=128, z=(-0.5, 0.5), topology=(Flat, Flat, Bounded))
diffusion = VerticalScalarDiffusivity(κ=1.0)
model = HydrostaticFreeSurfaceModel(; grid,
tracers = :c,
buoyancy = nothing,
velocities = PrescribedVelocityFields(),
closure = diffusion)
"""
set_diffusivity!(model, diffusivity)
Change diffusivity of model to `diffusivity`.
"""
function set_diffusivity!(model, diffusivity)
closure = VerticalScalarDiffusivity(; κ=diffusivity)
names = tuple(:c) # tracernames(model.tracers)
closure = with_tracers(names, closure)
model.closure = closure
return nothing
end
function set_initial_condition!(model, amplitude)
# Set initial condition
width = 0.1
cᵢ(x, y, z) = amplitude * exp(-z^2 / (2width^2))
set!(model, c=cᵢ)
return nothing
end
function stable_diffusion!(model, amplitude, diffusivity)
set_diffusivity!(model, diffusivity)
set_initial_condition!(model, amplitude)
# Do time-stepping
Nx, Ny, Nz = size(model.grid)
κ_max = maximum_diffusivity
Δz = 2π / Nz
Δt = 1e-1 * Δz^2 / κ_max
model.clock.time = 0
model.clock.iteration = 0
for n = 1:10
time_step!(model, Δt; euler=true)
end
# Compute scalar metric
c = model.tracers.c
# Hard way
# c² = c^2
# sum_c² = sum(c²)
# Another way to compute it
c² = Array(interior(c).^2)
sum_c² = sum(c²)
return sum_c²::Float64
end
We made a repo for all this stuff:
https://github.com/glwagner/Enzymanigans.jl/tree/main
check out stable_diffusion.jl
.
from oceananigans.jl.
Related Issues (20)
- Call it "Simulation setup" in the docs, not "Model setup"
- `BackgroundField` is a confusing name HOT 2
- Derivatives of a reduced field over an Immersed boundary HOT 5
- Pressure has extremely high gradients in random chunks of simulation using `NonhydrostaticModel` with `ImmersedBoundaryGrid` and `BuoyancyTracer` HOT 17
- Simulation tips may be a little misleading
- Lagrangian_particles (tracked_fields and using immersed boundaries) HOT 9
- boundary condition and output questions HOT 1
- Potential 'output_writers' saving bug? HOT 6
- Issue with out-of-bounds access and windowed field indexing HOT 5
- Huge memory use of Average associated with compilation HOT 20
- Halo inflation + restriction on halo size makes it impossible to run some problems HOT 1
- Vector rotation for grids where the "intrinsic" and "extrinsic" coordinate system are different HOT 8
- Allow single column grids with a specific location HOT 1
- Error when using `OpenBoundaryCondition` with `HydrostaticFreeSurfaceModel` HOT 35
- Using `LagrangianParticles` with `Flat` topology hits wrong function dispatch when computing fractional indices HOT 1
- More / more flexible Smagorinsky models HOT 8
- Outdated docs on background diffusivity/viscosity HOT 1
- Are `GradientBoundaryCondition`s set by the outward normal component or the coordinate-aligned component? HOT 1
- Segmentation Fault when trying to run a script HOT 14
- Post-Checkpoint Output Saving Interval Issue HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oceananigans.jl.