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

calc vertical flux function #98

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions taufactor/taufactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,16 @@ def check_convergence(self, verbose, conv_crit):
self.old_fl = self.new_fl
return False

def check_vertical_flux(self, conv_crit):
def calc_vertical_flux(self):
'''Calculates the vertical flux through the volume'''
vert_flux = self.conc[:, 1:-1, 1:-1, 1:-1] - \
self.conc[:, :-2, 1:-1, 1:-1]
vert_flux[self.conc[:, :-2, 1:-1, 1:-1] == 0] = 0
vert_flux[self.conc[:, 1:-1, 1:-1, 1:-1] == 0] = 0
return vert_flux

def check_vertical_flux(self, conv_crit):
vert_flux = self.calc_vertical_flux()
fl = torch.sum(vert_flux, (0, 2, 3))[1:-1]
err = (fl.max() - fl.min())/(fl.max())
if fl.min() == 0:
Expand Down Expand Up @@ -286,10 +291,15 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2, D_0=1):
self.end_simulation(iter_limit, verbose, start)
return self.tau

def check_vertical_flux(self, conv_crit):
def calc_vertical_flux(self):
'''Calculates the vertical flux through the volume'''
vert_flux = abs(self.conc - torch.roll(self.conc, 1, 1))
vert_flux[self.conc == 0] = 0
vert_flux[torch.roll(self.conc, 1, 1) == 0] = 0
return vert_flux

def check_vertical_flux(self, conv_crit):
vert_flux = self.calc_vertical_flux()
fl = torch.sum(vert_flux, (0, 2, 3))[3:-2]
err = (fl.max() - fl.min())*2/(fl.max() + fl.min())
if err < conv_crit or torch.isnan(err).item():
Expand Down Expand Up @@ -488,10 +498,15 @@ def check_convergence(self, verbose, conv_crit):

return False

def check_vertical_flux(self, conv_crit):
def calc_vertical_flux(self):
'''Calculates the vertical flux through the volume'''
vert_flux = (self.conc[:, 1:-1, 1:-1, 1:-1] - self.conc[:,
:-2, 1:-1, 1:-1]) * self.pre_factors[1][:, :-2, 1:-1, 1:-1]
vert_flux[self.nn == torch.inf] = 0
return vert_flux

def check_vertical_flux(self, conv_crit):
vert_flux = self.calc_vertical_flux()
fl = torch.sum(vert_flux, (0, 2, 3))[2:-2]
err = (fl.max() - fl.min())*2/(fl.max() + fl.min())
if err < conv_crit or torch.isnan(err).item():
Expand Down
Loading