Commit 6677813a authored by Sævik Pål Næverlid's avatar Sævik Pål Næverlid
Browse files

Add IBM

parent 611f923d
from .gridforce import Grid, Forcing
from .ibm import IBM
import numpy as np
class IBM:
def __init__(self, config):
self.D = config["ibm"].get('vertical_mixing', 1e-3) # Vertical mixing [m*2/s]
self.dt = config['dt']
def update_ibm(self, grid, state, _):
# Vertical diffusion velocity
rand = np.random.normal(size=len(state.X))
W = rand * (2 * self.D / self.dt) ** 0.5
# Update vertical position, using reflexive boundary condition at top
state.Z += W * self.dt
state.Z[state.Z < 0] *= -1
# Reflexive boundary condition at bottom
H = grid.sample_depth(state.X, state.Y) # Water depth
below_seabed = state.Z > H
state.Z[below_seabed] = 2*H[below_seabed] - state.Z[below_seabed]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment