Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisteunissen committed Nov 8, 2023
2 parents 562bbe8 + 6763a2f commit 9245838
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/m_photoi_helmh.f90
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ subroutine photoi_helmh_initialize(tree, cfg, is_used, eta)
real(dp) :: frac_O2, dummy(0)

call CFG_add_get(cfg, "photoi_helmh%author", author, &
"Can be Luque (default), Bourdon-2, Bourdon-3 or custom")
"Can be Bourdon-3 (default), Bourdon-2, Luque or custom")
call CFG_add(cfg, "photoi_helmh%lambdas", dummy, &
"Lambdas to use in Helmholtz eq; unit 1/(m bar)", &
.true.)
Expand Down Expand Up @@ -124,6 +124,7 @@ subroutine photoi_helmh_initialize(tree, cfg, is_used, eta)
coeffs = coeffs * (frac_O2 * gas_pressure)**2 ! 1/m^2
case ("custom")
call CFG_get_size(cfg, "photoi_helmh%lambdas", n_modes)
if (n_modes < 1) error stop "Custom photoionization lambdas and coeffs missing."
allocate(lambdas(n_modes))
allocate(coeffs(n_modes))
call CFG_get(cfg, "photoi_helmh%lambdas", lambdas)
Expand Down
30 changes: 26 additions & 4 deletions tools/sensitivity_analyze_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,35 @@
description='''Script to analyze results from a sensitivity study
Authors: Hemaditya Malla, Jannis Teunissen''')
parser.add_argument('logs', type=str, nargs='+',
help='Log files')
help='Log/amounts files')
parser.add_argument('-y', type=str, nargs='+', default=["sum(n_e)"],
help='Variables in the log files to compare')
parser.add_argument('-time_index', type=int, default=-1,
help='Which time index in the log files to consider')
args = parser.parse_args()

logs = sorted(args.logs)
logs_df = [pd.read_csv(f, delim_whitespace=True) for f in args.logs]

# Determine whether we analyse log files(pandas dataframe) or species amounts(txt files)
if not all([x.endswith('amounts.txt') for x in logs]):
logs_df = [pd.read_csv(f, delim_whitespace=True) for f in args.logs]
base_name = logs[0].replace('_log.txt', '')
else:
# Can we use the below variable elsewhere below?
analyse_chemistry = True
# Make sure that the default argument is changed
if args.y[0] == "sum(n_e)":
args.y = ["e"]

# Loading the species list and appending the time column to it
base_name = logs[0].replace('_amounts.txt', '')
with open(base_name + '_species.txt', 'r') as f:
species_list = [x.strip() for x in f.readlines() if x.strip()]
species_list.insert(0, "time")

# Load amounts of species and create a dataframe of them so that the below code wont break
logs_df = [pd.DataFrame(np.loadtxt(f), columns=species_list) for f in args.logs]


log_sizes = np.array([len(df) for df in logs_df])
max_size, min_size = log_sizes.max(), log_sizes.min()
Expand Down Expand Up @@ -59,7 +79,9 @@
print(f'R{"#":<4} {"variable":15} {"mu":>15} {"mustar":>15} {"sigma":>15}')

for i, ix in enumerate(reaction_ix):
values = np.array([df[args.y] for _, df in all_cases[ix]])
# print("test: ", args.y)
# test = [df[args.y] for _, df in all_cases[ix]]
values = np.array([df[args.y].to_numpy() for _, df in all_cases[ix]])
factors = np.array([f for f, _ in all_cases[ix]])

# Get values at time index
Expand Down Expand Up @@ -89,7 +111,7 @@
print(f'{"rank":<6} R{"#":<6} {"reaction_list":40} {"max(mustar)":15}')

# Load reaction names
base_name = logs[0].replace('_log.txt', '')
# base_name = logs[0].replace('_log.txt', '')
with open(base_name + '_reactions.txt', 'r') as f:
reactions_list = [x.strip() for x in f.readlines() if x.strip()]

Expand Down

0 comments on commit 9245838

Please sign in to comment.