WVTransformBoussinesq
Decompose nonhydrostatic variable-stratification flow into wave and geostrophic components.
Declaration
classdef WVTransformBoussinesq < WVTransformOverview
To initialize an instance of the WVTransformBoussinesq class you must specify the domain size, the number of grid points, and either the density profile or the stratification profile.
N0 = 3*2*pi/3600;
L_gm = 1300;
N2 = @(z) N0*N0*exp(2*z/L_gm);
wvt = WVTransformBoussinesq([100e3,100e3,4000],[64,64,65],N2Function=N2,latitude=30);
The transform state is stored in Ap,
Am, and
A0. Their current-time
views are Apt, Amt, and A0t.
Topics
- Create and restore a transform
WVTransformBoussinesqCreate a nonhydrostatic wave-vortex transform for variable stratification.waveVortexTransformFromFileRestore a WVTransformBoussinesq instance from an existing file
- Inspect the domain
- Physical environment
- Planetary rotation
betaMeridional gradient of the Coriolis parameter.fCoriolis parameter in radians per second.inertialPeriodInertial period in seconds.latitudeCentral latitude of the rotating domain in degrees north.planetaryRadiusRadius of the rotating planetary body in meters.rotationRatePlanetary rotation rate in radians per second.
- Stratification and reference density
N2Buoyancy frequency squared sampled on the vertical grid.N2FunctionFunction returning buoyancy frequency squared at requested depths.buoyancyPeriodShortest buoyancy period in seconds.dLnN2\(\partial_z \ln N^2\), vertical derivative of the logarithm of squared buoyancy frequencyrho0Boussinesq reference density in kilograms per cubic meter.rhoFunctionFunction returning the no-motion density profile at requested depths.shouldUseTrueNoMotionProfileWhether density diagnostics use the supplied no-motion profile directly.
- Gravity
gGravitational acceleration in meters per second squared.
- Planetary rotation
- Spatial grid
- Coordinate axes
- Coordinate arrays
- Domain dimensions
- Resolution and shape
NxNumber of spatial grid points in the x direction.NyNumber of spatial grid points in the y direction.NzNumber of vertical spatial grid points.spatialMatrixSizeShape of a gridded physical-space field.
- Quadrature and integration
z_intVertical quadrature weights in meters.volumeIntegralCompute the horizontally averaged depth integral of a scalar field.
- Spectral grid
- Compact grid vectors
- Compact grid arrays
KX-direction angular-wavenumber array in \(\mathrm{rad\,m^{-1}}\) with shape[Nj Nkl].LY-direction angular-wavenumber array in \(\mathrm{rad\,m^{-1}}\) with shape[Nj Nkl].JDimensionless vertical-mode index array with shape[Nj Nkl].kljGridReturn spectral-coordinate arrays in wave-vortex layout.
- Wavenumber spacing
- Horizontal wavenumber geometry
- Resolution and shape
NjNumber of retained vertical modes.NklNumber of retained compact horizontal-wavenumber columns.spectralMatrixSizeShape of a wave-vortex coefficient array.effectiveHorizontalGridResolutionreturns the effective grid resolution in meterseffectiveVerticalGridResolutionreturns the effective vertical grid resolution in meterseffectiveJMaxLargest active vertical-mode index.summarizeDegreesOfFreedomSummarize the spatial grid and active spectral degrees of freedom.
- Vertical modes and scaling
verticalModesVertical-mode solution used to construct the transform basis.h_0Geostrophic equivalent-depth scale for each vertical mode.h_pmWave equivalent depth on the spectral grid.Lr2Squared Rossby deformation radius in square meters.waveModeVerticalStructureAtIndexReturn wave vertical-structure factors at one vertical grid index.
- Vertical-mode transformation matrices
FMatrixTransformation matrix \(F\) projecting F-grid values onto vertical modes; shape[Nj Nz].FinvMatrixTransformation matrix \(F^{-1}\) reconstructing F-grid values from vertical modes; shape[Nz Nj].GMatrixTransformation matrix \(G\) projecting G-grid values onto vertical modes; shape[Nj Nz].GinvMatrixTransformation matrix \(G^{-1}\) reconstructing G-grid values from vertical modes; shape[Nz Nj].
- Transform configuration
isHydrostaticWhether the transform uses the hydrostatic approximation.shouldAntialiasWhether the spectral grid excludes modes that alias quadratic products.
- Physical environment
- Initialize the flow
- General initialization
addRandomFlowadd randomized flow to the existing stateaddUVEtaadd \((u,v,\eta)\) to the existing valuesinitFromNetCDFFileinitialize the flow from a NetCDF fileinitWithRandomFlowinitialize with a random flow stateinitWithUVEtainitialize with fluid variables \((u,v,\eta)\)initWithUVRhoinitialize with fluid variables \((u,v,\rho)\)removeAllremoves all energy from the model
- Waves
- Individual modes
addWaveModesadd amplitudes of the given wave modesinitWithWaveModesinitialize with the given wave modesremoveAllWavesremoves all wave from the model, including inertial oscillationssetWaveModesset amplitudes of the given wave modes
- Wave spectra
addGMSpectrumadd waves following a Garrett-Munk spectrumaddWavesWithFrequencySpectrumadd waves with a specified frequency spectruminitWavesWithFrequencySpectruminitialize with waves of a specified frequency spectruminitWithAlternativeSpectruminitialize with an alternative formulation of the GM spectrum in the wavenumber domain.initWithGMSpectruminitialize the wave field following a Garrett-Munk spectrum
- Individual modes
- Inertial oscillations
addInertialMotionsadd inertial motions to existing inertial motionsinitWithInertialMotionsinitialize with inertial motionsremoveAllInertialMotionsremove all inertial motionssetInertialMotionsset inertial motions
- Geostrophic motions
initWithGeostrophicStreamfunctioninitialize with a geostrophic streamfunctionsetGeostrophicStreamfunctionset a geostrophic streamfunctionaddGeostrophicStreamfunctionadd a geostrophic streamfunction to existing geostrophic motionssetGeostrophicModesset amplitudes of the given geostrophic modesaddGeostrophicModesadd amplitudes of the given geostrophic modesremoveAllGeostrophicMotionsremove all geostrophic motions
- Mean density anomalies
addMeanDensityAnomalyAdd a mean-density anomaly to the existing fluid state.initWithMeanDensityAnomalyInitialize the fluid state with a mean-density anomaly.removeAllMeanDensityAnomalyremove all mean density anomaliessetMeanDensityAnomalySet the mean-density-anomaly component.
- General initialization
- Evaluate physical fields
- Registered variables
hasVariableWithNameTest whether state variables are registered by name.summarizeVariablesPrint a table of registered state variables and cache status.variableNamesReturn the names of all registered state variables.variableWithNameCompute or retrieve one or more registered transform variables.
- On the model grid
- Velocity
- Density and displacement
etaapproximate isopycnal deviationrho_barCurrent horizontally averaged density,[Nz 1], in \(\mathrm{kg\,m^{-3}}\).rho_eexcess densityrho_nmDiagnosed no-motion density profile,[Nz 1], in \(\mathrm{kg\,m^{-3}}\).rho_nm0Reference no-motion density profile,[Nz 1], in \(\mathrm{kg\,m^{-3}}\).rho_totaltotal potential density
- Pressure and surface fields
- Vorticity and geostrophic fields
- At arbitrary positions
variableAtPositionWithNameAccess dynamical variables at arbitrary positions in the domain.
- Isopycnal utilities
placeParticlesOnIsopycnalReturn particle depths on the isopycnal identified by a no-motion depth.
- Registered variables
- Manage forcing and closures
- Configure forcing
addForcingAdd forcing or closure objects to this transform.setForcingReplace the complete forcing registry.removeForcingRemove the exact registered forcing objects.removeAllForcingRemove every forcing and closure from this transform.
- Inspect forcing and closures
forcingarray of WVForcing objectsforcingNamesReturn forcing and closure names in application order.forcingWithNameReturn registered forcing objects by name.hasForcingWithNameTest whether forcing objects are registered by name.hasClosureWhether a closure is currently attached to the transform.
- Summarize forcing
summarizeForcingPrint a table of registered forcing and closure objects.
- Configure forcing
- Analyze the flow
- Flow diagnostics
hasMeanPressureDifferenceDiagnose an MDA mean-pressure difference between the boundaries.uvMaxmax horizontal fluid speedwMaxmax vertical fluid speed
- Density validity
isDensityInValidRangeTest whether total density remains within the no-motion density range.
- Potential vorticity and enstrophy
exactPotentialEnstrophyExact potential enstrophy evaluated from available potential vorticity.totalEnstrophyPotential enstrophy computed from geostrophic coefficients.totalEnstrophySpatiallyIntegratedPotential enstrophy evaluated from the gridded QGPV field.
- Spectra
- Spectral fields
kAxisCenteredNx-by-1 x-wavenumber axis in \(\mathrm{rad\,m^{-1}}\).lAxisCenteredNy-by-1 y-wavenumber axis in \(\mathrm{rad\,m^{-1}}\).transformToKLAxestransforms in the spectral domain from (j,kl) to (kAxis,lAxis,j)crossSpectrumWithFgTransformCompute a real modal cross-spectrum using the F-basis transform.crossSpectrumWithGgTransformCompute a real modal cross-spectrum using the G-basis transform.spectrumWithFgTransformCompute a modal autospectrum using the F-basis transform.spectrumWithGgTransformCompute a modal autospectrum using the G-basis transform.
- Radial wavenumber
kRadialradial (k,l) wavenumber on the WV gridtransformToRadialWavenumbertransforms in the spectral domain from (j,kl) to (j,kRadial)
- Frequency
convertFromWavenumberToFrequencyBin wave energy by vertical mode and intrinsic frequency
- Spectral fields
- Flow diagnostics
- Analyze energy
- Component energy
inertialEnergytotal energy of the inertial flowmdaEnergytotal energy of the mean density anomalygeostrophicKineticEnergykinetic energy of the geostrophic flowwaveEnergyTotal energy of the internal-gravity-wave flow.geostrophicPotentialEnergypotential energy of the geostrophic flowgeostrophicEnergytotal energy, geostrophictotalEnergyOfFlowComponentCompute the energy carried by one flow component.
- Total energy
exactTotalEnergyNonlinear total energy evaluated from physical-space fields.totalEnergyTotal energy computed from wave-vortex coefficients.totalEnergySpatiallyIntegratedTotal energy computed from physical-space fields.
- Energy summaries
summarizeEnergyContentdisplays a summary of the energy content of the fluidsummarizeModeEnergyList the most energetic modes
- Component energy
- Save transform state
writeToFileWrite this instance to NetCDF file.
- Convert representations
- Physical fields and coefficients
transformUVEtaToWaveVortextransform fluid variables \((u,v,\eta)\) to wave-vortex coefficients \((A_+,A_-,A_0)\).transformUVWEtaToWaveVortextransform momentum variables \((u,v,w,\eta)\) to wave-vortex coefficients \((A_+,A_-,A_0)\).transformWaveVortexToUVWEtatransform wave-vortex coefficients \((A_+,A_-,A_0)\) to fluid variables \((u,v,\eta)\).
- Physical fields and coefficients
- Differentiate and integrate fields
diffXDifferentiate a gridded field in the periodic x direction.diffYDifferentiate a gridded field in the periodic y direction.diffZFDifferentiate an F-grid field with respect to z.diffZGDifferentiate a G-grid field with respect to z.intZFReturn the first antiderivative of an F-representation.intZGReturn the bottom-zero first antiderivative of a G-representation.
- Inspect flow components
- Primary flow components
waveComponentreturns the internal gravity wave flow componentinertialComponentreturns the inertial oscillation flow componentgeostrophicComponentreturns the geostrophic flow componentmdaComponentreturns the mean density anomaly componentprimaryFlowComponentsPrimary flow components that partition the active coefficient state.primaryFlowComponentNamesretrieve the names of all available variablesprimaryFlowComponentWithNameretrieve a WVPrimaryFlowComponent by name
- Registered and combined components
flowComponentsAll registered physical and diagnostic flow components.flowComponentNamesretrieve the names of all available variablesflowComponentWithNameretrieve a WVFlowComponent by nametotalFlowComponentCombined view of all primary flow components.
- Summarize flow components
summarizeFlowComponentsPrint a table of registered primary and diagnostic components.
- Primary flow components
- Inspect wave-vortex coefficients
- Stored coefficients
- Coefficients at the current time
AptAptis the positive-frequency coefficient array evaluated at the current transform time:AmtAmtis the negative-frequency coefficient array evaluated at the current transform time:A0tA0tis the zero-frequency coefficient array evaluated at the current transform time. On the supported \(f\)-plane transforms,A0has no linear phase winding and thereforewaveCoefficientsAtTimeTReturn positive- and negative-frequency coefficients at the current time.
- Coefficient evolution
t0Reference time for the stored wave phases, in seconds.tCurrent transform time in seconds.OmegaIntrinsic angular frequency of each wave and inertial mode.iOmegaImaginary angular frequency, \(i\Omega\), used for linear phase evolution.phaseunit-magnitude phase factor that advancesApfromt0totconjPhaseconjugate phase factor that advancesAmfromt0tot
- Create a related transform
spectralVariableWithResolutioncreate a new variable with different resolutionwaveVortexTransformWithDoubleResolutioncreate a new WVTransform with double resolutionwaveVortexTransformWithExplicitAntialiasingCreate an explicit-antialiasing transform with the same grid.waveVortexTransformWithResolutionCreate the same transform family at a new resolution.
- Extend a transform
- Flow components
addFlowComponentadd a flow component and its standard variablesaddPrimaryFlowComponentadd a primary flow component, automatically added to the flow
- Operations and variables
addOperationRegister one or more operations and their output variables.operationWithNameretrieve a WVOperation by nameremoveOperationRemove the exact registered operation and its cached outputs.
- Flow components
- Get package information
versionInstalled WaveVortexModel version.
Developer Topics
These items document internal implementation details and are not part of the primary public API.
- Projection and reconstruction coefficients
A0NProjects density displacement onto \(A_0\).A0UProjects \(u\) onto \(A_0\).A0VProjects \(v\) onto \(A_0\).A0ZProjects vertical vorticity onto \(A_0\).ApmDProjects horizontal divergence onto \(A_+\) and \(A_-\).ApmNProjects density displacement onto \(A_+\) and \(A_-\).ApmWNA0Reconstructs density displacement from \(A_0\).NAmReconstructs density displacement from \(A_-\).NApReconstructs density displacement from \(A_+\).PA0Reconstructs pressure height from \(A_0\).UA0Reconstructs \(u\) from \(A_0\).UAmReconstructs \(u\) from \(A_-\).UApReconstructs \(u\) from \(A_+\).VA0Reconstructs \(v\) from \(A_0\).VAmReconstructs \(v\) from \(A_-\).VApReconstructs \(v\) from \(A_+\).WAmReconstructs \(w\) from \(A_-\).WApReconstructs \(w\) from \(A_+\).
- Geometry and mode indexing
- Mode numbers and validity
isValidConjugateKLModeNumberreturn a boolean indicating whether (k,l) is a valid conjugate WV mode numberisValidConjugateModeNumberreturns a boolean indicating whether (k,l,j) is a valid conjugate mode numberisValidKLModeNumberreturn a boolean indicating whether (k,l) is a valid WV mode numberisValidModeNumberreturns a boolean indicating whether (k,l,j) is a valid mode numberisValidPrimaryKLModeNumberreturn a boolean indicating whether (k,l) is a valid primary (non-conjugate) WV mode numberisValidPrimaryModeNumberreturns a boolean indicating whether (k,l,j) is a valid primary (non-conjugate) mode numberkMode_dftk mode-number on the DFT gridkMode_wvk mode number on the WV gridlMode_dftl mode-number on the DFT gridlMode_wvl mode number on the WV gridprimaryKLModeNumberFromKLModeNumbertakes any valid WV mode number and returns the primary mode number
- Linear-index conversion
indexFromKLModeNumberreturn the linear index into k_wv and l_wv from a mode numberindexFromModeNumberreturn the linear index into a spectral matrix given (k,l,j)klModeNumberFromIndexreturn mode number from a linear index into a WV matrixmodeNumberFromIndexReturn mode numbers for spectral linear indices.
- DFT and WV layout metadata
Nk_dftlength of the k-wavenumber dimension on the DFT gridNl_dftlength of the l-wavenumber dimension on the DFT gridconjugateDimensionassumed conjugate dimensiondftConjugateIndices2Dindex into the DFT grid of the conjugate of each WV modedftPrimaryIndices2Dindex into the DFT grid of each WV modeindicesOfFourierConjugatesa matrix of linear indices of the conjugatek_dftk wavenumber dimension on the DFT gridklwavenumber dimensionl_dftl wavenumber dimension on the DFT gridshouldExcludeConjugateswhether the WV grid excludes redundant Hermitian-conjugate wavenumbersshouldExcludeNyquistwhether the WV grid includes Nyquist wavenumbers
- Layout conversion
indicesFromDFTGridToWVGridindices to convert from DFT to WV gridindicesFromWVGridToDFTGridindices to convert from WV to DFT gridtransformFromDFTGridToWVGridconvert from DFT to WV gridtransformFromSpatialDomainToDFTGridtransform from \((x,y,z)\) to \((k,l,z)\) on the DFT gridtransformFromWVGridToDFTGridconvert from a WV to DFT gridtransformToSpatialDomainFromDFTGridtransform from \((k,l,z)\) on the DFT grid to \((x,y,z)\)transformToSpatialDomainFromDFTGridAtPositiontransform from \((k,l)\) on the DFT grid to \((x,y)\) at any position
- Masks and Hermitian bookkeeping
isHermitianCheck if the matrix is Hermitian. Report errors.maskForAliasedModesreturns a mask with locations of modes that will alias with a quadratic multiplication.maskForConjugateFourierCoefficientsa mask indicate the components that are redundant conjugatesmaskForNyquistModesreturns a mask with locations of modes that are not fully resolvedsetConjugateToUnityset the conjugate of the wavenumber (iK,iL) to 1
- Additional geometry utilities
- Mode numbers and validity
- Spectral transforms and operators
FwInvMatrixtransformation matrix \(F_w^{-1}\)FwMatrixtransformation matrix \(F_w\)GwInvMatrixtransformation matrix \(G_w^{-1}\)GwMatrixtransformation matrix \(G_w\)P0Preconditioner for F, size(P)=[Nj 1]. Fu = uhat, (PF)u = Puhat, so ubar==PuhatPF0size(PF,PG)=[Nj x Nz]PF0invTransformation matricesPFpmsize(PF,PG)=[Nj x Nz x Nk]PFpmInvIGW transformation matricesQ0Preconditioner for G, size(Q)=[Nj 1]. Geta = etahat, (QG)eta = Qetahat, so etabar==Qetahat.QG0dimensionless preconditioned G-mode forward transformationQG0invdimensionless preconditioned G-mode inverse transformationQGpmdimensionless preconditioned G-mode forward transformationQGpmInvdimensionless preconditioned G-mode inverse transformationQGwgsize(PF,PG)=[Nj x Nj x Nk]degreesOfFreedomForComplexMatrixa matrix with the number of degrees-of-freedom at each entrydegreesOfFreedomForRealMatrixa matrix with the number of degrees-of-freedom at each entryfastTransformfast transform objecttransformFromSpatialDomainWithFiotransformFromSpatialDomainWithFouriertransformFromSpatialDomainWithG_wtransformToSpatialDomainWithFgargumentstransformToSpatialDomainWithFouriertransformToSpatialDomainWithFourierAtPositiontransformToSpatialDomainWithFwtransformToSpatialDomainWithGgargumentstransformToSpatialDomainWithGwtransformWithG_wg
- Nonlinear flux and forcing internals
- Persistence internals
classRequiredPropertyNamesgeometryFromGroupnamesOfRequiredPropertiesForGeometrynamesOfRequiredPropertiesForRotatingFPlanenamesOfRequiredPropertiesForTransformnamesOfTransformVariablesnewNonrequiredPropertyNamesnewRequiredPropertyNamesrequiredPropertiesForGeometryFromGrouprequiredPropertiesForRotatingFPlaneFromGrouprequiredPropertiesForTransformFromGrouptransformFromGroup
- Caches and registries
propertyAnnotationsForGeometryreturn array of CAPropertyAnnotations initialized by defaultpropertyAnnotationsForRotatingFPlane
- Class internals
DdeltaK2uniqueunique squared-wavenumbersK2uniqueK2Mapcell array Nk in length. Each cell contains indices back to K2PpmPreconditioner for F, size(P)=[Nj x Nk]. Fu = uhat, (PF)u = Puhat, so ubar==PuhatQpmPreconditioner for G, size(Q)=[Nj x Nk]. Geta = etahat, (QG)eta = Qetahat, so etabar==Qetahat.chebfunForZArraydelta_uhatdelta_vhatiK2uniquemap from 2-dim K2, to 1-dim K2uniquemaxFgmaxFwnK2uniquenumber of unique squared-wavenumbersquadraturePointsForStratifiedFlowreturn the quadrature points for a given stratificationthrowErrorIfDensityViolationchecks if the proposed coefficients are a valid adiabatic re-arrangement of the base stateverticalProjectionOperatorsWithRigidLidreturn the normalized projection operators with prefactorswvBuffer