Skip to content

Commit

Permalink
Simplify forcing calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtbrolly committed Apr 15, 2024
1 parent 20826fa commit e43f25c
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions mechanisms.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,9 @@ def __init__(self, model, k_f, dk_f, energy_input_rate, seed=1):
self.rng = np.random.default_rng(seed=seed)
self.band_filter = ((self.model.wv >= self.k_f - self.dk_f)
& (self.model.wv <= self.k_f + self.dk_f))
self.band_filter = self.band_filter
self.F = self.band_filter * self.energy_input_rate
self.fk_vars = self.F * self.model.n_x ** 2 * self.model.wv2
# Accounting for band filter:
# self.fk_vars *= np.prod(self.model.kx.shape) / self.band_filter.sum()
# The above and making isotropic energy of forcing flat within interval
self.fk_vars *= self.model.wv2i ** 0.5
self.fk_vars /= np.sum(2 * self.band_filter * self.model.wv2i ** 0.5
) / (self.model.n_x ** 2)
self.fk_vars = (self.energy_input_rate * self.band_filter
* self.model.n_x ** 4 * self.model.wv * 0.5
/ np.sum(self.band_filter * self.model.wv2i ** 0.5))

def __call__(self):
self.fk = np.reshape(self.rng.normal(size=self.model.wv.size)
Expand Down

0 comments on commit e43f25c

Please sign in to comment.