PPv3.1 - Optimizations, Monte Carlo, Plotting Extensibility, Framework for Non-self consistent modeling, and Bug Fixes#63
Merged
Chang-Scott merged 22 commits intomainfrom Jan 3, 2026
Merged
Conversation
- Added NON_SELF_CONSISTENT flag to DoSubstruct class in defineStructs.py - New Variables Added to PlanetStruct: Ocean/Ice Properties: Planet.Ocean.kThermWater_WmK - Overrides thermal conductivity for water layers Planet.Ocean.Eact_kJmol - Array for activation energy for diffusion of ice phases Ih-VI Planet.Ocean.kThermIce_WmK - Dict for constant thermal conductivity for each ice phase Silicate Properties: Planet.Sil.etaRock_Pas - Array for rock viscosities (overrides Constants.etaRock_Pas) Core Properties: Planet.Core.etaFeSolid_Pas - Viscosity of solid iron Planet.Core.etaFeLiquid_Pas - Viscosity of liquid iron Ice Melting Point Viscosities: Planet.etaMelt_Pas - Viscosity of ice I at Tb_K Planet.etaMeltIII_Pas - Same for ice III underplate layers Planet.etaMeltV_Pas - Same for ice V underplate layers
- Added support for generating non self consistent models in PP. Instead of specifying pressure, temperatures, PP takes thickness inputs for each layer. See NonSelfConsistsentInputs.md for inputs and PPTest29 for an example. - General flag is Planet.Do.NON_SELF_CONSISTENT to create a non self consistent planet. - PP does not use thermodyamic EOS in thsi case, but rather inputs that user specifies. - Maintains consistency with PP structure to still use PyALMA and Moonmag calculations as well as figure generations. - Convection model for non self consistent models follows Petricca 2023, PyALMA paper. - WIP Monte Carlo approach that will use these non self consistnet models. - A more detailed user guide will be provided after Monte Carlo implementaiton has been carried out.
- Introduced a new module for Monte Carlo parameter sampling, allowing exploration of parameter space and uncertainty assessment. - Added configuration settings specific to Monte Carlo calculations, including parameter ranges, distributions, and output options. - Updated existing files to integrate Monte Carlo parameters into the main PlanetProfile structure, ensuring compatibility with current modeling approaches. - Enhanced logging and error handling for scenarios involving broken models during Monte Carlo runs. - Implemented functions for saving and plotting Monte Carlo results, including distributions and correlations. - Updated setup functions to accommodate new Monte Carlo data and figure paths.
…pdates. Added a PrecomputeEOS() function that precomputes every EOS that will be used in PlanetProfile run. A majority of PlanetProfile runtime is slowed down by computing EOS for each planet (ocean EOS, ice EOS, mantle/iron core EOS). While PP tries to save these EOS to a global EOSlist, this EOSlist is not shared among workers in parallel processing and oftentimes is not robust for the ice EOS generation. Thus, we now precompute all the EOSs for large scale explorations (Exploreogram, Inductogram, Monte Carlo) beforehand and save to EOSlist before it is shared to the individual workers. This involves generating P-T grids for the ocean and ice EOS that are based on input parameters (deltaP, deltaT, etc.) - see PrecomputeEOS() for more details. This has dramatically reduced runtime of large scale explorations to a few seconds per model run, depending on properties being calculated (i.e. tidal Love numbers, magnetic induction icnrease runtime). One note is that the EOSlist object becomes very large (scale of GBs), and this is stored in RAM, which may cause crashes if users' machines have limited RAM. This is especially pertinent to Windows users, where the EOSlist is copied for each worker in parallel processing due to the way Windows handles multiprocessing, so it is something to be aware of. We also add updates to reaktoro plotting to plot the volume of solid species, rather than mol/kg. We also introduce a new monte plot to show scatter by ocean composition coloring. This needs to be improved in future.
…tes, and new thermodynamic plots. Adds some bug fixes when pre-generating all EOS and allows for parallel processing to pre-compute CustomSolution EOS grids, which is the most time intensive part of the EOS generation. Adds the TimingStruct and timing logger, that allows the code to be more comprehensively timed. This is a WIP, but is meant to improve debugging for computational effiency. Sets default of pyalma caclulations to complex and saves the amplitude and phase delay calculations, which can now be plotted in the ExploreOgram exploration plots. Adds two new thermodynamic plots to PlanetProfile individual runs - PlotMeltingCurves and PlotHydrosphereThermodynamics (toggled by Params.PLOT_MELTING_CURVES and Params.PLOT_HYDROSPHERE_THERMODYNAMICS respectively). The former plots the melting curve for the ocean EOS used, and the second plots the profile of thermodynamic properties used (density, alpha, Cp). Also some changes to the reaction calculation in Reaktoro, where we now include the reaction in the speciation calculation to both improve runtime and also allow equilibrium/disequilibrium amounts of reaction substructs to show in hydrospecies plots. Namely, we no longer use RktAffinity(), so should remove that in the future.
Update to improve the memory overhead with EOS - this update reduces the average melt EOS from .8GB to 20MB. The majority of the overhead comes from the melt EOS phase lookup table, which requires small temperature and phase steps specified by Planet.PfreezeRes_MPa and Planet.TfreezeRes_K to generate a high-res lookup table for the phase. Before, we stored this grid in scipy's nearestgridinterpolator which stores the input grid and values by upcasting to np.float64_, which take up a high amount of memroy space for the grid, espeically considering that we can store the phase as integers. Thus, we introduce our own nearestinterpolatorgrid that allows us to keep our phase data as ints.This has drastically reduced memory overhead.
…ve viscosity when propagating viscosity profile
Overhaul of large scale explorations (Explroeogram, Inductogram, MonteCarlo) to use a unified results scheme, where each datatype stores data in basesusbtruct and magnetic data in inductionsubstruct. This now allows exploreograms, montecarlos to save induction data and use the magplots for idnuctograms, if applicable. Thus, the large scale model runs are now more extensible and compatible with one another. To make these data structures compatible, we have overhauled the plotting functions of the large scale explorations and reorganized the functions into their own files (ExplorationPlots, MonteCarloPlots, MagPlots (already there)). Also added functions that are constantly re-used for plotting in the EssentialHelpers.py file which prevents code redundancy. Still need to improve the description for the functions. These new functions still need to be tested extensively and ensure that nothing was changed from the previous versions of PlanetProfile. Update also includes bug fixes and updates to BuildTest to test the new plotting functions.
…ice and water from seafreeze. Previously, MgSO4 used its own margules implementation to calculate phase diagram - this process was both slow and inaccurate based on old phase data, using a static lookup table. We now take advantage of the seafreeze package to construct the phase diagram dynamically based on user input P-T steps. We take the chemical potentials of the ice phases, as well as use the seafreeze water1 chemical potential added to the margules MgSO4 addition to compare and find transitions where mu_ice = mu_water. This implementation is similar to how CustomSolution works, instead using the Margules calculation for the MgSO4 mu addition. We change the default phase EOS type to calc so we now calculate the phase diagram rather than using the static lookup tables. To still use them, use 'lookup' in the phaseType planet setting.
…. We add a preliminary functionality that allows user to constrain a model space to those that best fit a 'true' model of Europa. The function proceeds as : 1) Generate a TrueModel using base PlanetProfile functionality and save to Params.Inversion object 2) Run exploreogram over a 2d grid of parameters. 3) Fit the model space that fall within uncertainty bounds of true observational data. This functionality allows user to account for uncertainty in paramaters in Inversion file. This setup is currently not integrated into PlanetProfile main function, but must be called separately. The next update will improve documentation annd integrate this functionality.
This update allows uers to set different 'folders' that hold different config sets so user can decide which configs to use, depending on their run. For example, user can have a folder of configs they use for single planet runs and a sepearte fodler of configs they use for exploreograms and relevant plotting options. Configs are now stored in /UserConfigs folder. #TODO Need to implement ability for user toe asily choose which config fodler they want to use. For now, the defualt is just the configs populated in /UserConfigs
1) Improves figure file saving by preventing overwriting by creating different figure files object for each exploreogram. 2) Overhauls comparison of exploration results. Now, we add a new function that creates an exploration comparison object for each pairwise combination of exploration results. Comparisons are only made between explroeograms that have the same input x and y variables and dimensions. If so, then we get the difference of the possible z variables that can then be plotted. User has option to do absolute difference or relative difference (FigMisc.EXPLOREOGRAM_COMPARISON_DIFFERENCE_TYPE). 3) Changes some variable name to improve matching with variable in PlanetStruct. 4) Adds the ability to override figure savefile base name (Params.OverrideFigureBase)
…t is still called. Also adds a specific hydrospehre thermdoynamics file name.
…d speed of HydroEOS, which remains the bottleneck of exploration runs, especially for high-fidelity modeling. Improvements include the following: 1) Saving of seafreeze properties in the EOSlist. We now separately generate the seafreeze props and save them to the EOSlist to prevent having to rerun the seafreeze calculations for different EOS that have the same grid. Oftentimes, we generate multiple EOS for ice phases that have different porosity/other settings, but the basic thermodynamics remain the same. Before, we would still have to redo the calculations - now, we save the seafreeze properties separately so that the calculations do not have to be rerun. This significantly improves runtime and reduces RAM overload before garbage collection. 2) Improvement of MgSO4 and reaktoroProps phase diagram lookup. This was a huge RAM overload issue, where high fidelity phase lookup grids required 10^3x10^3x6 grids of chemical potentials stored at float64, which would consume GBs in the RAM, often leading to blackscreens on personal laptops. Instead, we generate the seafreeze ice chemical potential grid once, determine the most stable phase and associated chemical potential, and only save these values (part of improvement #1 above). We then compare this 2d grid to the chemical potential of the aqueous solution. This greatly improves runtime since we no longer have to look through a 10^3x10^3x7 grid but rather just a 10^3x10^3 2d grid and more importantly reduces the overload on the memory space, thus enabling users to generate high fidelity lookup grids (i.e. Pphasestep of 0.01 MPa and Tphasestep of 0.005K) without crashing. 3) For OceanEOS: Implement a new toggle to reduce the fidelity of the thermodynamic properties EOS while maintaining the input fidelity of the phase properties (set by Planet.Ocean.deltaP and Planet.Ocean.deltaT). For high-fidelity modeling, it is important the deltaP and deltaT are set low enough to ensure accurate moment of inertia calculations, however too high fidelity led to crashes due to memory overload and slow runtime due to the high number of thermodynamic calculations required to create the EOS. Importantly, the thermdoynamic properties do not need to have a high fidelity relative to the phase grid as we interpolate thermodynamic properties across the grid. Now, we introduce Planet.Ocean.propsStepReductionFactor which sets the factor to reduce the reslution of the grid used to generate the thermdoynamic proeprties while still maintaining the fidleity of the phase grid. For example, if propsStepReductionFactor=10 deltaP=0.1 MPa and deltaT=0.1 K, this is the fidelity of the phase grid for the ocean, while the thermodynamcis will be generated at propsdeltaP=1MPa and propsdeltaT=1MPa.. Option should be set for high fidelity modeling. 4) Added Tvisc and eta variables that can be set by user to set viscosities of inner layers and optional switching of viscosities at a Tvisc value. 5) Improvement to precomputingEOS function for large exploration to speed up runtime.
… bug fixes to plotting
…mages with FigMisc.TRANSPARENT. Also adds a cetranlized smoothing grid to smooth the explorationplots
Multitude of bug fixes targeted at getting new capabilities of PPv3.1 working without errors. Battery of test runs (BuildTest.py) are now working, with these bug fixes addressing errors that were raised when running the tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Optimizations:
Plotting Exensibility:
Monte Carlo:
*Note that monte carlo has not been extensively tested and is a WIP update.
Non-self consistent modeling
*Note that monte carlo has not been extensively tested and is a WIP update.
MgSO4-Seafreeze Coupling
Bug fixes