Skip to content

Commit

Permalink
Moved files to module q3d, fixed broken imports
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlhicks committed Feb 16, 2023
1 parent 2b2f785 commit 92bdf12
Show file tree
Hide file tree
Showing 27 changed files with 104 additions and 278 deletions.
File renamed without changes.
37 changes: 36 additions & 1 deletion nondim.py → legacy_scripts/nondim.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import sys
import getopt
import yaml
from newsave import nondimensionalize

usage_str = """
usage: python nondim.py [-s] <constants-file>.yml <radius>
Expand All @@ -14,6 +13,42 @@
def usage():
print(usage_str)

def nondimensionalize(const,R):
""" For a constants dictionary const and a length R (for a sphere-like mesh,
the radius), returns the non-dimensionalized version of these constants """

from math import sqrt

nd_const = {}

# Define auxiliary constants

AM = max(const['A'],const['B'],const['C'])
LM = max(const['L1'],const['L2'],const['L3'])

# Define non-dimensionalized constants

nd_const['L0'] = const['L0']
nd_const['A'] = const['A']/AM
nd_const['B'] = const['B']/AM
nd_const['C'] = const['C']/AM
nd_const['L1'] = const['L1']/LM
nd_const['L2'] = const['L2']/LM
nd_const['L3'] = const['L3']/LM
nd_const['W0'] = const['W0']*R/(LM)
nd_const['W1'] = const['W1']*R/(LM)
nd_const['W2'] = const['W2']*R/(LM)
nd_const['q0'] = const['q0']*R
nd_const['ep'] = sqrt(LM/AM)/R
try:
nd_const['beta'] = const['beta']
except:
nd_const['beta'] = 1

# Return the non-dimensionalized constants

return nd_const

def main():
save_mode = False

Expand Down
File renamed without changes.
175 changes: 0 additions & 175 deletions main.py

This file was deleted.

4 changes: 2 additions & 2 deletions compute.py → q3d/compute.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from sympyplus import *

from config import constants as c
from config import settings
from q3d.config import constants as c
from q3d.config import settings

# Set up Qvector objects

Expand Down
2 changes: 1 addition & 1 deletion compute_terms.py → q3d/compute_terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from sympyplus import *

from config import constants as c
from q3d.config import constants as c

# Set up Qvector objects

Expand Down
2 changes: 1 addition & 1 deletion config.py → q3d/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def nondimensionalize(c:FromDict,R:float):
c.beta = 1

def initialize(settings_path,constants_path=None):
from loaddump import load_yml
from q3d.loaddump import load_yml

# make settings global, thus importable
global settings
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion firedrakeplus/check.py → q3d/firedrakeplus/check.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import printoff as pr
import q3d.printoff as pr

def check_energy_decrease(energies,current_time):
""" Checks for energy decreasee in latest energy iteration. """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from firedrake import interpolate, assemble
from firedrake import dx, ds
from ufl.operators import *
import printoff as pr
import q3d.printoff as pr

class linesearch:
def ls(name,*args,**kwargs):
Expand All @@ -21,7 +21,7 @@ def ls(name,*args,**kwargs):
def backtrack(q_prev,time_der,alpha):
""" Given the previous guess, the time derivative, and the time step
alpha, returns xi computed by backtracking. """
from firedrakeplus.eqnglobals import EqnGlobals
from q3d.firedrakeplus.eqnglobals import EqnGlobals

H1_vec = q_prev.function_space()

Expand Down Expand Up @@ -96,8 +96,8 @@ def none(q_prev,time_der,alpha):
return alpha

def compute_energy(*functions, der=0, min_moment=None):
from firedrakeplus.eqnglobals import EqnGlobals
from config import settings
from q3d.firedrakeplus.eqnglobals import EqnGlobals
from q3d.config import settings

# Check for correct values

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def set_eqn_globals(comp,uflcache_dict):
from config import settings
from q3d.config import settings

global EqnGlobals
class EqnGlobals:
Expand Down
2 changes: 1 addition & 1 deletion firedrakeplus/fy.py → q3d/firedrakeplus/fy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ def RandomFunction(function_space):
return function

def ManuQ(mesh):
from firedrakeplus.eqnglobals import EqnGlobals
from q3d.firedrakeplus.eqnglobals import EqnGlobals
return firedrakefy(EqnGlobals.manu_q,mesh)
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 92bdf12

Please sign in to comment.