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

Develop #5

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e342431
Created dictionary input file. Modified model to take arguments from …
JorickLania Nov 4, 2024
61cd9ca
Created CETOgrid.py script to run the model over a grid of values. Mo…
JorickLania Nov 7, 2024
63b6ce6
Ran the CETOgrid script over temperatures from 3500 to 6000 K. Moved …
JorickLania Nov 13, 2024
6bcd651
reorganised directories, added constants.py and thermodynamics.py
JorickLania Jan 7, 2025
26902ec
Implemented all Shomate equations in thermodynamics.py; begun impleme…
JorickLania Jan 8, 2025
850b95b
Finished implementation of thermodynamics equation
JorickLania Jan 15, 2025
8a0c562
Implemented unit tests for thermodynamics script
JorickLania Jan 16, 2025
79020f7
Added results directory to gitignore for clarity
JorickLania Jan 16, 2025
53c689a
Added results directory to gitignore
JorickLania Jan 16, 2025
939ed1f
Removed leftover clutter from directory
JorickLania Jan 16, 2025
4d603a7
Added vscode and pytest to gitignore
JorickLania Jan 20, 2025
a823e97
Rewrote default input file, checked for usability and readability. Im…
JorickLania Jan 20, 2025
e0d848f
Created utilities file for functions without a clear organisational p…
JorickLania Jan 22, 2025
7c4b74d
Added sigmoidal penalty function for later use to utilities
JorickLania Jan 22, 2025
94d21b8
Started implementing the optimisation function in script 'model.py'
JorickLania Jan 22, 2025
90d9140
Changed i, j in forloops in utilities functions to be more descriptive.
JorickLania Feb 3, 2025
2d1f034
Created test for optimisationfunction (not yet confirmed to work).
JorickLania Feb 4, 2025
81c732c
Edit to test_optimisationfunction.py to allow the test to run properl…
JorickLania Feb 4, 2025
1265e13
Completed testing for optimisation function. Optimisation function in…
JorickLania Feb 4, 2025
9901a27
Added more activites to activity.py. Made edits for clarity to config…
JorickLania Feb 6, 2025
da676e1
Added smoothTriangle function to utilities for future use. Editted si…
JorickLania Feb 6, 2025
3d13538
Implemented non-initial version of optimisation / objective function.…
JorickLania Feb 11, 2025
d52513f
Tested and verified optimisation function against Young's values. Imp…
JorickLania Feb 12, 2025
c499520
Implemented dual_annealing; editted most functions to take two dictio…
JorickLania Feb 17, 2025
f639ec8
Fixed test_initialoptimisationfunction, start implemented model.py
JorickLania Feb 18, 2025
248efc9
Made changes to objective function to properly calculate pressure.
JorickLania Feb 19, 2025
878cb0c
Fixed mistakes in computation of mass balance equations in objective …
JorickLania Feb 20, 2025
ec73c7a
Made small changes to boundary conditions and constants to fix linger…
JorickLania Feb 21, 2025
4dd94df
Maade bool param for ideal mixing clearer in defaultconfig and functi…
JorickLania Feb 21, 2025
471a36e
Cleaned up after final testing/debugging. Added docstrings for MCMC m…
JorickLania Feb 21, 2025
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: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# Virtual environment and pip install requirements
venv
requirements.txt

# Vscode
.vscode/settings.json

#Pytest
.pytest_cache

# Results directory
results/run1
results/

# GRT directory (used for reference)
source/codeYoung/GRT_1300_6000

# temporary progress files
progress.png
progress.txt

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
71 changes: 0 additions & 71 deletions initial_atm_vMCMC_2024.txt

This file was deleted.

156 changes: 0 additions & 156 deletions output_summary_atm_SiH4_xB_SAVE.txt

This file was deleted.

23 changes: 23 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
contourpy==1.3.0
corner==2.2.2
cycler==0.12.1
emcee==3.1.6
fonttools==4.54.1
importlib_metadata==8.5.0
importlib_resources==6.4.5
jax==0.4.30
jaxlib==0.4.30
kiwisolver==1.4.7
llvmlite==0.43.0
matplotlib==3.9.2
ml_dtypes==0.5.0
numba==0.60.0
numpy==2.0.2
opt_einsum==3.4.0
packaging==24.1
pillow==10.4.0
pyparsing==3.1.4
python-dateutil==2.9.0.post0
scipy==1.13.1
six==1.16.0
zipp==3.20.2
60 changes: 60 additions & 0 deletions source/activity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from __future__ import annotations
import numpy as np
from numpy import log as ln

def get_activity(D, config, get_all=False):
"""Computes activity coefficient for model species. For ideal mixing, all ln(g) terms equal
zero such that there is no deviation from ideal behaviour. Non-ideal mixing is captured by the
computed lng (ln gamma) terms below for Si, O, H2, H2O in melt phase, H in metal phase and xB.
Optional boolean parameter get_all controls whether all activities are computed and returned,
or if only the activities of Si, O and xB are returned.
Parameters:
D (dict) : Dictionary representing variable input for model;
retrieves mole fractions of species used in calculating coefficients.
config (dict) : Dictionary of global model input, retrieves parameters that are not
varied in the model: T_surface, T_eq, bool_ideal_mixing. The latter
controls non-ideality of activity coefficients. If False, lng terms will
be computed via empirical formulae. If True, lng terms are zero.
get_all (Bool) : Boolean controlling whether terms for H2, H2O_melt and H_metal are
computed and returned. These equations are implemented but their
validity is still under review. Default is False.

Returns:
lng (list) : List of lng terms for Si, O, H2, H2O (melt), H (metal) and xB."""

if config["bool_ideal_mixing"] is False:
lngSi = -6.65*1873.0/config["T_eq"]-(12.41*1873.0/config["T_eq"])*ln(1.0-D["Si_metal"]) - \
((-5.0*1873.0/config["T_eq"])*D["O_metal"]*(1.0+ln(1-D["O_metal"])/D["O_metal"]-1.0/(1.0-D["Si_metal"]))) + \
(-5.0*1873.0/config["T_eq"])*D["O_metal"]**2.0*D["Si_metal"]*(1.0/(1.0-D["Si_metal"])+1.0/(1.0-D["O_metal"]) + \
D["Si_metal"]/(2.0*(1.0-D["Si_metal"])**2.0)-1.0)
lngO = (4.29-16500.0/config["T_eq"])-(-1.0*1873.0/config["T_eq"])*ln(1.0-D["O_metal"]) - \
((-5.0*1873.0/config["T_eq"])*D["Si_metal"]*(1.0+ln(1-D["Si_metal"])/D["Si_metal"]-1.0/(1.0-D["O_metal"]))) + \
(-5.0*1873.0/config["T_eq"])*D["Si_metal"]**2.0*D["O_metal"]*(1.0/(1.0-D["O_metal"])+1.0/(1.0-D["Si_metal"])+ \
D["O_metal"]/(2.0*(1.0-D["O_metal"])**2.0)-1.0)

xB = (D["H2O_melt"]/(1-D["H2O_melt"])*(1/3)) / (1.0 + (D["H2O_melt"]/(1-D["H2O_melt"])*(1/3)))

if get_all is True:
lngH2 = (74829.6/(8.3144*config["T_eq"]))*(1.0 - D["H2_melt"])**2.0

lngH2O_melt = (74826.0/(8.3144*config["T_eq"]))*(1.0 - D["H2O_melt"])**2.0

lngH_metal_T_indep = -1.9*(1.0 - D["H_metal"])**2.0

x_light = D["Si_metal"] + D["O_metal"]
lngH_metal = -3.8*x_light*(1.0 + ln(1.0 - x_light)/x_light - 1.0/(1.0-D["H_metal"])) + 3.8*(x_light**2.0)*D["H_metal"]* \
(1.0/(1.0 - D["H_metal"]) + 1.0/(1.0 - x_light) + D["H_metal"]/(2.0*(1.0-D["H_metal"])**2.0) - 1.0)
else:
lngH2 = 0.0
lngH2O_melt = 0.0
lngH_metal = 0.0

elif config['bool_ideal_mixing'] is True:
lngSi = 0.0
lngO = 0.0
xB = 0.0
lngH2 = 0.0
lngH2O_melt = 0.0
lngH_metal = 0.0

return [lngSi, lngO, lngH2, lngH2O_melt, lngH_metal, xB]
Loading