METHODS-Group / DRDMannTurb

BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Confirm (approximate) divergence-free properties for resulting model #24

Closed alizma closed 11 months ago

alizma commented 1 year ago

To confirm properties of the model, we should evaluate the divergence of the fit at every training iteration. This can be done with evaluating

$$ \langle \vec{k}_1, \nabla \cdot \vec{U}_i \rangle \approx 0 \quad \forall i \in \{ 1, 2, 3 \}$$

where $\vec{U}_i$ is the velocity in the $i$-th direction. In other words, we want to confirm that the Helmholtz decomposition for the resulting wind vector field consists approximately only of the curl component.

To obtain the velocity field from the surrogate spectra learned by the model, do we use

$$U = \mathcal{F}^{-1} \mathcal{G} $$

where $\mathcal{G}$ is the point-wise multiplication by $G(k)$ which is positive-definite and satisfies $G(k) G^* (k) = \Phi (k)$?

brendankeith commented 1 year ago

One can prove that this is unnecessary as the class of models we are working with is divergence-free at the continuous-level, by construction. If we wish to make a rigorous argument for the paper, we can copy Ustim's argument from Section 4.2 and Remark 4.3 of https://arxiv.org/abs/2008.03957.

(Note that Q(k) is the Fourier transform of the curl operator.)

alizma commented 11 months ago

I'm still not completely sure how to prove this on the continuous level, but having divergence-free-ness is necessary for testing the package and ensuring that the fluctuation generation works as promised. To this end, GenerateFluctuationField now has the new evaluate_divergence() method, which computes the point-wise divergence of the vector field using 2nd order centered differences (a wrapper around an iterated np.gradient() application) on the associated grid. This method returns the full point-wise divergence tensor and further information about the divergence can be computed with .max(), .sum(), .mean() for maximum, total, and average divergences across the entire field.

In the current example, this method indeed confirms that the point-wise divergence is small in the fluctuation field generated from a pre-trained DRD model (the same network used in the first example in the paper) -- across several runs, the largest in magnitude I've observed is approximately $0.064...$ with the spacing (36.36363 96.0, 17.45454) with the average being on the order of $10^{-2}$. In other words, even on this coarse grid, the divergence is fairly small. Moreover, increasing the resolution of the discretization (decreasing the sizes of the spacing) results in divergence quantities which are on the same order of magnitude. One could perform this evaluation across a wide range of discretizations to obtain a limiting divergence, but in the end it only matters that this is below a prescribed tolerance.

The new methods have been added to the documentation and example of generating the fluctuation field, but it remains to use them in the test suite, #44.

I'll close this issue since the method has been added and the concept has been proven, but this should be revisited in the future when it comes to proving the continuous-level properties.

brendankeith commented 11 months ago

I'm still not completely sure how to prove this on the continuous level, but having divergence-free-ness is necessary for testing the package and ensuring that the fluctuation generation works as promised. To this end, GenerateFluctuationField now has the new evaluate_divergence() method, which computes the point-wise divergence of the vector field using 2nd order centered differences (a wrapper around an iterated np.gradient() application) on the associated grid. This method returns the full point-wise divergence tensor and further information about the divergence can be computed with .max(), .sum(), .mean() for maximum, total, and average divergences across the entire field.

In the current example, this method indeed confirms that the point-wise divergence is small in the fluctuation field generated from a pre-trained DRD model (the same network used in the first example in the paper) -- across several runs, the largest in magnitude I've observed is approximately 0.064... with the spacing (36.36363 96.0, 17.45454) with the average being on the order of 10−2. In other words, even on this coarse grid, the divergence is fairly small. Moreover, increasing the resolution of the discretization (decreasing the sizes of the spacing) results in divergence quantities which are on the same order of magnitude. One could perform this evaluation across a wide range of discretizations to obtain a limiting divergence, but in the end it only matters that this is below a prescribed tolerance.

The new methods have been added to the documentation and example of generating the fluctuation field, but it remains to use them in the test suite, #44.

I'll close this issue since the method has been added and the concept has been proven, but this should be revisited in the future when it comes to proving the continuous-level properties.

The reason that the error doesn't decrease with the grid spacing is due to the error introduced by domain truncation. For some domains, boundary conditions, and model covariances, it is possible to write out an expression for the error analytically [1]. In our case, that is probably not possible, but I expect that this source of error will decay inverse exponentially with the domain size.

[1] https://doi.org/10.1137/18M1215700