Repository navigation
v0.8.0
Changes
This release is extensive (this update has been in the works for almost 2.5 years!) sorry for that. I would recommend treating this as a major new update and just dive into the documentation as if it was a new package. Please reach out to joseph.p.renaud@nasa.gov to invite you to the TidalPy slack for more discussion and help.
TidalPy 0.8.0 replaces TidalPy's backend with a new C++ backend. The classic Cython, numba, and Python modules are removed, and the new modules carry their final names: Structures, RadialSolver, Tides, Material, Rheology, Viscosity, PartialMelt, Cooling, Radiogenics, Dynamics, Stellar, and Utilities. Module, class, and function names and signatures change, so code written for 0.7.X needs to be updated: see the migration guide in the documentation (https://tidalpy.readthedocs.io/en/latest/future_structure.html). Pin TidalPy<0.8 to keep using 0.7.X API.
New Features
C++ Backend
This is a high-level summary only. The full API and design notes can be found in TidalPy's documentation. The migration guide explains the rationale for this change and presents porting examples.
TidalPy.Utilitiesadds a C++ base-class hierarchy with schema-versioned TOML config files; C++ logging viaspdlog; non-dimensionalization scales (Utilities.dimensions) and unit/orbital-element conversions (Utilities.conversions); and closed-form associated Legendre tables for degrees 2..10 (plus a generic evaluator viaxsfsub module).- Physics model families (
Rheology,Viscosity,PartialMelt,Cooling,Radiogenics, the tide models ofTides, the luminosity models ofStellar, and the equation-of-state and shear-modulus laws ofMaterial), each with vectorized (ndarray) calls, config save/loads, and binary serialization support. All are built on one parameter-spec system, so every model shares the same Python surface (construction by position or keyword,make_*,parameters,get_parameter,with_parameters,get_config_dict) and refuses a config key it does not read, naming the closest one it does. - A Zener (standard linear solid) rheology,
Rheology.Zener(zener,sls), which relaxes to a set fraction of its modulus instead of to zero, as a bulk response needs. - Materials (
TidalPy.Material): aMaterialcombines a solid and a liquidPhase(each an equation-of-state law, a shear-modulus law, viscosity laws, default rheologies, and thermal constants) with melting curves that can follow the pressure, melt weakening, optional bulk mixing of the melt (which a Zener bulk rheology turns into bulk dissipation), and latent heat.Material.calc_stategives every property at a pressure and temperature. Each layer carries physics switches that default to the simplest and fastest case:use_thermal_expansion,use_melting,use_pressure_melting,use_melt_density,use_heating,use_tides, andstate. - World, layer, and system classes (
TidalPy.Structures). TOML-driven world building; oneLayerclass with its material and other models; a whole-planet EOS solve with radius-continuous profile getters, which finds each layer's solid and liquid zones as it integrates (the Love solve takes each zone as a layer), lets a layer hold its mass and move, and can integrate temperature and heat flow through each layer's cooling model (conduction, or boundary layers around an adiabat) with radiogenic, tidal, and prescribed heat sources and per-layer temperature rates; whole-planet Love numbers as a world method (shooting or propagation-matrix, tidal/loading/free boundary conditions, cached for repeated solves, with a surface-conditioning diagnostic); global (1D) tidal dissipation for every world type (rheology-driven through the radial solver, or analytic cpl/ctl/ctl_q models); 3D tidal stress/strain/heating (secular or instantaneous, full 4D grids or analytically collapsed totals/profiles, latitude bands); spin and orbital rate engines (Dynamics); stellar luminosity models (Stellar); and aSystemclass linking worlds (insolation, single- and dual-body tidal evolution with energy-balance checks). - A melting layer is split into a liquid zone only where its shear modulus vanishes (
[numerical] minimum_solid_rigiditydefault 0), so partial melt stays a melt-weakened solid that flexes and dissipates with the layers around it, andminimum_complex_rigiditydefaults to 1e-15; the tidal response and heating change continuously as a layer melts. - A rebuilt standalone radial solver (
TidalPy.RadialSolver.radial_solver), call-compatible with the 0.7.X one, using CyRK dense output so the radial solution is evaluated exactly at any radius instead of interpolated from a fixed grid. Adds dense post-solve evaluation (get_radial_solution,eos_call), per-Love-number quality factors and phase lags, and a homogeneous-sphere convenience helper (homogeneous_love_numbers). - CyRK's explicit
Tsit5,Vern7, andVern8integrators are available to the EOS and Love-number solves (integration_methodofradial_solver,solve_eos, andsolve_love_numbers, and the[eos_solver]and[radial_solver]tables). - A rebuilt tides engine (
TidalPy.Tides): unsquared eccentricity functions for degrees 2..10 at truncation levels 2, 4, 6, 8, 10, 20, and 50 (default 10), where level N keeps every product of two eccentricity functions, and so the heating, through e^N as the 0.7.X level N did, and unsquared obliquity functions (off, I^1, I^2, and fully general), used by one truncation-based Kaula potential engine in place of the 0.7.X per-scenario potential modules. Note the convention change: the 0.7.X eccentricity and inclination functions were the squared G^2/F^2, while the new ones are unsquared G/F. A tidal solve warns once per world when its eccentricity is past the range of its truncation level at its spin rate; the ranges are measured separately for near-synchronous, moderate, and fast rotators, andrecommend_eccentricity_truncationandrecommend_obliquity_truncationpick a level for a tolerance and spin rate. - 20 executed tutorial notebooks (
Demos/), validation benchmarks against published Love numbers, BurnMan, and the tidal dissipation results of Renaud et al. (2021) plus a performance-tracking harness (Benchmarks/), and end-to-end tests (Tests/Test_E2E/). - Speed, measured against TidalPy 0.7 on the same machine with the same inputs (the full table, method, and caveats are in the migration guide). Building a planet with its interior is about 220x faster now that the equation of state is integrated directly and the materials and worlds are read from memory: a fresh Io went from 1.4 seconds to about a millisecond. 3D heating maps are 2.4-5.9x faster on one thread (instantaneous and orbit-averaged) and 6.8-13x at the default thread count, a single radiogenic heating evaluation about 5x, vectorized rheology 3x, and global tidal heating 2.2-3.8x at every truncation level measured. The numba start-up cost is gone: a 0.7.X tidal heating call takes about 7 seconds during warm up and about a second at the start of every later session, while 0.8.0 takes a fraction of a millisecond. The standalone radial solver is about the same or in some cases a little slower, however it is much more accurate and stable then the previous versions.
- Every object writes the configuration it was built from (
get_config_dict, with model tables keyed exactly as themake_*factories accept them) and rebuilds from it (build_worldandbuild_systemtake a name, a path, or a config dictionary, with optional nestedoverrides;build_layer_from_dictrebuilds a layer), andsave_to_tomlwrites the current state of a world or system as a buildable file under a version header. A world file may pin its own[eos_solver]and[radial_solver]settings so that it reproduces a run with the configuration file alone, and the configuration loader warns about keys it does not read. - Conveniences on the world and system classes:
calc_tidesand the 3D calls take their orbital state from the world'sSystemwhen it is left out, andcalc_tidesreturns its results. - Native radial-solver input builders (
TidalPy.RadialSolver.build_inputs):build_rs_input_homogeneous_layersandbuild_rs_input_from_dataassemble the density and complex-modulus profiles the standalone solver takes from layer descriptions andRheologymodels, in C++. - Bundled worlds, rebuilt on the new schema from the 0.7.X WorldPack: the terrestrial bodies
io,europa,luna,mercury,earth_simple,earth_thermal,earth_prem,pluto,charon,triton, andtrappist1bthroughtrappist1h; theluna_dynamic,mercury_dynamic,pluto_dynamic, andeuropa_dynamicvariants, whose liquid layer (and, for Europa, a new ocean) is solved with the dynamic equations on a pressure-dependent law; the gas giantsjupiter_simple,jupiter, andneptune; the starssolandtrappist1; and the systemssol_sstemandpluto_charon_system(Pluto and Charon as a mutually synchronous pair about the Sun). - MatPack (
TidalPy.Material.load_material,available_materials): many named materials with their literature sources (simplified materials; mantle, crust, and core materials; water ices, water, and other volatiles; giant-planet envelopes and cores). - The material, world, and system files of the data directory (and the packaged ones it has no copy of) are read into memory when TidalPy is imported (
TidalPy.database). A file edited, added, or deleted during a session is noticed by the next build. On Python 3.11 and later these files are parsed with the standard library'stomllib, about ten times faster thantoml. System.evolve(host, world)integrates a world and its tidal host in C++ with CyRK's implicit solvers (LSODA by default), evolving their shared orbit, both spins, and optionally every layer's temperature with both bodies raising tides. Capture into, passage through, and release from spin-orbit locks follow from the equations. It returns aPairedEvolutionResult, and its defaults come from the[evolution]configuration section, which a system file's own[evolution]table overrides.
Package
- One configuration file,
TidalPy_Configs.toml(packaged defaults inTidalPy.defaultc, loaded toTidalPy.config). The packaged defaults are parsed on every load and the user's file is merged over them, so a partial file works and a new default reaches an existing file.TidalPy.save_config(path)writes the effective configuration under a header naming the TidalPy, SciPy, and CyRK versions. - The C++ (spdlog) logger now writes a single
TidalPy_<timestamp>.logfile. The Pythonlogging-based logger is removed. In a Jupyter notebook, warnings print below the cell ([logging] notebook_console_level), andTidalPy.capture_logcollects log messages within awithblock. - The TidalPy data/config directories move with the minor version to
.../TidalPy/0.8.X/. Upgrading from 0.7.X starts a fresh directory; the 0.7.X configuration and world files use a different format and are not read by 0.8.0. TidalPy.get_include()lists every TidalPy directory that holds a C++ header, after CyRK's include directories.
Removed
- The classic modules:
TidalPy.structures,tides, the classicRadialSolverandMaterial,rheology,cooling,radiogenics,dynamics,stellar,orbit,Extending(BurnMan planet building), the classicWorldPackarchive,numba_scipy,utilities,output, andlogger. The migration guide maps each onto its replacement. TidalPy.toolbox(quick_tidal_dissipation,quick_dual_body_tidal_dissipation) has no replacement yet. Instead most functionality should be done using the new world and system classes (the migration guide has the worked example).- The import-time deprecation notice added in 0.7.6.
TidalPy.exceptions.TidalPyDeprecationWarningremains importable, so code that filters it keeps working. TidalPy.exceptionskeeps onlyTidalPyException,InitializationError,ArgumentException,ConfigurationException,ModelException,UnknownModelError,TidalPyIntegrationException,SolutionFailedError, andTidalPyDeprecationWarning. The C++ backend raisesValueError,RuntimeError,TypeError, andNotImplementedError.TidalPy.extensive_logging,TidalPy.extensive_checks,TidalPy.world_config_dir, and the constantsmin_spin_orbit_diffandmin_viscosity, which only the classic modules read.
Fixes
TidalPy.clear_cachedeleted every__pycache__directory in the Python environment'ssite-packages, not only TidalPy's. It now clears only the installed TidalPy package.TidalPy.RadialSolver: the Takeuchi and Saito (1972) starting conditions, which the shooting method uses by default, evaluated their phi and psi functions with a truncated series at every argument, to avoid a floating-point cancellation near zero (issue #41). The series drifts once the argument k^2 r^2 passes about 1 (a 2e-5 relative error at 10, meaningless past about 30), which high degrees, short forcing periods, and dynamic liquid layers reach. Arguments above 0.5 now use the exact definitions, so the functions hold about 1e-13 everywhere. At such large arguments the Takeuchi solutions are themselves nearly dependent, and the re-orthonormalization of the shooting method (below) keeps such solves accurate.TidalPy.RadialSolver: the compressible-solid starting conditions (Takeuchi and Kamata) lost precision in (beta^2 k^2 - omega^2) / gamma when the forcing frequency squared is far above gamma = 4 pi G rho / 3, which is at periods shorter than about an hour (a 1e-10 relative error at 0.1 rad/s, 1e-6 at 1 rad/s). It is now computed without the cancellation. Together with the fix above, Love numbers at tidal periods are unchanged (the bundled worlds move by less than 1e-10 at tight tolerances), while at a one-minute period Takeuchi Love numbers that were off by up to 2.5% now match the Kamata starting conditions to 1e-10 for layered bodies and 7e-5 in the worst homogeneous case.TidalPy.RadialSolvernow allows rigid translation of the body such that every degree-1 surface condition for loading are properly calculated (issues #53 and #99). The 0.7.X solver returned h', l', and k' carrying an arbitrary translation set by integration error, which changed with the forcing period and the tolerance, by order one at periods longer than about a month. A degree-1 loading solve now fixes the frame of the body's own center of mass (CE, k' = 0) in its surface solve (Guo et al. 2004; Martens 2016) and reports the Love numbers and the radial functions there, or in the CM, CF, CL, or CH frame of Blewitt (2003) through the newdegree1_frameargument and[radial_solver]key. A body whose layers are all static now solves, and so does one with a liquid surface layer (a static liquid surface has no l', so the CF and CL frames are refused there). A 0.7.X result can mimic the new CE frame by performing (h' - k') and (l' - k').TidalPy.RadialSolver: dynamic liquid layers lost accuracy at long forcing periods and failed at longer ones, as their independent solutions became nearly dependent by the surface, and 0.7.X only printed a warning below a fixed 2.5e-5 rad/s. The shooting method now integrates a dynamic liquid in the pressure variable P = y2 - rho g y1 + rho y5, and a layer's independent solutions as one system that is re-orthonormalized where they become nearly dependent ([numerical] minimum_solution_independence). The Love numbers of neutral dynamic liquids and near-static solids hold the requested tolerance down to the 1e-16 rad/s minimum frequency, and the warning is removed.steps_takengives each layer's step count, shared by its solutions, andorthonormalizationscounts each layer's restarts.- The
offcooling model reported a boundary-layer thickness of half the layer, a value with no meaning for a layer that does not cool; it now reports NaN. TidalPy.RadialSolver.radial_solvernever attached its extension to TidalPy's logger, so the C++ warnings of the world it builds from a supplied profile (its EOS and Love solves) were dropped. They now reach the log.
Utilities
- Implemented a new constant/parameter backend that can be accessed in C++ but modified in Python/Cython.
- Refactored
constants.d_DBL_MANT_DIGtoconstants.d_DBL_MANT_DIGITSfor readability. - Refactored
constants.d_PI_DBLtoconstants.d_PI. - Refactored
constants.d_NAN_DBLtoconstants.d_NAN.
- Refactored
Tests
- Test suites for every module. The tests that compared the new implementations against the 0.7.X ones now compare against frozen reference data generated from the 0.7.X code (
frozen/*.npzbeside each test, andTests/Test_RadialSolver/test_dense_benchmark/). Tests/Test_Tides/Test_Classes/test_collapse_vs_legacy_01.pypins the global collapse (cpl) against frozen results from the 0.7.Xtoolbox.quick_tidesfor synchronous and non-synchronous cases at degrees 2 and 3.- The 0.7.X test suites (
Test_Oldand the classic halves of the module suites) are removed with the modules they tested. - The suite runs against a fresh temporary data directory (
Tests/conftest.pysetsTIDALPY_DATA_DIRbefore TidalPy is imported), so the user'sTidalPy_Configs.tomlno longer changes test results and nothing is written to the user's data directory. - CI installs
nbformat,nbclient, andipykernel, so the demo and benchmark notebooks run there; the notebook test skips demo S02 by name, with its reason, so a plainpytest Tests/passes.
Documentation
- A documentation page for every module, the tutorial notebooks, and the benchmarks. The migration guide (
future_structure.md, kept at its 0.7.6 address) maps the 0.7.X modules, classes, and functions onto their replacements with verified porting examples. The 0.7.X module pages are removed.
Dependencies
- Removed:
numba,dill,pathos,astropy, andastroquery(and thenumba_scipyentry point), which only the classic modules used.psutilmoves to thedevextra (used for performance-benchmark). Theburnmanandjuliaextras are removed; BurnMan is only needed to run theBenchmarks/EOS/EOS_vs_BurnMan.ipynbcomparison. - Added:
tqdm(progress bars for long calculations). cyrk>=0.20.0.System.evolvedrives CyRK's implicit solvers (BDF, LSODA, Radau) from C++ with events and a user Jacobian, and relies on the fix to their dense LU solve in CyRK 0.20.0, which also brings the explicitTsit5,Vern7, andVern8methods.pandas>=1.5was added to thedevrequirements. It is used by the performance-benchmark views inBenchmarks/Performance.
spdlog Submodule
- Adds spdlog (header-only C++ logging) as a submodule at
Dependencies/spdlog.
XSF Submodule
- Adds the xsf package as a submodule. The spherical Bessel function headers are used in various
RadialSolvercalculations.
Eigen Submodule
- Adds the Eigen package as a submodule. It provides much of LAPACK's functionality used in the radial solver's propagation-matrix method.
GitHub Tracked Changes
- Cythonizing eccen inclin function by @jrenaud90 in #104
- Fix license url by @jrenaud90 in #106
- Merge Updates by @jrenaud90 in #107
- Rsx fix by @jrenaud90 in #111
- New class structure by @jrenaud90 in #112
- New structure classes by @jrenaud90 in #113
- New Physics Models by @jrenaud90 in #114
- Merges C++ structures back into ver 0.8.0 by @jrenaud90 in #118
- Thermal eos by @jrenaud90 in #120
- Ver 0.8.0 by @jrenaud90 in #121
Full Changelog: v0.7.6...v0.8.0