def get_athinput(cwd=-1): if cwd == -1: cwd = os.getcwd() athin = cwd + '/' + [ fnm for fnm in os.listdir(os.getcwd() + '/') if fnm.startswith('athinput') ][0] data = ar.athinput(athin) return data
def athinput2riemann(athinput, eos=None): """Uses parameters from "athinput" to define a Riemann problem with a specified (optional) eos.""" if os.path.isfile(athinput): athinput = athena_read.athinput(athinput) if eos is None: # assume ideal EOS with gamma from athinput eos = Ideal(athinput['hydro']['gamma']) if eos == 'H': eos = SimpleHydrogen() pin = athinput['problem'] # only look at d[lr], p[lr], u[lr], T[lr] (state) parameters states = { i: pin[i] for i in pin if (len(i) == 2) and (i[0] in 'dpuT') and (i[1] in 'lr') } return riemann_problem(states, eos)
Typical usage example: foo = ClassFoo() bar = foo.FunctionBar() """ import sys sys.path.insert(0, '/home6/sbaronet/athena-dust/vis/python') import athena_read from pathlib import Path import numpy as np import matplotlib.pyplot as plt # Collect .athdf outputs, init sim consts. and grid athinput = athena_read.athinput('../athinput.si.nas') outputs = sorted( list( Path('../athdf').glob(athinput['job']['problem_id'] + '.out1.*.athdf'))) Omega = athinput['problem']['omega'] # local Keplerian angular frequency T = 2 * np.pi / Omega # orbital period epsilon = athinput['problem']['epsilon'] # avg. dust/gas ρ-ratio in BG state times = [] # sim output times rhopmax, rhopmin = [], [] # max/min dust densities rhogmax, rhogmin = [], [] # max/min gas densities for output in outputs: # load all data into memory data = athena_read.athdf(output) times.append(data['Time'] / T) temp = np.amax(data['rhop']) - epsilon # difference w/ epsilon
Typical usage example: foo = ClassFoo() bar = foo.FunctionBar() """ import sys sys.path.insert(0, '/home6/sbaronet/athena-dust/vis/python') import athena_read from pathlib import Path import numpy as np import matplotlib.pyplot as plt from matplotlib import animation # Collect .athdf outputs, init sim consts. and grid athinput = athena_read.athinput('../athinput.si') outputs = sorted(list(Path('../athdf').glob(athinput["job"]["problem_id"] + '.out1.*.athdf'))) c_s = athinput['hydro']['iso_sound_speed'] # sound speed Omega = athinput['problem']['omega'] # local Keplerian angular frequency H = c_s / Omega # gas scale height T = 2*np.pi/Omega # orbital period data = athena_read.athdf(outputs[0]) xf, zf = data['x1f'] / H, data['x2f'] / H times = [] # sim output times rhos = [] # particle density for output in outputs: # load all data into memory data = athena_read.athdf(output) times.append(data['Time'] / T) rhos.append(data['rho'][0]) # [0] effectively flattens 3D array
def load_athinput(athinput_path, do_path_format=1): '''Loads data from athinput files. ''' return athinput(format_path(athinput_path, do_path_format))
# densities, of the dust during the saturated, turbulent state of the SI. # # Author: Stanley A. Baronett # Created: 2022-03-09 # Last Modified: 2022-03-12 #============================================================================== import sys sys.path.insert(0, '/home6/sbaronet/athena-dust/vis/python') import athena_read import numpy as np from pathlib import Path # from scipy.stats import skew, kurtosis # for later use with outputp data # Collect Athena++ inputs, outputs, and sim constants t_sat, n_bins = float(sys.argv[1]), int(sys.argv[2]) # t_sat in code unit [T] athinput = athena_read.athinput('athinput.si') Pi = athinput['problem']['duy0'] # radial pressure gradient etav_K = Pi * athinput['hydro']['iso_sound_speed'] # scaling factor dt = athinput['output1']['dt'] # time between vp1 outputs i_sat = int(t_sat / dt) # sat state output index outputs = sorted( list(Path('athdf').glob(athinput["job"]["problem_id"] + '.out1.*.athdf'))) sat_outputs = outputs[i_sat:] # slice saturated state vpxs, rhops = [], [] print(f'Compiling data...', flush=True) for i, output in enumerate(sat_outputs): data = athena_read.athdf(output) vpxs.append(data['vp1']) rhops.append(data['rhop'])