From 292e814f332138979bf673bab0ad23a0f1cd3ceb Mon Sep 17 00:00:00 2001 From: Bob Myhill Date: Sat, 25 May 2024 16:26:06 +0100 Subject: [PATCH] added new docstrings --- .../HeFESTo_to_burnman.py | 12 ++- burnman/minerals/SLB_2022.py | 90 +++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/burnman/data/input_raw_endmember_datasets/HeFESTo_to_burnman.py b/burnman/data/input_raw_endmember_datasets/HeFESTo_to_burnman.py index cf3887ef..ebe6deac 100644 --- a/burnman/data/input_raw_endmember_datasets/HeFESTo_to_burnman.py +++ b/burnman/data/input_raw_endmember_datasets/HeFESTo_to_burnman.py @@ -87,7 +87,7 @@ def rfloat(x, m=1.0): # Do not process liquid!! if os.stat(f).st_size > 0 and str(f).split("/")[-1] != "liq": name = str(f).split("/")[-1] - d = pd.read_csv(f, sep='\\s+') + d = pd.read_csv(f, sep="\\s+") endmembers = list(d.columns) @@ -384,9 +384,19 @@ def rfloat(x, m=1.0): for key, prm in sorted(sol_params.items()): + docstring = '"""' + docstring += f'{prm["solution_type"]} model for {solution_aliases[key]} ({key}).\n' + docstring += "Endmembers (and site species distributions) are given in the order:\n" + for i in range(prm["n_mbrs"]): + docstring += f'- {prm["mbr_names"][i]} ({prm["mbr_site_formulae"][i]})\n' + if key == "mw": + docstring += "The entropy from the first site in magnetite is not counted.\n" + docstring += '"""' + print( f"\nclass {solution_aliases[key]}(Solution):\n" " def __init__(self, molar_fractions=None):\n" + f" {docstring}\n" f' self.name = "{solution_aliases[key]}"\n' f" self.solution_model = {prm['solution_type']}(\n" " endmembers=[" diff --git a/burnman/minerals/SLB_2022.py b/burnman/minerals/SLB_2022.py index 8b05f60b..5657e0d9 100644 --- a/burnman/minerals/SLB_2022.py +++ b/burnman/minerals/SLB_2022.py @@ -1622,6 +1622,11 @@ def __init__(self): class c2c_pyroxene(Solution): def __init__(self, molar_fractions=None): + """IdealSolution model for c2c_pyroxene (c2c). + Endmembers (and site species distributions) are given in the order: + - mgc2 ([Mg]2) + - fec2 ([Fe]2) + """ self.name = "c2c_pyroxene" self.solution_model = IdealSolution( endmembers=[ @@ -1635,6 +1640,12 @@ def __init__(self, molar_fractions=None): class calcium_ferrite_structured_phase(Solution): def __init__(self, molar_fractions=None): + """AsymmetricRegularSolution model for calcium_ferrite_structured_phase (cf). + Endmembers (and site species distributions) are given in the order: + - mgcf ([Mg][Al]) + - fecf ([Fe][Al]) + - nacf ([Na][Si]) + """ self.name = "calcium_ferrite_structured_phase" self.solution_model = AsymmetricRegularSolution( endmembers=[ @@ -1651,6 +1662,14 @@ def __init__(self, molar_fractions=None): class clinopyroxene(Solution): def __init__(self, molar_fractions=None): + """AsymmetricRegularSolution model for clinopyroxene (cpx). + Endmembers (and site species distributions) are given in the order: + - di ([Ca][Mg][Si]2) + - he ([Ca][Fe][Si]2) + - cen ([Mg][Mg][Si]2) + - cats ([Ca][Al][Si1/2Al1/2]2) + - jd ([Na][Al][Si]2) + """ self.name = "clinopyroxene" self.solution_model = AsymmetricRegularSolution( endmembers=[ @@ -1674,6 +1693,14 @@ def __init__(self, molar_fractions=None): class garnet(Solution): def __init__(self, molar_fractions=None): + """SymmetricRegularSolution model for garnet (gt). + Endmembers (and site species distributions) are given in the order: + - py ([Mg]3[Al][Al]) + - al ([Fe]3[Al][Al]) + - gr ([Ca]3[Al][Al]) + - mgmj ([Mg]3[Mg][Si]) + - namj ([Na2/3Mg1/3]3[Si][Si]) + """ self.name = "garnet" self.solution_model = SymmetricRegularSolution( endmembers=[ @@ -1702,6 +1729,12 @@ def __init__(self, molar_fractions=None): class ilmenite(Solution): def __init__(self, molar_fractions=None): + """SymmetricRegularSolution model for ilmenite (il). + Endmembers (and site species distributions) are given in the order: + - mgil ([Mg][Si]) + - feil ([Fe][Si]) + - co ([Al][Al]) + """ self.name = "ilmenite" self.solution_model = SymmetricRegularSolution( endmembers=[ @@ -1717,6 +1750,13 @@ def __init__(self, molar_fractions=None): class ferropericlase(Solution): def __init__(self, molar_fractions=None): + """SymmetricRegularSolution model for ferropericlase (mw). + Endmembers (and site species distributions) are given in the order: + - pe ([Mg]2[Mg]2) + - wu ([Fe]2[Fe]2) + - anao ([Na]2[Al]2) + The entropy from the first site in magnetite is not counted. + """ self.name = "ferropericlase" self.solution_model = SymmetricRegularSolution( endmembers=[ @@ -1733,6 +1773,12 @@ def __init__(self, molar_fractions=None): class new_aluminous_phase(Solution): def __init__(self, molar_fractions=None): + """SymmetricRegularSolution model for new_aluminous_phase (nal). + Endmembers (and site species distributions) are given in the order: + - mnal ([Mg]2[Al5/6Si1/6]6) + - fnal ([Fe]2[Al5/6Si1/6]6) + - nnal ([Na]2[Al3/6Si3/6]6) + """ self.name = "new_aluminous_phase" self.solution_model = SymmetricRegularSolution( endmembers=[ @@ -1748,6 +1794,11 @@ def __init__(self, molar_fractions=None): class olivine(Solution): def __init__(self, molar_fractions=None): + """SymmetricRegularSolution model for olivine (ol). + Endmembers (and site species distributions) are given in the order: + - fo ([Mg]2) + - fa ([Fe]2) + """ self.name = "olivine" self.solution_model = SymmetricRegularSolution( endmembers=[ @@ -1762,6 +1813,13 @@ def __init__(self, molar_fractions=None): class orthopyroxene(Solution): def __init__(self, molar_fractions=None): + """SymmetricRegularSolution model for orthopyroxene (opx). + Endmembers (and site species distributions) are given in the order: + - en ([Mg][Mg]) + - fs ([Fe][Fe]) + - mgts ([Mg][Al]) + - odi ([Ca][Mg]) + """ self.name = "orthopyroxene" self.solution_model = SymmetricRegularSolution( endmembers=[ @@ -1778,6 +1836,11 @@ def __init__(self, molar_fractions=None): class plagioclase(Solution): def __init__(self, molar_fractions=None): + """SymmetricRegularSolution model for plagioclase (plg). + Endmembers (and site species distributions) are given in the order: + - an ([Ca]) + - ab ([Na]) + """ self.name = "plagioclase" self.solution_model = SymmetricRegularSolution( endmembers=[ @@ -1792,6 +1855,12 @@ def __init__(self, molar_fractions=None): class post_perovskite(Solution): def __init__(self, molar_fractions=None): + """SymmetricRegularSolution model for post_perovskite (ppv). + Endmembers (and site species distributions) are given in the order: + - mppv ([Mg][Si]) + - fppv ([Fe][Si]) + - appv ([Al][Al]) + """ self.name = "post_perovskite" self.solution_model = SymmetricRegularSolution( endmembers=[ @@ -1807,6 +1876,12 @@ def __init__(self, molar_fractions=None): class bridgmanite(Solution): def __init__(self, molar_fractions=None): + """SymmetricRegularSolution model for bridgmanite (pv). + Endmembers (and site species distributions) are given in the order: + - mgpv ([Mg][Si]) + - fepv ([Fe][Si]) + - alpv ([Al][Al]) + """ self.name = "bridgmanite" self.solution_model = SymmetricRegularSolution( endmembers=[ @@ -1822,6 +1897,11 @@ def __init__(self, molar_fractions=None): class ringwoodite(Solution): def __init__(self, molar_fractions=None): + """SymmetricRegularSolution model for ringwoodite (ri). + Endmembers (and site species distributions) are given in the order: + - mgri ([Mg]2) + - feri ([Fe]2) + """ self.name = "ringwoodite" self.solution_model = SymmetricRegularSolution( endmembers=[ @@ -1836,6 +1916,11 @@ def __init__(self, molar_fractions=None): class mg_fe_aluminous_spinel(Solution): def __init__(self, molar_fractions=None): + """SymmetricRegularSolution model for mg_fe_aluminous_spinel (sp). + Endmembers (and site species distributions) are given in the order: + - sp ([Mg3/4Al1/4]4[Al7/8Mg1/8]8) + - hc ([Fe3/4Al1/4]4[Al7/8Fe1/8]8) + """ self.name = "mg_fe_aluminous_spinel" self.solution_model = SymmetricRegularSolution( endmembers=[ @@ -1850,6 +1935,11 @@ def __init__(self, molar_fractions=None): class wadsleyite(Solution): def __init__(self, molar_fractions=None): + """SymmetricRegularSolution model for wadsleyite (wa). + Endmembers (and site species distributions) are given in the order: + - mgwa ([Mg]2) + - fewa ([Fe]2) + """ self.name = "wadsleyite" self.solution_model = SymmetricRegularSolution( endmembers=[