Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Fixed some bugs involved in trying to read in simulation data without…
Browse files Browse the repository at this point in the history
… radius
  • Loading branch information
daminton committed Jan 15, 2023
1 parent ebe4985 commit 107fc88
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
10 changes: 7 additions & 3 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import subprocess
import shlex
import warnings
import sys
from tqdm.auto import tqdm
from typing import (
Literal,
Expand Down Expand Up @@ -453,9 +454,11 @@ def _type_scrub(output_data):
if p.returncode != 0:
for line in res[1]:
print(line, end='')
warnings.warn("Failure in swiftest_driver", stacklevel=2)
warnings.warn("Failure in swiftest_driver", stacklevel=2)
sys.exit()
except:
warnings.warn(f"Error executing main swiftest_driver program", stacklevel=2)
sys.exit()

pbar.close()
return
Expand Down Expand Up @@ -918,8 +921,9 @@ def set_integrator(self,
warnings.warn(f"Cannot find the Swiftest driver in {str(self.binary_path)}",stacklevel=2)
self.driver_executable = None
else:
shutil.copy(self.binary_source, self.driver_executable)
self.driver_executable.resolve()
if self.binary_path.exists():
shutil.copy(self.binary_source, self.driver_executable)
self.driver_executable.resolve()
else:
self.binary_path = "NOT IMPLEMENTED FOR THIS CODE"
self.driver_executable = None
Expand Down
14 changes: 8 additions & 6 deletions src/swiftest/swiftest_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -800,12 +800,14 @@ module subroutine swiftest_io_netcdf_initialize_output(self, param)
end do

! Set special fill mode for discard time so that we can make use of it for non-discarded bodies.
select case (vartype)
case(NF90_FLOAT)
call netcdf_io_check( nf90_def_var_fill(nc%id, nc%discard_time_varid, NO_FILL, huge(1.0_SP)), "netcdf_io_initialize_output nf90_def_var_fill discard_time NF90_FLOAT" )
case(NF90_DOUBLE)
call netcdf_io_check( nf90_def_var_fill(nc%id, nc%discard_time_varid, NO_FILL, huge(1.0_DP)), "netcdf_io_initialize_output nf90_def_var_fill discard_time NF90_DOUBLE" )
end select
if (param%lclose) then
select case (vartype)
case(NF90_FLOAT)
call netcdf_io_check( nf90_def_var_fill(nc%id, nc%discard_time_varid, NO_FILL, huge(1.0_SP)), "netcdf_io_initialize_output nf90_def_var_fill discard_time NF90_FLOAT" )
case(NF90_DOUBLE)
call netcdf_io_check( nf90_def_var_fill(nc%id, nc%discard_time_varid, NO_FILL, huge(1.0_DP)), "netcdf_io_initialize_output nf90_def_var_fill discard_time NF90_DOUBLE" )
end select
end if

! Take the file out of define mode
call netcdf_io_check( nf90_enddef(nc%id), "netcdf_io_initialize_output nf90_enddef" )
Expand Down
6 changes: 5 additions & 1 deletion src/swiftest/swiftest_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,11 @@ module subroutine swiftest_util_get_energy_and_momentum_system(self, param)
nbody_system%L_orbit(j) = Lcborbit(j) + sum(Lplorbit(j,1:npl), pl%lmask(1:npl))
end do

nbody_system%be = sum(-3*pl%Gmass(1:npl)*pl%mass(1:npl)/(5*pl%radius(1:npl)), pl%lmask(1:npl))
if ((param%lclose)) then
nbody_system%be = sum(-3*pl%Gmass(1:npl)*pl%mass(1:npl)/(5*pl%radius(1:npl)), pl%lmask(1:npl))
else
nbody_system%be = 0.0_DP
end if
nbody_system%te = nbody_system%ke_orbit + nbody_system%ke_spin + nbody_system%pe + nbody_system%be
nbody_system%L_total(:) = nbody_system%L_orbit(:) + nbody_system%L_spin(:)
end associate
Expand Down

0 comments on commit 107fc88

Please sign in to comment.