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

Commit

Permalink
fixed netcdf start+count error for rotphase; added rotphase to sim.ad…
Browse files Browse the repository at this point in the history
…d_body
  • Loading branch information
anand43 committed Feb 10, 2024
1 parent 99ca5f4 commit 7eae81c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/swiftest/swiftest_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1529,9 +1529,9 @@ module function swiftest_io_netcdf_read_frame_system(self, nc, param) result(ier
! rotphase may not be input by the user
status = nf90_inq_varid(nc%id, nc%rotphase_varname, nc%rotphase_varid)
if (status == NF90_NOERR) then
call netcdf_io_check( nf90_get_var(nc%id, nc%rotphase_varid, rtemp, start=[tslot]), &
call netcdf_io_check( nf90_get_var(nc%id, nc%rotphase_varid, cb%rotphase, start=[tslot]), &
"netcdf_io_read_frame_system nf90_getvar rotphase_varid" )
cb%rotphase = rtemp(1) * DEG2RAD
cb%rotphase = cb%rotphase * DEG2RAD
else
cb%rotphase = 0.0_DP
end if
Expand Down
9 changes: 7 additions & 2 deletions swiftest/init_cond.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ def vec2xr(param: Dict, **kwargs: Any):
Time at start of simulation
c_lm : (2, lmax + 1, lmax + 1) array of floats, optional
Spherical Harmonics coefficients; lmax = max spherical harmonics order
rotphase : float
rotational phase angle of the central body in degrees
Returns
-------
ds : xarray dataset
Expand All @@ -470,9 +473,9 @@ def vec2xr(param: Dict, **kwargs: Any):
sph_dims = ['sign', 'l', 'm'] # Spherical Harmonics dimensions

vector_vars = ["rh","vh","Ip","rot"]
scalar_vars = ["name","a","e","inc","capom","omega","capm","Gmass","radius","rhill","j2rp2","j4rp4"]
scalar_vars = ["name","a","e","inc","capom","omega","capm","Gmass","radius","rhill","j2rp2","j4rp4", "rotphase"]
sph_vars = ["c_lm"]
time_vars = ["rh","vh","Ip","rot","a","e","inc","capom","omega","capm","Gmass","radius","rhill","j2rp2","j4rp4"]
time_vars = ["rh","vh","Ip","rot","a","e","inc","capom","omega","capm","Gmass","radius","rhill","j2rp2","j4rp4", "rotphase"]

# Check for valid keyword arguments
kwargs = {k:kwargs[k] for k,v in kwargs.items() if v is not None}
Expand All @@ -482,6 +485,8 @@ def vec2xr(param: Dict, **kwargs: Any):
kwargs['rot'] = np.zeros((len(kwargs['Gmass']),3))
if "Ip" not in kwargs and "Gmass" in kwargs:
kwargs['Ip'] = np.full((len(kwargs['Gmass']),3), 0.4)
if "rotphase" not in kwargs:
kwargs['rotphase'] = 0.0

if "time" not in kwargs:
kwargs["time"] = np.array([0.0])
Expand Down
2 changes: 1 addition & 1 deletion swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -2601,7 +2601,7 @@ def input_to_clm_array(val, n):
Gmass = self.GU * mass

dsnew = init_cond.vec2xr(self.param, name=name, a=a, e=e, inc=inc, capom=capom, omega=omega, capm=capm, id=id,
Gmass=Gmass, radius=radius, rhill=rhill, Ip=Ip, rh=rh, vh=vh,rot=rot, j2rp2=J2, j4rp4=J4, c_lm=c_lm, time=time)
Gmass=Gmass, radius=radius, rhill=rhill, Ip=Ip, rh=rh, vh=vh,rot=rot, j2rp2=J2, j4rp4=J4, c_lm=c_lm, rotphase=rotphase, time=time)

dsnew = self._combine_and_fix_dsnew(dsnew)
self.save(verbose=False)
Expand Down

0 comments on commit 7eae81c

Please sign in to comment.