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

Add working example

parent a1d5c5ee
......@@ -20,9 +20,10 @@ class IBM:
self.dt = config["dt"]
self.mortality_factor = np.exp(-mortality * self.dt / 86400)
def update_ibm(self, grid, state, forcing):
new_salinity_model = True
salinity_model = config["ibm"].get('salinity_model', 'new')
self.new_salinity_model = (salinity_model == 'new')
def update_ibm(self, grid, state, forcing):
# Mortality
state.super *= self.mortality_factor
......@@ -44,22 +45,24 @@ class IBM:
# Upwards if light enough (decreasing depth)
W[Eb >= 0.01] = -self.swim_vel
if new_salinity_model:
if self.new_salinity_model:
# Mixture of down/up if salinity between 23 and 31
# Downwards if salinity < 31
state_rand = np.random.rand(*state.salt.shape)
not_enough_salt = state.salt < 31 - state_rand*8
W[not_enough_salt] = self.swim_vel
salt_limit = np.random.uniform(23, 31, W.shape)
else:
# Downwards if salinity < 20
W[state.salt < 20] = self.swim_vel
salt_limit = 20
W[state.salt < salt_limit] = self.swim_vel
# Random diffusion velocity
if self.vertical_diffusion:
rand = np.random.normal(size=len(W))
W += rand * (2 * self.D / self.dt) ** 0.5
# Update vertical position, using reflexive boundary condition
# Update vertical position, using reflexive boundary condition at the top
state.Z += W * self.dt
state.Z[state.Z < 0] *= -1
# For z-version, do not go below 20 m
state.Z[state.Z >= 20.0] = 19.0
......
time_control:
# Start and stop of simulation
start_time : 2015-09-07 01:00:00
stop_time : 2015-09-07 01:05:00
start_time : 2015-09-07 04:00:00
stop_time : 2015-09-07 04:05:00
reference_time : 2000-01-01 04:00:00
files:
......@@ -12,68 +13,69 @@ files:
gridforce:
module: ladim.gridforce.ROMS
input_file: forcing.nc # Use wildcards (*) to select a range of files
ibm_forcing:
temp: temp
salt: salt
ibm:
ibm_module: ladim_ibm.salmon_lice
state:
# pid, X, Y, Z are mandatory and should not be given
ibm_variables:
- age # Age of particle [degree-days]
module: ladim_ibm.salmon_lice
variables:
- super # Number of actual salmon lice per simulation particle
- age # Age of particle [degree*days]
- days # Age of particle [days]
- temp # Particle ambient temperature [Celcius]
- salt # Particle ambient salinity [1]
particle_release:
release_type: discrete
release_type: continuous
release_frequency: [60, s] # Normally: [1, h]
variables:
- mult # Number of particles released
- release_time # Time of release, formatted as yyyy-mm-ddThh:mm:ss
- X # X coordinate of release location
- Y # Y coordinate of release location
- Z # Depth of release location
- group_id # Custom id used to group particles in post processing
- super # Number of actual eggs per simulation particle
- farmid # Custom id used to group particles in post processing
- super # Number of actual salmon lice per simulation particle
# Converters (if not float)
mult: int
release_time: time
group_id: int
particle_variables: [release_time, group_id]
farmid: int
particle_variables: [release_time, farmid]
output_variables:
# Output period, format [value, unit], unit = s, m, h, or d
outper: [60, s]
outper: [60, s] # Normally: [1, h]
# Uncomment the entry below to split output file into daily files
# numrec: 24
# Variable names
particle: [release_time, group_id]
instance: [pid, X, Y, Z, age, super]
particle: [release_time, farmid]
instance: [pid, X, Y, Z, super, age, days, temp, salt]
# --- Output format for standard variables ---
# Output format for the particle release time
release_time:
ncformat: f8
long_name: particle release time
units: seconds since reference_time
# Output format for the particle identifier
pid:
ncformat: i4
long_name: particle identifier
# Output format for the X coordinate
X:
ncformat: f4
long_name: particle X-coordinate
# Output format for the Y coordinate
Y:
ncformat: f4
long_name: particle Y-coordinate
# Output format for the particle depth
Z:
ncformat: f4
long_name: particle depth
......@@ -83,22 +85,39 @@ output_variables:
# --- Output format for IBM-specific variables ---
# Output format for the temperature
temp:
ncformat: f4
long_name: temperature
standard_name: sea_water_temperature
units: Celcius
farmid:
ncformat: i4
long_name: fish farm location number
group_id: {ncformat: i4, long_name: particle group id}
age:
ncformat: f4
long_name: particle age in degree-days
units: Celcius days
standard_name: integral_of_sea_water_temperature_wrt_time
super: {ncformat: f4, long_name: number of individuals in instance}
super:
ncformat: f4
long_name: number of individuals in instance
salt:
ncformat: f4
long_name: salinity
standard_name: sea_water_salinity
days:
ncformat: f4
long_name: Days after haching
units: days
numerics:
# Model time step, [value, unit]
dt: [60, s] # usually 120 on 160m NorFjords, 600 NorKyst, 1800 SVIM
advection: RK4 # either EF, RK2 or RK4 (recommended)
diffusion: 0 # [m*2/s]
diffusion: 1.0 # [m*2/s]
1 2015-09-07T04:00:00 3 4 0 11111 4000
2 2015-09-07T04:00:00 4 5 10 22222 2000
1 2015-09-07T04:00:00 5 6 20 33333 1000
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