Skip to content

Commit

Permalink
Merge pull request #222 from ImperialCollegeLondon/dev_env
Browse files Browse the repository at this point in the history
updating from python 3.7 to 3.10
  • Loading branch information
ACea15 committed Nov 13, 2022
2 parents ef973b1 + f359043 commit 3e5efc7
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 23 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/sharpy_tests.yaml
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]
python-version: [3.10.8]

steps:
- uses: actions/checkout@v2
Expand All @@ -34,24 +34,26 @@ jobs:
- name: Setup conda
uses: s-weigand/setup-conda@v1
with:
python-version: 3.7
python-version: 3.9
- name: Pre-Install dependencies
run: |
gfortran --version
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
# wget https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.sh -O miniconda.sh;
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
hash -r
conda config --set always_yes yes --set changeps1 no
# conda config --append channels conda-forge
conda update --name base conda
conda list --name base conda
conda init bash
hash -r
export QT_QPA_PLATFORM='offscreen'
sudo apt install libeigen3-dev
conda env create -f utils/environment_minimal.yml
conda env create -f utils/environment_new.yml
conda init bash
source activate sharpy_minimal
source activate sharpy
git submodule init
git submodule update
git fetch --tags -f
Expand All @@ -60,7 +62,8 @@ jobs:
pip install .
pip install coverage
coverage run -m unittest discover
coverage json
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
verbose: true
4 changes: 2 additions & 2 deletions sharpy/generators/turbvelocityfield.py
Expand Up @@ -113,9 +113,9 @@ def initialise(self, in_dict, restart=False):

_, self.extension = os.path.splitext(self.settings['turbulent_field'])

if self.extension is '.h5':
if self.extension == '.h5':
self.read_btl(self.settings['turbulent_field'])
if self.extension in '.xdmf':
if self.extension == '.xdmf':
self.read_xdmf(self.settings['turbulent_field'])

if 'z' in self.settings['periodicity']:
Expand Down
6 changes: 3 additions & 3 deletions sharpy/linear/assembler/lineargustassembler.py
Expand Up @@ -5,7 +5,7 @@
import sharpy.utils.settings as settings
import sharpy.utils.cout_utils as cout
from abc import ABCMeta, abstractmethod

from scipy import signal
dict_of_linear_gusts = {}


Expand Down Expand Up @@ -504,9 +504,9 @@ def campbell(sigma_w, length_scale, velocity, dt=None):
den_tf = np.array([935/216, 561/12, 102, 60])
if dt is not None:
num_tf, den_tf, dt = scsig.cont2discrete((num_tf, den_tf), dt, method='bilinear')
camp_tf = scsig.ltisys.TransferFunctionDiscrete(num_tf, den_tf, dt=dt)
camp_tf = signal.TransferFunction(num_tf, den_tf, dt=dt)
else:
camp_tf = scsig.ltisys.TransferFunction(num_tf, den_tf)
camp_tf = signal.TransferFunction(num_tf, den_tf)
ss_turb = libss.StateSpace.from_scipy(camp_tf.to_ss())

ss_turb.initialise_variables(({'name': 'noise_in', 'size': 1}), var_type='in')
Expand Down
4 changes: 2 additions & 2 deletions sharpy/linear/src/libsparse.py
Expand Up @@ -35,8 +35,8 @@
import warnings
import numpy as np
import scipy.sparse as sparse
from scipy.sparse._sputils import upcast_char
import scipy.sparse.linalg as spalg
import scipy.sparse.sputils as sputils

# --------------------------------------------------------------------- Classes

Expand Down Expand Up @@ -65,7 +65,7 @@ def todense(self):
def _add_dense(self, other):
if other.shape != self.shape:
raise ValueError('Incompatible shapes.')
dtype = sputils.upcast_char(self.dtype.char, other.dtype.char)
dtype = upcast_char(self.dtype.char, other.dtype.char)
order = self._swap('CF')[0]
result = np.array(other, dtype=dtype, order=order, copy=True)
M, N = self._swap(self.shape)
Expand Down
4 changes: 2 additions & 2 deletions sharpy/linear/src/libss.py
Expand Up @@ -1841,12 +1841,12 @@ def Hnorm_from_freq_resp(gv, method):
Warning: only use for SISO systems! For MIMO definitions are different
"""

if method is 'H2':
if method == 'H2':
Nk = len(gv)
gvsq = gv * gv.conj()
Gnorm = np.sqrt(np.trapz(gvsq / (Nk - 1.)))

elif method is 'Hinf':
elif method == 'Hinf':
Gnorm = np.linalg.norm(gv, np.inf)

if np.abs(Gnorm.imag / Gnorm.real) > 1e-16:
Expand Down
2 changes: 1 addition & 1 deletion sharpy/linear/src/lingebm.py
Expand Up @@ -1337,7 +1337,7 @@ def update_matrices_time_scale(self, time_ref):
def cont2disc(self, dt=None):
"""Convert continuous-time SS model into """

assert self.discr_method is not 'newmark', \
assert self.discr_method != 'newmark', \
'For Newmark-beta discretisation, use assemble method directly.'

if dt is not None:
Expand Down
3 changes: 2 additions & 1 deletion sharpy/linear/utils/ss_interface.py
Expand Up @@ -475,7 +475,8 @@ def load_from_h5_file(cls, variable_type, variables_data):
raise KeyError(f'Unknown variable type {variable_type}. Must be either InputVariable, OutputVariable '
f'or StateVariable')
for ith_variable in range(n_variables):
name = variables_data['names'][ith_variable].astype('U13') # decode to unicode
# name = variables_data['names'][ith_variable].astype('U13') # decode to unicode
name = str(variables_data['names'][ith_variable], 'utf8') # decode to unicode
list_of_variables.append(var_class(name,
size=variables_data['sizes'][ith_variable],
index=variables_data['indices'][ith_variable]),
Expand Down
2 changes: 1 addition & 1 deletion sharpy/rom/utils/librom.py
Expand Up @@ -1024,7 +1024,7 @@ def modred(SSb, N, method='residualisation'):
C11 = SSb.C[:, :N]
D = SSb.D

if method is 'truncation':
if method == 'truncation':
SSrom = libss.StateSpace(A11, B11, C11, D, dt=SSb.dt)
else:
Nb = SSb.A.shape[0]
Expand Down
4 changes: 2 additions & 2 deletions sharpy/solvers/beamloader.py
Expand Up @@ -122,8 +122,8 @@ def read_files(self):
# Need to redefine strings to remove the "b" at the beginning
for iconstraint in range(self.mb_data_dict['num_constraints']):
self.mb_data_dict["constraint_%02d" % iconstraint]['behaviour'] = self.mb_data_dict["constraint_%02d" % iconstraint]['behaviour'].decode()
#for ibody in range(self.mb_data_dict['num_bodies']):
# self.mb_data_dict["body_%02d" % ibody]['FoR_movement'] = self.mb_data_dict["body_%02d" % ibody]['FoR_movement'].decode()
for ibody in range(self.mb_data_dict['num_bodies']):
self.mb_data_dict["body_%02d" % ibody]['FoR_movement'] = self.mb_data_dict["body_%02d" % ibody]['FoR_movement'].decode()

def validate_fem_file(self):
raise NotImplementedError('validation of the fem file in beamloader is not yet implemented!')
Expand Down
2 changes: 1 addition & 1 deletion sharpy/solvers/dynamiccoupled.py
Expand Up @@ -334,7 +334,7 @@ def initialise(self, data, custom_settings=None, restart=False):
'FoR_vel(x)', 'FoR_vel(z)'])

# Define the function to correct aerodynamic forces
if self.settings['correct_forces_method'] is not '':
if self.settings['correct_forces_method'] != '':
self.correct_forces = True
self.correct_forces_generator = gen_interface.generator_from_string(self.settings['correct_forces_method'])()
self.correct_forces_generator.initialise(in_dict=self.settings['correct_forces_settings'],
Expand Down
2 changes: 1 addition & 1 deletion sharpy/solvers/staticcoupled.py
Expand Up @@ -124,7 +124,7 @@ def initialise(self, data, input_dict=None, restart=False):
self.residual_table.print_header(['iter', 'step', 'log10(res)', 'Fx', 'Fy', 'Fz', 'Mx', 'My', 'Mz'])

# Define the function to correct aerodynamic forces
if self.settings['correct_forces_method'] is not '':
if self.settings['correct_forces_method'] != '':
self.correct_forces = True
self.correct_forces_generator = gen_interface.generator_from_string(self.settings['correct_forces_method'])()
self.correct_forces_generator.initialise(in_dict=self.settings['correct_forces_settings'],
Expand Down
Expand Up @@ -417,3 +417,6 @@ def tearDown(self):
os.remove(solver_path + f)

shutil.rmtree(solver_path + 'output/')

if __name__ == '__main__':
unittest.main()
2 changes: 2 additions & 0 deletions tests/linear/rom/test_krylov.py
Expand Up @@ -64,6 +64,8 @@ def run_test(self, test_settings):
assert np.log10(max_error) < -2, 'Significant mismatch in ROM frequency Response'

# check saving function
if os.path.isfile(self.test_dir + '/rom_data.h5'):
os.remove(self.test_dir + '/rom_data.h5')
self.rom.save(self.test_dir + '/rom_data.h5')

def test_krylov(self):
Expand Down
Expand Up @@ -336,7 +336,7 @@ def generate_solver_file(horseshoe=False):
}

minus_m_star = 0
if config['StaticUvlm']['horseshoe'] is 'on':
if config['StaticUvlm']['horseshoe'] == 'on':
minus_m_star = max(m_main - 1, 1)
config['AerogridPlot'] = {'include_rbm': 'off',
'include_applied_forces': 'on',
Expand Down
2 changes: 1 addition & 1 deletion tests/uvlm/static/planarwing/generate_planarwing.py
Expand Up @@ -335,7 +335,7 @@ def generate_solver_file(horseshoe=False):
}

minus_m_star = 0
if config['StaticUvlm']['horseshoe'] is 'on':
if config['StaticUvlm']['horseshoe'] == 'on':
minus_m_star = max(m_main - 1, 1)
config['AerogridPlot'] = {'include_rbm': 'off',
'include_applied_forces': 'on',
Expand Down
26 changes: 26 additions & 0 deletions utils/environment_new.yml
@@ -0,0 +1,26 @@
name: sharpy
channels:
- conda-forge
- defaults
dependencies:
- asn1crypto>=1.2.0
- colorama>=0.4.1
- control>=0.8.4
- dill>=0.3.1.1
- h5py>=2.9.0
- jupyterlab>=1.2.3
- lxml>=4.4.1
- mayavi>=4.7.1
- nbsphinx>=0.4.3
- pandas>=0.25.3
- pyOpenSSL>=19.0.0
- PySocks>=1.7.1
- PyYAML>=5.1.2
- recommonmark>=0.6.0
- slycot>=0.4.0
- sphinx_rtd_theme>=0.4.3
- wheel>=0.33.6
- xlrd>=1.2.0
- python=3.10
- openpyxl>=3.0.10
- cmake=3.14.0

0 comments on commit 3e5efc7

Please sign in to comment.