Skip to content

Commit

Permalink
Merge branch 'rc-1.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoiz committed Feb 9, 2021
2 parents 6dc2353 + ba6fe7a commit e4da4c6
Show file tree
Hide file tree
Showing 26 changed files with 1,027 additions and 748 deletions.
2 changes: 1 addition & 1 deletion .version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "release version",
"message": "1.2",
"message": "1.2.1",
"color": "green"
}
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@

# General information about the project.
project = 'SHARPy'
copyright = '2020, LoCA Lab ICL'
copyright = '2021, LoCA Lab ICL'
author = 'Aeroelastics Lab, Imperial College London'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.2'
version = '1.2.1'
# The full version, including alpha/beta/rc tags.
release = '1.2'
release = '1.2.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
1,372 changes: 692 additions & 680 deletions docs/source/content/example_notebooks/wind_turbine.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/source/includes/generators/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Dynamic Control Surface generators enable the user to prescribe a certain contro
./gridbox/index
./gustvelocityfield/index
./helicoidalwake/index
./modifystructure/index
./shearvelocityfield/index
./steadyvelocityfield/index
./straightwake/index
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ChangeLumpedMass
----------------

.. autoclass:: sharpy.generators.modifystructure.ChangeLumpedMass
:members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ChangedVariable
---------------

.. autoclass:: sharpy.generators.modifystructure.ChangedVariable
:members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LumpedMassControl
-----------------

.. autoclass:: sharpy.generators.modifystructure.LumpedMassControl
:members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ModifyStructure
---------------

.. autoclass:: sharpy.generators.modifystructure.ModifyStructure
:members:
7 changes: 7 additions & 0 deletions docs/source/includes/generators/modifystructure/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. toctree::
:glob:

./ChangeLumpedMass
./ChangedVariable
./LumpedMassControl
./ModifyStructure
7 changes: 0 additions & 7 deletions docs/source/includes/postprocs/StabilityDerivatives.rst

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RigidDynamicCoupledStep
-----------------------



.. autoclass:: sharpy.solvers.rigiddynamiccoupledstep.RigidDynamicCoupledStep
:members:
1 change: 1 addition & 0 deletions docs/source/includes/solvers/structural_solvers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ Structural Solvers
./structural/NonLinearDynamicPrescribedStep
./structural/NonLinearStatic
./structural/NonLinearStaticMultibody
./structural/RigidDynamicCoupledStep
./structural/RigidDynamicPrescribedStep
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
get_transformation_matrix
-------------------------

.. automodule:: sharpy.utils.algebra.get_transformation_matrix
1 change: 1 addition & 0 deletions docs/source/includes/utils/algebra/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Note:
./deuler_dt_NED
./euler2quat
./euler2rot
./get_transformation_matrix
./get_triad
./mat2quat
./multiply_matrices
Expand Down
2 changes: 1 addition & 1 deletion lib/UVLM
Submodule UVLM updated 0 files
2 changes: 1 addition & 1 deletion lib/xbeam
116 changes: 72 additions & 44 deletions sharpy/postproc/savedata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import h5py
import copy
import sharpy
import sharpy.utils.cout_utils as cout
from sharpy.utils.solver_interface import solver, BaseSolver
Expand Down Expand Up @@ -58,6 +59,10 @@ class SaveData(BaseSolver):
settings_description['save_linear_uvlm'] = 'Save linear UVLM state space system. Use with caution when dealing with ' \
'large systems.'

settings_types['save_rom'] = 'bool'
settings_default['save_rom'] = False
settings_description['save_rom'] = 'Saves the ROM matrices and the reduced order model'

settings_types['skip_attr'] = 'list(str)'
settings_default['skip_attr'] = ['fortran',
'airfoils',
Expand Down Expand Up @@ -108,31 +113,33 @@ def __init__(self):
self.ClassesToSave = (sharpy.presharpy.presharpy.PreSharpy,)

def initialise(self, data, custom_settings=None, caller=None):

# Add these anyway - therefore if you add your own skip_attr you don't have to retype all of these
self.settings_default['skip_attr'].append(['fortran',
'airfoils',
'airfoil_db',
'settings_types',
'ct_dynamic_forces_list',
'ct_forces_list',
'ct_gamma_dot_list',
'ct_gamma_list',
'ct_gamma_star_list',
'ct_normals_list',
'ct_u_ext_list',
'ct_u_ext_star_list',
'ct_zeta_dot_list',
'ct_zeta_list',
'ct_zeta_star_list',
'dynamic_input'])
self.data = data
if custom_settings is None:
self.settings = data.settings[self.solver_id]
else:
self.settings = custom_settings

settings.to_custom_types(self.settings,
self.settings_types, self.settings_default, options=self.settings_options)

# Add these anyway - therefore if you add your own skip_attr you don't have to retype all of these
self.settings['skip_attr'].extend(['fortran',
'airfoils',
'airfoil_db',
'settings_types',
'ct_dynamic_forces_list',
'ct_forces_list',
'ct_gamma_dot_list',
'ct_gamma_list',
'ct_gamma_star_list',
'ct_normals_list',
'ct_u_ext_list',
'ct_u_ext_star_list',
'ct_zeta_dot_list',
'ct_zeta_list',
'ct_zeta_star_list',
'dynamic_input'])

self.ts_max = self.data.ts + 1

# create folder for containing files if necessary
Expand Down Expand Up @@ -192,35 +199,28 @@ def run(self, online=False):
hdfile = h5py.File(self.filename, 'a')

if (online and file_exists):
if self.settings['save_aero']:
h5utils.add_as_grp(self.data.aero.timestep_info[self.data.ts],
hdfile['data']['aero']['timestep_info'],
grpname=("%05d" % self.data.ts),
ClassesToSave=(sharpy.utils.datastructures.AeroTimeStepInfo,),
SkipAttr=self.settings['skip_attr'],
compress_float=self.settings['compress_float'])
if self.settings['save_struct']:
if self.data.structure.timestep_info[self.data.ts].in_global_AFoR:
tstep = self.data.structure.timestep_info[self.data.ts]
else:
tstep = self.data.structure.timestep_info[self.data.ts].copy()
tstep.whole_structure_to_global_AFoR(self.data.structure)

h5utils.add_as_grp(tstep,
hdfile['data']['structure']['timestep_info'],
grpname=("%05d" % self.data.ts),
ClassesToSave=(sharpy.utils.datastructures.StructTimeStepInfo,),
SkipAttr=self.settings['skip_attr'],
compress_float=self.settings['compress_float'])
self.save_timestep(self.data, self.settings, self.data.ts, hdfile)
else:
skip_attr_init = copy.deepcopy(self.settings['skip_attr'])
skip_attr_init.append('timestep_info')

h5utils.add_as_grp(self.data, hdfile, grpname='data',
ClassesToSave=self.ClassesToSave, SkipAttr=skip_attr_init,
compress_float=self.settings['compress_float'])

if self.settings['save_struct']:
h5utils.add_as_grp(list(),
hdfile['data']['structure'],
grpname='timestep_info')
if self.settings['save_aero']:
h5utils.add_as_grp(list(),
hdfile['data']['aero'],
grpname='timestep_info')

for it in range(len(self.data.structure.timestep_info)):
tstep_p = self.data.structure.timestep_info[it]
if tstep_p is not None:
if not tstep_p.in_global_AFoR:
tstep_p.whole_structure_to_global_AFoR(self.data.structure)
h5utils.add_as_grp(self.data, hdfile, grpname='data',
ClassesToSave=self.ClassesToSave, SkipAttr=self.settings['skip_attr'],
compress_float=self.settings['compress_float'])
self.save_timestep(self.data, self.settings, it, hdfile)

hdfile.close()

Expand All @@ -245,7 +245,12 @@ def run(self, online=False):
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')

elif self.settings['format'] == 'mat':
from scipy.io import savemat
Expand Down Expand Up @@ -286,3 +291,26 @@ def run(self, online=False):
savemat(matfilename, savedict)

return self.data

@staticmethod
def save_timestep(data, settings, ts, hdfile):
if settings['save_aero']:
h5utils.add_as_grp(data.aero.timestep_info[ts],
hdfile['data']['aero']['timestep_info'],
grpname=("%05d" % ts),
ClassesToSave=(sharpy.utils.datastructures.AeroTimeStepInfo,),
SkipAttr=settings['skip_attr'],
compress_float=settings['compress_float'])
if settings['save_struct']:
if data.structure.timestep_info[ts].in_global_AFoR:
tstep = data.structure.timestep_info[ts]
else:
tstep = data.structure.timestep_info[data.ts].copy()
tstep.whole_structure_to_global_AFoR(data.structure)

h5utils.add_as_grp(tstep,
hdfile['data']['structure']['timestep_info'],
grpname=("%05d" % ts),
ClassesToSave=(sharpy.utils.datastructures.StructTimeStepInfo,),
SkipAttr=settings['skip_attr'],
compress_float=settings['compress_float'])
2 changes: 1 addition & 1 deletion sharpy/postproc/writevariablestime.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def initialise(self, data, custom_settings=None, caller=None):

# Initialise velocity generator
self.caller = caller
if not self.caller is None:
if ((not self.caller is None) and (not len(self.settings['vel_field_variables']) == 0)):
if self.caller.solver_classification.lower() == 'aero':
# For aerodynamic solvers
self.velocity_generator = self.caller.velocity_generator
Expand Down
25 changes: 24 additions & 1 deletion sharpy/rom/krylov.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import sharpy.utils.h5utils as h5
import sharpy.rom.utils.krylovutils as krylovutils
import warnings as warn

import h5py

@rom_interface.rom
class Krylov(rom_interface.BaseRom):
Expand Down Expand Up @@ -141,6 +141,29 @@ def initialise(self, in_settings=None):
except AttributeError:
self.nfreq = 1

def save(self, filename):
"""
Saves to an ``.h5`` file of name ``filename`` the left and right projectors and the reduced order model
Args:
filename (str): path and filename to which to save the data
"""
rom_projectors = {'right_projector': self.V,
'left_projector': self.W,
}

if '.h5' not in filename[-3:]:
filename += '.h5'

with h5py.File(filename, 'a') as outfile:
h5.add_as_grp(rom_projectors, outfile, grpname='projectors',
compress_float=True)
h5.add_as_grp(self.ssrom, outfile,
grpname='ssrom',
ClassesToSave=(libss.ss, ),
compress_float=True)

def run(self, ss):
"""
Performs Model Order Reduction employing Krylov space projection methods.
Expand Down
2 changes: 1 addition & 1 deletion sharpy/sharpy_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def main(args=None, sharpy_input_dict=None):
if sharpy_input_dict is None:
parser = argparse.ArgumentParser(prog='SHARPy', description=
"""This is the executable for Simulation of High Aspect Ratio Planes.\n
Imperial College London 2020""")
Imperial College London 2021""")
parser.add_argument('input_filename', help='path to the *.sharpy input file', type=str, default='')
parser.add_argument('-r', '--restart', help='restart the solution with a given snapshot', type=str,
default=None)
Expand Down
Loading

0 comments on commit e4da4c6

Please sign in to comment.