coef_dealiasing=1 puts some elements of the array to zero.
Created originally on Bitbucket by avmo (Ashwin Vishnu)
After this code in base/forcing/specific.py
#!python
class NormalizedForcing(SpecificForcingPseudoSpectral):
tag = 'normalized_forcing'
@classmethod
def _complete_params_with_default(cls, params):
"""This static method is used to complete the *params* container.
"""
super(NormalizedForcing, cls)._complete_params_with_default(params)
params.forcing._set_child(
cls.tag,
{'type_normalize': '2nd_degree_eq'})
def compute(self):
"""compute a forcing normalize with a 2nd degree eq."""
try:
a_fft = self.sim.state.state_fft.get_var(self.key_forced)
except ValueError:
a_fft = self.sim.state.compute(self.key_forced)
a_fft = self.oper.coarse_seq_from_fft_loc(
a_fft, self.shapeK_loc_coarse)
if mpi.rank == 0:
Fa_fft = self.forcingc_raw_each_time()
Fa_fft = self.normalize_forcingc(Fa_fft, a_fft)
kwargs = {self.key_forced: Fa_fft}
self.fstate_coarse.init_fft_from(**kwargs)
Try add a debug breakpoint and run the following
#!python
state_fft = self.fstate_coarse.state_fft
Fa_fft2 = state_fft.get_var('ap_fft') + state_fft.get_var('am_fft')
np.isclose(Fa_fft, Fa_fft2)
This may be a minor detail, but affects the forcing calculation.
I want to confirm this is a bug or not. I managed to trace it to the algorithm of how where_dealiased
is calculated.
#!python
# for spectra, we forget the larger wavenumber,
# since there is no energy inside because of dealiasing
self.nkxE = self.nkx_seq - 1
self.nkyE = self.nky_seq/2
self.kxE = self.deltakx * np.arange(self.nkxE)
self.kyE = self.deltaky * np.arange(self.nkyE)
self.khE = self.kxE
self.nkhE = self.nkxE
# Initialisation dealiasing
self.coef_dealiasing = coef_dealiasing
CONDKX = abs(self.KX) > self.coef_dealiasing*self.kxE.max()
CONDKY = abs(self.KY) > self.coef_dealiasing*self.kyE.max()
where_dealiased = np.logical_or(CONDKX, CONDKY)