Skip to content

Commit

Permalink
Merge branch 'ImperialCollegeLondon:main' into dev_pip2
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-l-p authored Feb 8, 2024
2 parents eb32df5 + 9cdb599 commit 04294e0
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 46 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ RUN mamba init bash
RUN mamba config --set always_yes yes --set changeps1 no
RUN mamba update -q conda
RUN mamba config --set auto_activate_base false
RUN mamba env create -f /sharpy_dir/utils/environment.yml && mamba clean -afy && \

find /mamba/ -follow -type f -name '*.a' -delete && \
find /mamba/ -follow -type f -name '*.pyc' -delete && \
find /mamba/ -follow -type f -name '*.js.map' -delete
RUN mamba env create -f /sharpy_dir/utils/environment.yml
#RUN mamba clean -afy
RUN find /mamba/ -follow -type f -name '*.a' -delete
RUN find /mamba/ -follow -type f -name '*.pyc' -delete
RUN find /mamba/ -follow -type f -name '*.js.map' -delete

#COPY /utils/docker/* /root/
RUN ln -s /sharpy_dir/utils/docker/* /root/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2368,9 +2368,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Run SHARPy Simulation"
"execution_count": 22,
]
"### Run SHARPy Simulation"]
},
{
"cell_type": "code",
Expand Down
2 changes: 1 addition & 1 deletion lib/xbeam
Submodule xbeam updated 1 files
+4 −3 CMakeLists.txt
13 changes: 4 additions & 9 deletions sharpy/postproc/aeroforcescalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,8 @@ def calculate_forces(self, ts):
self.data.aero.timestep_info[ts].body_unsteady_forces[i_surf, 0:3]
) = self.calculate_forces_for_isurf_in_g_frame(force[i_surf], unsteady_force=unsteady_force[i_surf])

print(self.settings["nonlifting_body"])
if self.settings["nonlifting_body"]:
print(self.data.nonlifting_body.n_surf)
for i_surf in range(self.data.nonlifting_body.n_surf):
print(i_surf)
(
self.data.nonlifting_body.timestep_info[ts].inertial_steady_forces[i_surf, 0:3],
self.data.nonlifting_body.timestep_info[ts].body_steady_forces[i_surf, 0:3],
Expand Down Expand Up @@ -236,8 +233,8 @@ def screen_output(self, ts):
def file_output(self, filename):
# assemble forces/moments matrix
# (1 timestep) + (3+3 inertial steady+unsteady) + (3+3 body steady+unsteady)
force_matrix = np.zeros((self.ts_max, 1 + 3 + 3 + 3 + 3 + 3 + 3))
moment_matrix = np.zeros((self.ts_max, 1 + 3 + 3 + 3 + 3 + 3 + 3))
force_matrix = np.zeros((self.ts_max, 1 + 3 + 3 + 3 + 3 ))
moment_matrix = np.zeros((self.ts_max, 1 + 3 + 3 + 3 + 3))
for ts in range(self.ts_max):
aero_tstep = self.data.aero.timestep_info[ts]
i = 0
Expand Down Expand Up @@ -271,12 +268,10 @@ def file_output(self, filename):
header += 'fx_unsteady_G, fy_unsteady_G, fz_unsteady_G, '
header += 'fx_steady_a, fy_steady_a, fz_steady_a, '
header += 'fx_unsteady_a, fy_unsteady_a, fz_unsteady_a'
header += 'mx_total_G, my_total_G, mz_total_G'
header += 'mx_total_a, my_total_a, mz_total_a'

np.savetxt(self.folder + 'forces_' + filename,
force_matrix,
fmt='%i' + ', %10e'*18,
fmt='%i' + ', %10e' * (np.shape(force_matrix)[1] - 1),
delimiter=',',
header=header,
comments='#')
Expand All @@ -290,7 +285,7 @@ def file_output(self, filename):

np.savetxt(self.folder + 'moments_' + filename,
moment_matrix,
fmt='%i' + ', %10e'*18,
fmt='%i' + ', %10e' * (np.shape(moment_matrix)[1] - 1),
delimiter=',',
header=header,
comments='#')
58 changes: 32 additions & 26 deletions sharpy/postproc/savedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ def initialise(self, data, custom_settings=None, caller=None, restart=False):
self.filename_linear = self.folder + self.data.settings['SHARPy']['case'] + '.linss.h5'

# remove old file if it exists
for file_path in [self.filename, self.filename_linear]:
if os.path.isfile(file_path):
os.remove(file_path)
self.remove_file_if_exist(self.filename)

# check that there is a linear system - else return setting to false
if self.settings['save_linear'] or self.settings['save_linear_uvlm']:
Expand Down Expand Up @@ -204,6 +202,10 @@ def initialise(self, data, custom_settings=None, caller=None, restart=False):
self.ClassesToSave += (sharpy.solvers.linearassembler.Linear, sharpy.linear.src.libss.ss_block)
self.caller = caller

def remove_file_if_exist(self, filepath):
if os.path.isfile(filepath):
os.remove(filepath)

def run(self, **kwargs):

online = settings_utils.set_value_or_default(kwargs, 'online', False)
Expand Down Expand Up @@ -247,33 +249,37 @@ def run(self, **kwargs):

hdfile.close()

if self.settings['save_linear_uvlm']:
linhdffile = h5py.File(self.filename.replace('.data.h5', '.uvlmss.h5'), 'a')
h5utils.add_as_grp(self.data.linear.linear_system.uvlm.ss, linhdffile, grpname='ss',
if self.settings['save_linear_uvlm']:
linhdffile = h5py.File(self.filename.replace('.data.h5', '.uvlmss.h5'), 'a')
self.remove_file_if_exist(linhdffile)
h5utils.add_as_grp(self.data.linear.linear_system.uvlm.ss, linhdffile, grpname='ss',
ClassesToSave=self.ClassesToSave, SkipAttr=self.settings['skip_attr'],
compress_float=self.settings['compress_float'])
h5utils.add_as_grp(self.data.linear.linear_system.linearisation_vectors, linhdffile,
grpname='linearisation_vectors',
ClassesToSave=self.ClassesToSave, SkipAttr=self.settings['skip_attr'],
compress_float=self.settings['compress_float'])
linhdffile.close()

if self.settings['save_linear']:
self.remove_file_if_exist(self.filename_linear)
with h5py.File(self.filename_linear, 'a') as linfile:
h5utils.add_as_grp(self.data.linear.linear_system.linearisation_vectors, linfile,
grpname='linearisation_vectors',
ClassesToSave=self.ClassesToSave, SkipAttr=self.settings['skip_attr'],
compress_float=self.settings['compress_float'])
h5utils.add_as_grp(self.data.linear.linear_system.linearisation_vectors, linhdffile,
grpname='linearisation_vectors',
h5utils.add_as_grp(self.data.linear.ss, linfile, grpname='ss',
ClassesToSave=self.ClassesToSave, SkipAttr=self.settings['skip_attr'],
compress_float=self.settings['compress_float'])
linhdffile.close()

if self.settings['save_linear']:
with h5py.File(self.filename_linear, 'a') as linfile:
h5utils.add_as_grp(self.data.linear.linear_system.linearisation_vectors, linfile,
grpname='linearisation_vectors',
ClassesToSave=self.ClassesToSave, SkipAttr=self.settings['skip_attr'],
compress_float=self.settings['compress_float'])
h5utils.add_as_grp(self.data.linear.ss, linfile, grpname='ss',
ClassesToSave=self.ClassesToSave, SkipAttr=self.settings['skip_attr'],
compress_float=self.settings['compress_float'])

if self.settings['save_rom']:
try:
for k, rom in self.data.linear.linear_system.uvlm.rom.items():
rom.save(self.filename.replace('.data.h5', '_{:s}.rom.h5'.format(k.lower())))
except AttributeError:
cout.cout_wrap('Could not locate a reduced order model to save')

if self.settings['save_rom']:
try:
for k, rom in self.data.linear.linear_system.uvlm.rom.items():
romhdffile = self.filename.replace('.data.h5', '_{:s}.rom.h5'.format(k.lower()))
self.remove_file_if_exist(romhdffile)
rom.save(romhdffile)
except AttributeError:
cout.cout_wrap('Could not locate a reduced order model to save')

elif self.settings['format'] == 'mat':
from scipy.io import savemat
Expand Down
2 changes: 1 addition & 1 deletion sharpy/solvers/noaero.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def update_grid(self, beam):
-1,
beam_ts=-1)

def update_custom_grid(self, structure_tstep, aero_tstep):
def update_custom_grid(self, structure_tstep, aero_tstep, nl_body_tstep = None):
# called by DynamicCoupled
if self.settings['update_grid']:
self.data.aero.generate_zeta_timestep_info(structure_tstep,
Expand Down
2 changes: 1 addition & 1 deletion sharpy/structure/utils/modalutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def write_modes_vtk(data, eigenvectors, NumLambda, filename_root,
else:
num_rigid_body = 0

for mode in range(num_rigid_body, NumLambda - num_rigid_body):
for mode in range(num_rigid_body, NumLambda):
# scale eigenvector
eigvec = eigenvectors[:num_dof, mode]
fact = scale_mode(data, eigvec, rot_max_deg, perc_max)
Expand Down

0 comments on commit 04294e0

Please sign in to comment.