Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up Smagorinsky parameterisation #7

Open
Chris-Pedersen opened this issue Nov 9, 2023 · 1 comment
Open

Speed up Smagorinsky parameterisation #7

Chris-Pedersen opened this issue Nov 9, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@Chris-Pedersen
Copy link
Owner

Chris-Pedersen commented Nov 9, 2023

We have Smagorinsky implemented and working. However we are taking a large number of ffts:

        uh=-il*ph
        vh=ik*ph
        Sxx = torch.fft.irfftn(uh*ik,dim=(1,2))
        Syy = torch.fft.irfftn(vh*il,dim=(1,2))
        Sxy = 0.5 * torch.fft.irfftn(uh * il + vh * ik)
        nu = (self.constant * dx)**2 * torch.sqrt(2 * (Sxx**2 + Syy**2 + 2 * Sxy**2))
        nu_Sxxh = torch.fft.rfftn(nu * Sxx,dim=(1,2))
        nu_Sxyh = torch.fft.rfftn(nu * Sxy,dim=(1,2))
        nu_Syyh = torch.fft.rfftn(nu * Syy,dim=(1,2))
        du = 2 * (torch.fft.irfftn(nu_Sxxh * ik,dim=(1,2)) + torch.fft.irfftn(nu_Sxyh * il,dim=(1,2)))
        dv = 2 * (torch.fft.irfftn(nu_Sxyh * ik,dim=(1,2)) + torch.fft.irfftn(nu_Syyh * il,dim=(1,2)))
        ## Take curl to convert u, v forcing to potential vorticity forcing
        dq = -torch.fft.irfftn(il*torch.fft.rfftn(du,dim=(1,2)),dim=(1,2))+torch.fft.irfftn(ik*torch.fft.rfftn(dv,dim=(1,2)),dim=(1,2))

Given the relationship between the velocities and the streamfunction, and that we are mostly just taking derivatives here, there should be some speedups possible. And given that we need this Smag even for our "DNS", we should make this as efficient as possible.

@Chris-Pedersen Chris-Pedersen added the enhancement New feature or request label Nov 24, 2023
@Chris-Pedersen
Copy link
Owner Author

So this is becoming more significant now due to #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant