From 21e00134de64e8e64c95c41011ebfe7c36389d71 Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Sat, 30 Sep 2023 19:44:20 -0400 Subject: [PATCH 01/15] Fixed test code --- swiftest/simulation_class.py | 2 +- tests/test_swiftest.py | 121 +---------------------------------- 2 files changed, 2 insertions(+), 121 deletions(-) diff --git a/swiftest/simulation_class.py b/swiftest/simulation_class.py index d6627c325..a4a2b12b8 100644 --- a/swiftest/simulation_class.py +++ b/swiftest/simulation_class.py @@ -413,7 +413,7 @@ def run(self,dask: bool = False, **kwargs): self.set_parameter(**kwargs) # Write out the current parameter set before executing run - self.write_param() + self.save(verbose=False) if self.codename != "Swiftest": warnings.warn(f"Running an integration is not yet supported for {self.codename}",stacklevel=2) diff --git a/tests/test_swiftest.py b/tests/test_swiftest.py index e6d1cf4c9..28f4e4a83 100755 --- a/tests/test_swiftest.py +++ b/tests/test_swiftest.py @@ -259,123 +259,4 @@ def test05_gr(self): if __name__ == '__main__': - unittest.main() - if os.path.exists("simdir"): - shutil.rmtree("simdir") - - # Add the modern planets and the Sun using the JPL Horizons Database. - # Add the modern planets and the Sun using the JPL Horizons Database. - sim.add_solar_system_body(major_bodies) - - # Display the run configuration parameters. - param = sim.get_parameter(verbose=False) - sim.save() - - for f in file_list: - self.assertTrue(os.path.exists(f)) - - print("\ntest_read_ic: Test whether we can read back initial conditions files created by test_gen_ic") - sim = swiftest.Simulation(read_param=True) - # Check if all names in Dataset read in from file match the expected list of names - self.assertTrue((major_bodies == sim.init_cond['name']).all(), msg="Name mismatch in Dataset") - - # Check to see if all parameter values read in from file match the expected parameters saved when generating the file - self.assertTrue(all([v == param[k] for k,v in sim.param.items() if k in param])) - - def test02_integrators(self): - """ - Tests that Swiftest is able to integrate a collection of massive bodies and test particles with all available integrators - """ - print("\ntest_integrators: Tests that Swiftest is able to integrate a collection of massive bodies and test particles with all available integrators") - sim = swiftest.Simulation() - sim.clean() - - # Add the modern planets and the Sun using the JPL Horizons Database. - # Add the modern planets and the Sun using the JPL Horizons Database. - sim.add_solar_system_body(major_bodies) - - # Display the run configuration parameters. - param = sim.get_parameter(verbose=False) - sim.save() - - # Add 10 user-defined test particles. - ntp = 10 - - name_tp = [f"TestParticle_{i:02}" for i in range(1,ntp+1)] - a_tp = rng.uniform(0.3, 1.5, ntp) - e_tp = rng.uniform(0.0, 0.2, ntp) - inc_tp = rng.uniform(0.0, 10, ntp) - capom_tp = rng.uniform(0.0, 360.0, ntp) - omega_tp = rng.uniform(0.0, 360.0, ntp) - capm_tp = rng.uniform(0.0, 360.0, ntp) - - integrators= ["helio","whm","rmvs","symba"] - sim.add_body(name=name_tp, a=a_tp, e=e_tp, inc=inc_tp, capom=capom_tp, omega=omega_tp, capm=capm_tp) - sim.set_parameter(tstart=0.0, tstop=0.10, dt=0.01, istep_out=1, dump_cadence=0) - for i in integrators: - sim.run(integrator=i) - - - def test03_conservation(self): - """ - Tests that Swiftest conserves mass, energy, and momentum to within acceptable tolerances. - """ - print("\ntest_conservation: Tests that Swiftest conserves mass, energy, and momentum to within acceptable tolerances.") - - # Error limits - L_slope_limit = 1e-10 - E_slope_limit = 1e-8 - GM_limit = 1e-14 - - sim = swiftest.Simulation() - sim.clean() - - sim.add_solar_system_body(major_bodies) - - dt = 0.01 - nout = 1000 - tstop = 1e4 - tstep_out = tstop / nout - - sim.run(tstart=0.0, tstop=tstop, dt=dt, tstep_out=tstep_out, dump_cadence=0, compute_conservation_values=True, integrator="symba") - - def fit_func(x,slope,b): - """ - Linear function for curve fitting - """ - return slope * x + b - - # Calculate the angular momentum error - sim.data['L_tot'] = sim.data['L_orbit'] + sim.data['L_spin'] + sim.data['L_escape'] - sim.data['DL'] = sim.data['L_tot'] - sim.data['L_tot'].isel(time=0) - L_error = swiftest.tool.magnitude(sim.data,'DL') / swiftest.tool.magnitude(sim.data.isel(time=0), 'L_tot') - - # Calculate the energy error - E_error = (sim.data['TE'] - sim.data['TE'].isel(time=0)) / sim.data['TE'].isel(time=0) - - # Calculate the mass error - sim.data['GMtot'] = sim.data['Gmass'].sum(dim='name',skipna=True) + sim.data['GMescape'] - GM_error = (sim.data['GMtot'] - sim.data['GMtot'].isel(time=0)) / sim.data['GMtot'].isel(time=0) - GM_final = GM_error.isel(time=-1).values - - # Compute the slope of the error vs time fit - E_fit_result = E_error.curvefit("time",fit_func) - L_fit_result = L_error.curvefit("time",fit_func) - - E_slope = E_fit_result['curvefit_coefficients'].sel(param='slope').values - L_slope = L_fit_result['curvefit_coefficients'].sel(param='slope').values - - # Print the final errors - print("\n") - print(f"Angular momentum error slope: {L_slope:.2e}/{sim.TU_name}") - print(f"Energy error slope: {E_slope:.2e}/{sim.TU_name}") - print(f"Final Mass Error: {GM_final:.2e}") - - self.assertLess(np.abs(L_slope),L_slope_limit, msg=f"Angular Momentum Error of {L_slope:.2e}/{sim.TU_name} higher than threshold value of {L_slope_limit:.2e}/{sim.TU_name}") - self.assertLess(np.abs(E_slope),E_slope_limit, msg=f"Energy Error of {E_slope:.2e}/{sim.TU_name} higher than threshold value of {E_slope_limit:.2e}/{sim.TU_name}") - self.assertLess(np.abs(GM_final),GM_limit, msg=f"Mass Error of {GM_final:.2e} higher than threshold value of {GM_limit:.2e}") - -if __name__ == '__main__': - unittest.main() - if os.path.exists("simdir"): - shutil.rmtree("simdir") + unittest.main() \ No newline at end of file From da736f1d2ddc4e1953291c3d440bb37e92e30d57 Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 2 Oct 2023 10:40:00 -0500 Subject: [PATCH 02/15] Fixed bad merge of test script --- tests/test_swiftest.py | 68 +++++------------------------------------- 1 file changed, 8 insertions(+), 60 deletions(-) diff --git a/tests/test_swiftest.py b/tests/test_swiftest.py index 28f4e4a83..117b50788 100755 --- a/tests/test_swiftest.py +++ b/tests/test_swiftest.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ Copyright 2023 - David Minton, Carlisle Wishard, Jennifer Pouplin, Jake Elliott, & Dana Singh This file is part of Swiftest. @@ -25,69 +24,16 @@ import swiftest import unittest import os -import shutil import numpy as np from numpy.random import default_rng from astroquery.jplhorizons import Horizons import datetime - rng = default_rng(seed=123) major_bodies = ["Sun","Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"] param = {} - -class TestSwiftest(unittest.TestCase): - - def test01_gen_ic(self): - """ - Tests that Swiftest is able to successfully generate a set of initial conditions in a file without any exceptions being raised - """ - print("\ntest_gen_ic: Test whether we can generate simulation initial conditions test") - # Files that are expected to be generated: - simdir = "simdata" - file_list = [simdir, os.path.join(simdir,"param.in"), os.path.join(simdir,"init_cond.nc")] - - sim = swiftest.Simulation() - sim.clean() -#!/usr/bin/env python3 - -""" - Copyright 2023 - David Minton, Carlisle Wishard, Jennifer Pouplin, Jake Elliott, & Dana Singh - This file is part of Swiftest. - Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with Swiftest. - If not, see: https://www.gnu.org/licenses. -""" - -""" -Tests that energy and momentum errors are within tolerances in a Swiftest simulation - -Input ------- - -Output ------- -None -""" - -import swiftest -import unittest -import os -import shutil -import numpy as np -from numpy.random import default_rng - -rng = default_rng(seed=123) - -major_bodies = ["Sun","Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"] -param = {} - - class TestSwiftest(unittest.TestCase): def test01_gen_ic(self): @@ -102,7 +48,6 @@ def test01_gen_ic(self): sim = swiftest.Simulation() sim.clean() - # Add the modern planets and the Sun using the JPL Horizons Database. # Add the modern planets and the Sun using the JPL Horizons Database. sim.add_solar_system_body(major_bodies) @@ -112,7 +57,8 @@ def test01_gen_ic(self): for f in file_list: self.assertTrue(os.path.exists(f)) - + return + def test02_read_ic(self): """ @@ -125,7 +71,8 @@ def test02_read_ic(self): # Check to see if all parameter values read in from file match the expected parameters saved when generating the file self.assertTrue(all([v == param[k] for k,v in sim.param.items() if k in param])) - + return + def test03_integrators(self): """ @@ -154,7 +101,7 @@ def test03_integrators(self): sim.run(integrator=i) except: self.fail(f"Failed with integrator {i}") - + return def test04_conservation(self): """ @@ -214,7 +161,7 @@ def fit_func(x,slope,b): self.assertLess(np.abs(L_slope),L_slope_limit, msg=f"Angular Momentum Error of {L_slope:.2e}/{sim.TU_name} higher than threshold value of {L_slope_limit:.2e}/{sim.TU_name}") self.assertLess(np.abs(E_slope),E_slope_limit, msg=f"Energy Error of {E_slope:.2e}/{sim.TU_name} higher than threshold value of {E_slope_limit:.2e}/{sim.TU_name}") self.assertLess(np.abs(GM_final),GM_limit, msg=f"Mass Error of {GM_final:.2e} higher than threshold value of {GM_limit:.2e}") - + return def test05_gr(self): """ @@ -253,7 +200,8 @@ def test05_gr(self): varpi_sim = sim.data['varpi'].sel(name="Mercury") dvarpi_gr = np.diff(varpi_sim) / tstep_out dvarpi_err = np.mean(dvarpi_obs - dvarpi_gr) / dvarpi_obs_mean - self.assertLess(np.abs(dvarpi_err),dvarpi_limit,msg=f'Mercury precession rate error of of {dvarpi_err:.2e} "/{sim.TU_name} higher than threshold value of {dvarpi_limit:.2e} "/{sim.TU_name}') + print(f'{i}: Mercury precession rate error {dvarpi_err:.2e} "/{sim.TU_name}') + self.assertLess(np.abs(dvarpi_err),dvarpi_limit,msg=f'{dvarpi_err:.2e} /{sim.TU_name} is higher than threshold value of {dvarpi_limit:.2e} "/{sim.TU_name}') return From 6371a5a7814d444ef8ea5fa8be8177ef2332aaad Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 2 Oct 2023 10:40:11 -0500 Subject: [PATCH 03/15] Updated version --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 6895b410d..3bae60812 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2023.9.4 \ No newline at end of file +2023.10.0 \ No newline at end of file From 5a1157408c2f95ef96d785b8e68329d036af3adc Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 2 Oct 2023 10:40:37 -0500 Subject: [PATCH 04/15] Streamlined dependency build on MacOS --- buildscripts/build_dependencies.sh | 5 +++++ buildscripts/build_hdf5.sh | 11 ++++------- buildscripts/build_netcdf-c.sh | 4 ---- buildscripts/build_netcdf-fortran.sh | 4 ---- buildscripts/build_zlib.sh | 4 ---- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/buildscripts/build_dependencies.sh b/buildscripts/build_dependencies.sh index 719f1e8e2..32ac73ea9 100755 --- a/buildscripts/build_dependencies.sh +++ b/buildscripts/build_dependencies.sh @@ -41,6 +41,11 @@ if ! command -v ninja &> /dev/null; then fi fi +# Get the OpenMP Libraries +if [ $OS = "MacOSX" ]; then + ${SCRIPT_DIR}/get_lomp.sh ${ARGS} +fi + ${SCRIPT_DIR}/build_zlib.sh ${ARGS} ${SCRIPT_DIR}/build_hdf5.sh ${ARGS} ${SCRIPT_DIR}/build_netcdf-c.sh ${ARGS} diff --git a/buildscripts/build_hdf5.sh b/buildscripts/build_hdf5.sh index 9863f33ed..5fa0148a4 100755 --- a/buildscripts/build_hdf5.sh +++ b/buildscripts/build_hdf5.sh @@ -20,10 +20,7 @@ set -a ARGS=$@ . ${SCRIPT_DIR}/_build_getopts.sh ${ARGS} . ${SCRIPT_DIR}/set_compilers.sh -# Get the OpenMP Libraries -if [ $OS = "MacOSX" ]; then - ${SCRIPT_DIR}/get_lomp.sh ${ARGS} -fi + NPROC=$(nproc) @@ -53,6 +50,9 @@ fi if [ ! -d ${DEPENDENCY_DIR}/hdfsrc ]; then curl -s -L https://github.com/HDFGroup/hdf5/releases/download/hdf5-${HDF5_VER}/hdf5-${HDF5_VER}.tar.gz | tar xvz -C ${DEPENDENCY_DIR} + ZLIB_TGZ_NAME="zlib-${ZLIB_VER}.tar.gz" + ZLIB_TGZ_ORIGPATH="https://github.com/madler/zlib/releases/download/v${ZLIB_VER}/" + curl -L "https://github.com/HDFGroup/hdf5_plugins/archive/refs/tags/${PLUGIN_VER}.tar.gz" -o hdfsrc/hdf5_plugins.tar.gz fi printf "\n" @@ -68,9 +68,6 @@ printf "LDFLAGS: ${LDFLAGS}\n" printf "*********************************************************\n" cd ${DEPENDENCY_DIR}/hdfsrc -ZLIB_TGZ_NAME="zlib-${ZLIB_VER}.tar.gz" -ZLIB_TGZ_ORIGPATH="https://github.com/madler/zlib/releases/download/v${ZLIB_VER}/" -curl -L "https://github.com/HDFGroup/hdf5_plugins/archive/refs/tags/${PLUGIN_VER}.tar.gz" -o hdf5_plugins.tar.gz HDF5_ROOT=${PREFIX} ZLIB_ROOT=${PREFIX} diff --git a/buildscripts/build_netcdf-c.sh b/buildscripts/build_netcdf-c.sh index 6295eeda7..ee7415cbf 100755 --- a/buildscripts/build_netcdf-c.sh +++ b/buildscripts/build_netcdf-c.sh @@ -15,10 +15,6 @@ set -a ARGS=$@ . ${SCRIPT_DIR}/_build_getopts.sh ${ARGS} . ${SCRIPT_DIR}/set_compilers.sh -# Get the OpenMP Libraries -if [ $OS = "MacOSX" ]; then - ${SCRIPT_DIR}/get_lomp.sh ${ARGS} -fi NPROC=$(nproc) diff --git a/buildscripts/build_netcdf-fortran.sh b/buildscripts/build_netcdf-fortran.sh index 0457e74c7..c82f24573 100755 --- a/buildscripts/build_netcdf-fortran.sh +++ b/buildscripts/build_netcdf-fortran.sh @@ -15,10 +15,6 @@ set -a ARGS=$@ . ${SCRIPT_DIR}/_build_getopts.sh ${ARGS} . ${SCRIPT_DIR}/set_compilers.sh -# Get the OpenMP Libraries -if [ $OS = "MacOSX" ]; then - ${SCRIPT_DIR}/get_lomp.sh ${ARGS} -fi NPROC=$(nproc) diff --git a/buildscripts/build_zlib.sh b/buildscripts/build_zlib.sh index c3ef95318..337e6a839 100755 --- a/buildscripts/build_zlib.sh +++ b/buildscripts/build_zlib.sh @@ -15,10 +15,6 @@ set -a ARGS=$@ . ${SCRIPT_DIR}/_build_getopts.sh ${ARGS} . ${SCRIPT_DIR}/set_compilers.sh -# Get the OpenMP Libraries -if [ $OS = "MacOSX" ]; then - ${SCRIPT_DIR}/get_lomp.sh ${ARGS} -fi NPROC=$(nproc) From 13da5c70c68abbcea303dc91fdd1cb8fc61b90d4 Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:10:45 -0500 Subject: [PATCH 05/15] Updated version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7ef3358cb..5e63045aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "swiftest" -version = "2023.9.4" +version = "2023.9.10" authors=[ {name = 'David A. Minton', email='daminton@purdue.edu'}, {name = 'Carlisle Wishard'}, From cbb8f5a4c7815b4f1da23b8dd3d5f020a357916b Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:24:29 -0500 Subject: [PATCH 06/15] Updated version properly --- pyproject.toml | 2 +- src/globals/globals_module.f90 | 2 +- tests/test_swiftest.py | 40 +++++++++++++++++++--------------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5e63045aa..b23dee210 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "swiftest" -version = "2023.9.10" +version = "2023.10.0" authors=[ {name = 'David A. Minton', email='daminton@purdue.edu'}, {name = 'Carlisle Wishard'}, diff --git a/src/globals/globals_module.f90 b/src/globals/globals_module.f90 index 93ed3ac1e..96ad34e2a 100644 --- a/src/globals/globals_module.f90 +++ b/src/globals/globals_module.f90 @@ -48,7 +48,7 @@ module globals integer(I4B), parameter :: UPPERCASE_OFFSET = iachar('A') - iachar('a') !! ASCII character set parameter for lower to upper !! conversion - offset between upper and lower - character(*), parameter :: VERSION = "2023.9.4" !! Swiftest version + character(*), parameter :: VERSION = "2023.9.10" !! Swiftest version !> Symbolic name for integrator types character(*), parameter :: UNKNOWN_INTEGRATOR = "UKNOWN INTEGRATOR" diff --git a/tests/test_swiftest.py b/tests/test_swiftest.py index 117b50788..717142012 100755 --- a/tests/test_swiftest.py +++ b/tests/test_swiftest.py @@ -36,7 +36,7 @@ class TestSwiftest(unittest.TestCase): - def test01_gen_ic(self): + def test_gen_ic(self): """ Tests that Swiftest is able to successfully generate a set of initial conditions in a file without any exceptions being raised """ @@ -50,9 +50,6 @@ def test01_gen_ic(self): # Add the modern planets and the Sun using the JPL Horizons Database. sim.add_solar_system_body(major_bodies) - - # Display the run configuration parameters. - param = sim.get_parameter(verbose=False) sim.save() for f in file_list: @@ -60,12 +57,17 @@ def test01_gen_ic(self): return - def test02_read_ic(self): + def test_read_ic(self): """ Tests that Swiftest is able to read a set of pre-existing initial conditions files and that they contain the correct data """ print("\ntest_read_ic: Test whether we can read back initial conditions files created by test_gen_ic") - sim = swiftest.Simulation(read_param=True) + sim = swiftest.Simulation() + sim.clean() + + # Add the modern planets and the Sun using the JPL Horizons Database. + sim.add_solar_system_body(major_bodies) + sim.save() # Check if all names in Dataset read in from file match the expected list of names self.assertTrue((major_bodies == sim.init_cond['name']).all(), msg="Name mismatch in Dataset") @@ -74,23 +76,26 @@ def test02_read_ic(self): return - def test03_integrators(self): + def test_integrators(self): """ Tests that Swiftest is able to integrate a collection of massive bodies and test particles with all available integrators """ print("\ntest_integrators: Tests that Swiftest is able to integrate a collection of massive bodies and test particles with all available integrators") - sim = swiftest.Simulation(read_param=True) + sim = swiftest.Simulation() + + # Add the modern planets and the Sun using the JPL Horizons Database. + sim.add_solar_system_body(major_bodies) # Add 10 user-defined test particles. ntp = 10 - name_tp = [f"TestParticle_{i:02}" for i in range(1,ntp+1)] - a_tp = rng.uniform(0.3, 1.5, ntp) - e_tp = rng.uniform(0.0, 0.2, ntp) - inc_tp = rng.uniform(0.0, 10, ntp) - capom_tp = rng.uniform(0.0, 360.0, ntp) - omega_tp = rng.uniform(0.0, 360.0, ntp) - capm_tp = rng.uniform(0.0, 360.0, ntp) + name_tp = [f"TestParticle_{i:02}" for i in range(1,ntp+1)] + a_tp = rng.uniform(0.3, 1.5, ntp) + e_tp = rng.uniform(0.0, 0.2, ntp) + inc_tp = rng.uniform(0.0, 10, ntp) + capom_tp = rng.uniform(0.0, 360.0, ntp) + omega_tp = rng.uniform(0.0, 360.0, ntp) + capm_tp = rng.uniform(0.0, 360.0, ntp) integrators= ["whm","helio","rmvs","symba"] sim.add_body(name=name_tp, a=a_tp, e=e_tp, inc=inc_tp, capom=capom_tp, omega=omega_tp, capm=capm_tp) @@ -98,12 +103,13 @@ def test03_integrators(self): integrators= ["whm","helio","rmvs","symba"] for i in integrators: try: + sim.clean() sim.run(integrator=i) except: self.fail(f"Failed with integrator {i}") return - def test04_conservation(self): + def test_conservation(self): """ Tests that Swiftest conserves mass, energy, and momentum to within acceptable tolerances. """ @@ -163,7 +169,7 @@ def fit_func(x,slope,b): self.assertLess(np.abs(GM_final),GM_limit, msg=f"Mass Error of {GM_final:.2e} higher than threshold value of {GM_limit:.2e}") return - def test05_gr(self): + def test_gr(self): """ Tests that GR is working correctly by computing the precession of Mercury's longitude of periapsis and comparing it to values obtained from the JPL/Horizons ephemeris service From 44b4b9135a139979b022b198f08eeae884f6d959 Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:26:58 -0500 Subject: [PATCH 07/15] Fixed bad version --- src/globals/globals_module.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/globals_module.f90 b/src/globals/globals_module.f90 index 96ad34e2a..d1a078329 100644 --- a/src/globals/globals_module.f90 +++ b/src/globals/globals_module.f90 @@ -48,7 +48,7 @@ module globals integer(I4B), parameter :: UPPERCASE_OFFSET = iachar('A') - iachar('a') !! ASCII character set parameter for lower to upper !! conversion - offset between upper and lower - character(*), parameter :: VERSION = "2023.9.10" !! Swiftest version + character(*), parameter :: VERSION = "2023.10.0" !! Swiftest version !> Symbolic name for integrator types character(*), parameter :: UNKNOWN_INTEGRATOR = "UKNOWN INTEGRATOR" From f539e2677634a1e929143fadc0cb8aa746237382 Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:00:05 -0500 Subject: [PATCH 08/15] Fixed issue that was causing initial conditions from being messed up when calling .run() multiple times in the same session, which screwed up the tests. Tests work again --- swiftest/simulation_class.py | 7 ++++--- tests/test_swiftest.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/swiftest/simulation_class.py b/swiftest/simulation_class.py index a4a2b12b8..0f8bea50c 100644 --- a/swiftest/simulation_class.py +++ b/swiftest/simulation_class.py @@ -412,15 +412,16 @@ def run(self,dask: bool = False, **kwargs): if len(kwargs) > 0: self.set_parameter(**kwargs) - # Write out the current parameter set before executing run - self.save(verbose=False) - if self.codename != "Swiftest": warnings.warn(f"Running an integration is not yet supported for {self.codename}",stacklevel=2) return + # Save initial conditions if not self.restart: self.clean() + + # Write out the current parameter set before executing run + self.write_param(verbose=False,**kwargs) print(f"Running a {self.codename} {self.integrator} run from tstart={self.param['TSTART']} {self.TU_name} to tstop={self.param['TSTOP']} {self.TU_name}") diff --git a/tests/test_swiftest.py b/tests/test_swiftest.py index 717142012..63f07829c 100755 --- a/tests/test_swiftest.py +++ b/tests/test_swiftest.py @@ -85,6 +85,7 @@ def test_integrators(self): # Add the modern planets and the Sun using the JPL Horizons Database. sim.add_solar_system_body(major_bodies) + sim.clean() # Add 10 user-defined test particles. ntp = 10 @@ -103,7 +104,6 @@ def test_integrators(self): integrators= ["whm","helio","rmvs","symba"] for i in integrators: try: - sim.clean() sim.run(integrator=i) except: self.fail(f"Failed with integrator {i}") @@ -213,4 +213,5 @@ def test_gr(self): if __name__ == '__main__': + os.environ["HDF5_USE_FILE_LOCKING"]="FALSE" unittest.main() \ No newline at end of file From f40d02f862c22fbdb261d79a4d550b5b0d0da90a Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:59:38 -0500 Subject: [PATCH 09/15] Added the Python 3.12 build to the linux wheels --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b23dee210..bb22467c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -102,7 +102,6 @@ before-all = [ ] [tool.cibuildwheel.linux] -skip = "cp312-*" before-all = [ "yum install doxygen libxml2-devel libcurl-devel -y", "buildscripts/build_dependencies.sh -p /usr/local" From f55fa15f73a21025ca998944366b3eca54f76944 Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 2 Oct 2023 17:05:26 -0500 Subject: [PATCH 10/15] Updated versioning of dependency python packages and got rid of some cruft in the hdf5 build script --- buildscripts/build_hdf5.sh | 20 -------------------- pyproject.toml | 5 +++-- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/buildscripts/build_hdf5.sh b/buildscripts/build_hdf5.sh index 5fa0148a4..97106c03e 100755 --- a/buildscripts/build_hdf5.sh +++ b/buildscripts/build_hdf5.sh @@ -12,7 +12,6 @@ # If not, see: https://www.gnu.org/licenses. HDF5_VER="1_14_2" -PLUGIN_VER="1.14.0" ZLIB_VER="1.3" SCRIPT_DIR=$(realpath $(dirname $0)) @@ -48,13 +47,6 @@ if [[ (-d ${DEPENDENCY_DIR}/hdfsrc) && (-f ${DEPENDENCY_DIR}/hdfsrc/README.md) ] fi fi -if [ ! -d ${DEPENDENCY_DIR}/hdfsrc ]; then - curl -s -L https://github.com/HDFGroup/hdf5/releases/download/hdf5-${HDF5_VER}/hdf5-${HDF5_VER}.tar.gz | tar xvz -C ${DEPENDENCY_DIR} - ZLIB_TGZ_NAME="zlib-${ZLIB_VER}.tar.gz" - ZLIB_TGZ_ORIGPATH="https://github.com/madler/zlib/releases/download/v${ZLIB_VER}/" - curl -L "https://github.com/HDFGroup/hdf5_plugins/archive/refs/tags/${PLUGIN_VER}.tar.gz" -o hdfsrc/hdf5_plugins.tar.gz -fi - printf "\n" printf "*********************************************************\n" printf "* BUILDING HDF5 LIBRARY *\n" @@ -105,18 +97,6 @@ else sudo cmake --install build fi -# tar xvzf hdf5_plugins.tar.gz -# PLUGIN_SOURCE=hdf5_plugins-${PLUGIN_VER} - -# BUILD_OPTIONS="-DTGZPATH:PATH=${PLUGIN_SOURCE}/libs -DH5PL_ALLOW_EXTERNAL_SUPPORT:STRING=\"TGZ\"" -# cmake -B ${PLUGIN_SOURCE}/build -C ${PLUGIN_SOURCE}/config/cmake/cacheinit.cmake -DCMAKE_BUILD_TYPE:STRING=Release ${BUILD_OPTIONS} -G Ninja ${PLUGIN_SOURCE} -# cmake --build ${PLUGIN_SOURCE}/build -j${NPROC} --config Release -# if [ -w ${PREFIX} ]; then -# cmake --install ${PLUGIN_SOURCE}/build -# else -# sudo cmake --install ${PLUGIN_SOURCE}/build -# fi - if [ $? -ne 0 ]; then printf "hdf5 could not be compiled.\n" exit 1 diff --git a/pyproject.toml b/pyproject.toml index bb22467c7..dd6d5a0c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,8 +30,9 @@ dependencies = [ 'dask>=2022.1', 'distributed>=2022.1', 'bottleneck>=1.3.5', - 'h5netcdf>=1.0.2', - 'netcdf4>=1.6.2', + 'h5netcdf>=1.2.0', + 'h5py>=3.9.0', + 'netcdf4>=1.6.4', 'matplotlib>=3.7.1', 'astropy>=5.1', 'astroquery>=0.4.6', From 96429ee9b3ca45d9156ce0f4e59ec00ba5259ae1 Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 2 Oct 2023 17:15:28 -0500 Subject: [PATCH 11/15] Relaxing some packaging version requirements --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dd6d5a0c1..b895b752f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,9 +30,9 @@ dependencies = [ 'dask>=2022.1', 'distributed>=2022.1', 'bottleneck>=1.3.5', - 'h5netcdf>=1.2.0', - 'h5py>=3.9.0', - 'netcdf4>=1.6.4', + 'h5netcdf', + 'h5py', + 'netcdf4', 'matplotlib>=3.7.1', 'astropy>=5.1', 'astroquery>=0.4.6', From 0e86eafd9cea6da36cefcdedfc2c0a5dabdfe264 Mon Sep 17 00:00:00 2001 From: David Minton Date: Mon, 2 Oct 2023 22:12:58 -0500 Subject: [PATCH 12/15] Put back the missing download of hdf5 --- buildscripts/build_hdf5.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/buildscripts/build_hdf5.sh b/buildscripts/build_hdf5.sh index 97106c03e..3f93d036b 100755 --- a/buildscripts/build_hdf5.sh +++ b/buildscripts/build_hdf5.sh @@ -47,6 +47,9 @@ if [[ (-d ${DEPENDENCY_DIR}/hdfsrc) && (-f ${DEPENDENCY_DIR}/hdfsrc/README.md) ] fi fi +if [ ! -d ${DEPENDENCY_DIR}/hdfsrc ]; then + curl -s -L https://github.com/HDFGroup/hdf5/releases/download/hdf5-${HDF5_VER}/hdf5-${HDF5_VER}.tar.gz | tar xvz -C ${DEPENDENCY_DIR} +fi printf "\n" printf "*********************************************************\n" printf "* BUILDING HDF5 LIBRARY *\n" From d1fd2c9e1e5c9b7663336568202a261db165249a Mon Sep 17 00:00:00 2001 From: David Minton Date: Mon, 2 Oct 2023 22:53:56 -0500 Subject: [PATCH 13/15] Skip the Linux Python 3.12 wheel because it fails --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index b895b752f..7e24d42a4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -103,6 +103,7 @@ before-all = [ ] [tool.cibuildwheel.linux] +skip = "cp312-*" before-all = [ "yum install doxygen libxml2-devel libcurl-devel -y", "buildscripts/build_dependencies.sh -p /usr/local" From 40b0d0c104dd4045b2d312d05b88221d1fa6b9d0 Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Tue, 3 Oct 2023 07:43:01 -0500 Subject: [PATCH 14/15] added additional skips to the linux build because it is an override not an append --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7e24d42a4..488fbaf6b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -103,7 +103,7 @@ before-all = [ ] [tool.cibuildwheel.linux] -skip = "cp312-*" +skip = "cp312-* pp* -manylinux_i686* *-musllinux*" before-all = [ "yum install doxygen libxml2-devel libcurl-devel -y", "buildscripts/build_dependencies.sh -p /usr/local" From 47e3c88905c4fb3812850e097dd5a3c28b8ea953 Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Tue, 3 Oct 2023 10:12:32 -0500 Subject: [PATCH 15/15] Fixed bug that was preventing initial conditions file from being saved when new bodys are added in multiple add_solar_system_body calls --- swiftest/simulation_class.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/swiftest/simulation_class.py b/swiftest/simulation_class.py index 0f8bea50c..eee68f963 100644 --- a/swiftest/simulation_class.py +++ b/swiftest/simulation_class.py @@ -2177,10 +2177,8 @@ def add_solar_system_body(self, dsnew = init_cond.vec2xr(self.param,**kwargs) dsnew = self._combine_and_fix_dsnew(dsnew) - if dsnew['npl'] > 0 or dsnew['ntp'] > 0: + if dsnew['id'].max(dim='name') > 0 and dsnew['name'].size > 0: self.save(verbose=False) - - self.init_cond = self.data.copy(deep=True)