Skip to content
Snippets Groups Projects
Commit 8b13f0ce authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files
parents e2d1b73b e79edacd
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
conda update --all conda update --all
conda create -n wetb_py3 python=3.5 conda create -n wetb_py3 python=3.5
source activate wetb_py3 source activate wetb_py3
conda install setuptools_scm future h5py pytables pytest nose sphinx blosc conda install setuptools_scm future h5py pytables pytest nose sphinx blosc psutil
conda install scipy pandas matplotlib cython xlrd coverage xlwt openpyxl paramiko conda install scipy pandas matplotlib cython xlrd coverage xlwt openpyxl paramiko
conda install -c https://conda.anaconda.org/conda-forge pyscaffold pytest-cov conda install -c https://conda.anaconda.org/conda-forge pyscaffold pytest-cov
``` ```
...@@ -19,7 +19,7 @@ conda install -c https://conda.anaconda.org/conda-forge pyscaffold pytest-cov ...@@ -19,7 +19,7 @@ conda install -c https://conda.anaconda.org/conda-forge pyscaffold pytest-cov
conda update --all conda update --all
conda create -n wetb_py3 python=3.4 conda create -n wetb_py3 python=3.4
source activate wetb_py3 source activate wetb_py3
conda install setuptools_scm future h5py pytables pytest nose sphinx conda install setuptools_scm future h5py pytables pytest nose sphinx psutil
conda install scipy pandas matplotlib cython xlrd coverage xlwt openpyxl paramiko conda install scipy pandas matplotlib cython xlrd coverage xlwt openpyxl paramiko
conda install -c https://conda.anaconda.org/conda-forge pyscaffold pytest-cov conda install -c https://conda.anaconda.org/conda-forge pyscaffold pytest-cov
``` ```
......
...@@ -40,7 +40,7 @@ The python distribution in use will now be located in \<path_to_anaconda\>/env/p ...@@ -40,7 +40,7 @@ The python distribution in use will now be located in \<path_to_anaconda\>/env/p
``` ```
conda install setuptools_scm future h5py pytables pytest nose sphinx conda install setuptools_scm future h5py pytables pytest nose sphinx
conda install scipy pandas matplotlib cython xlrd coverage xlwt openpyxl conda install scipy pandas matplotlib cython xlrd coverage xlwt openpyxl psutil
``` ```
* Not all packages are available in the conda repositories, but they can be * Not all packages are available in the conda repositories, but they can be
......
...@@ -15,6 +15,46 @@ import numpy as np ...@@ -15,6 +15,46 @@ import numpy as np
class Control(object): class Control(object):
def torque_controller_tuning(self, r0, lambda_opt, ksi_pole_part,
omega_pole_part, j_dt):
"""THIS IS A WIP
"""
# TODO: THIS IS STILL A WIP
i12, i23, i34 = self.select_regions()
# Compute K factor for optimal CP tracking in region 1 as
# K=0.5*rho*A*Cp_opt*R^3/lambda_opt^3
# HAWCStab2/Computation_LIB/compute_controller_input_mod.f90:83-88
# Compute K factor for optimal CP tracking in region 1 as
# K=0.5*rho*A*Cp_opt*R^3/lambda_opt^3
# pi_torque_controller%kfactor=0.d0
# do i=1,iregion2-iregion1-1
# !kfactor=kfactor+0.85d0*kfactor_fit(i)*substructure(3)
# pi_torque_controller%kfactor
# = pi_torque_controller%kfactor
# + kfactor_fit(i)*substructure(3)%opstate(i+iregion1)%r0**3/lambda_opt**3
# enddo
# HAWCStab2/Computation_LIB/compute_controller_input_mod.f90:89
# pi_torque_controller%kfactor =
# pi_torque_controller%kfactor/max(dfloat(iregion2-iregion1-1), 1.d0)
Qg = (r0*r0*r0)/(lambda_opt*lambda_opt*lambda_opt)
# PI generator torque controller in region 2 (constant speed, variable power)
# HAWCStab2/Computation_LIB/compute_controller_input_mod.f90:104-105
# pi_torque_controller%kp = 2.d0*ksi_pole_part*omega_pole_part*j_dt
# pi_torque_controller%ki = omega_pole_part**2*j_dt
pgTorque = 2.0*ksi_pole_part*omega_pole_part*j_dt
igTorque = omega_pole_part**2*j_dt
return Qg, pgTorque, igTorque
def pitch_controller_tuning(self, pitch, I, dQdt, P, Omr, om, csi): def pitch_controller_tuning(self, pitch, I, dQdt, P, Omr, om, csi):
""" """
...@@ -89,6 +129,24 @@ class Control(object): ...@@ -89,6 +129,24 @@ class Control(object):
return K return K
def select_regions(self, pitch, omega, power): def select_regions(self, pitch, omega, power):
"""Find indices at wich point the controller should switch between the
different operating mode regions.
Parameters
----------
Returns
------
i12 : int
123 : int
134 : int
"""
i12 = 0 i12 = 0
......
...@@ -202,6 +202,15 @@ class LogFile(object): ...@@ -202,6 +202,15 @@ class LogFile(object):
# no need to look for messages if global time is mentioned # no need to look for messages if global time is mentioned
continue continue
elif line[:4] == ' kfw':
pass
# Global time = 17.7800000000000 Iter = 2
# kfw 0.861664060457402
# nearwake iterations 17
# computed relaxation factor 0.300000000000000
elif line[:20] == ' Starting simulation': elif line[:20] == ' Starting simulation':
init_block = False init_block = False
...@@ -627,7 +636,138 @@ class LoadResults(ReadHawc2): ...@@ -627,7 +636,138 @@ class LoadResults(ReadHawc2):
del change_list[k] del change_list[k]
break break
# self.ch_details_new = ch_details_new # TODO: THIS IS STILL A WIP
def _make_channel_names(self):
"""Give every channel a unique channel name which is (nearly) identical
to the channel names as defined in the htc output section. Instead
of spaces, use colon (;) to seperate the different commands.
THIS IS STILL A WIP
"""
index = {}
names = {'htc_name':[], 'chi':[], 'label':[], 'unit':[], 'index':[],
'name':[], 'description':[]}
constraint_fmts = {'bea1':'constraint;bearing1',
'bea2':'constraint;bearing2',
'bea3':'constraint;bearing3',
'bea4':'constraint;bearing4'}
# mbdy momentvec tower 1 1 global
force_fmts = {'F':'mbdy;forcevec;{body};{nodenr:03i};{coord};{comp}',
'M':'mbdy;momentvec;{body};{nodenr:03i};{coord};{comp}'}
state_fmt = 'mbdy;{state};{typ};{body};{elnr:03i};{zrel:01.02f};{coord}'
wind_coord_map = {'Vx':'1', 'Vy':'2', 'Vz':'3'}
wind_fmt = 'wind;{typ};{coord};{x};{y};{z};{comp}'
for ch in range(self.Nch):
name = self.ch_details[ch, 0]
name_items = misc.remove_items(name.split(' '), '')
description = self.ch_details[ch, 2]
descr_items = misc.remove_items(description.split(' '), '')
unit = self.ch_details[ch, 1]
# default names
htc_name = ' '.join(name_items+descr_items)
label = ''
coord = ''
typ = ''
elnr = ''
nodenr = ''
zrel = ''
state = ''
# CONSTRAINTS: BEARINGS
if name_items[0] in constraint_fmts:
htc_name = constraint_fmts[name_items[0]] + ';'
htc_name += (descr_items[0] + ';')
htc_name += unit
# MBDY FORCES/MOMENTS
elif name_items[0][0] in force_fmts:
comp = name_items[0]
if comp[0] == 'F':
i0 = 1
else:
i0 = 0
label = description.split('coo: ')[1].split(' ')[1]
coord = descr_items[i0+5]
body = descr_items[i0+1][5:]#.replace('Mbdy:', '')
nodenr = int(descr_items[i0+3])
htc_name = force_fmts[comp[0]].format(body=body, coord=coord,
nodenr=nodenr, comp=comp)
# STATE: POS, VEL, ACC, STATE_ROT
elif descr_items[0][:5] == 'State':
if name_items[0] == 'State':
i0 = 1
state = 'state'
else:
i0 = 0
state = 'state_rot'
typ = name_items[i0+0]
comp = name_items[i0+1]
coord = name_items[i0+3]
body = descr_items[3][5:]#.replace('Mbdy:', '')
elnr = int(descr_items[5])
zrel = float(descr_items[6][6:])#.replace('Z-rel:', ''))
if len(descr_items) > 8:
label = ' '.join(descr_items[9:])
htc_name = state_fmt.format(typ=typ, body=body, elnr=elnr,
zrel=zrel, coord=coord,
state=state)
# WINDSPEED
elif description[:9] == 'Free wind':
if descr_items[4] == 'gl.':
coord = '1' # global
else:
coord = '2' # non-rotating rotor coordinates
try:
comp = wind_coord_map[descr_items[3][:-1]]
typ = 'free_wind'
except KeyError:
comp = descr_items[3]
typ = 'free_wind_hor'
tmp = description.split('pos')[1]
x, y, z = tmp.split(',')
# z might hold a label....
z_items = z.split(' ')
if len(z_items) > 1:
label = ' '.join(z_items[1:])
z = z_items[0]
x, y, z = x.strip(), y.strip(), z.strip()
htc_name = wind_fmt.format(typ=typ, coord=coord, x=x, y=y, z=z,
comp=comp)
names['htc_name'].append(htc_name)
names['chi'].append(ch)
# this is the Channel column from the sel file, so the unique index
# which is dependent on the order of the channels
names['index'].append(ch+1)
names['unit'].append(unit)
names['name'].append(name)
names['description'].append(description)
names['label'].append(label)
names['state'].append(state)
names['type'].append(typ)
names['comp'].append(comp)
names['coord'].append(coord)
names['elnr'].append(coord)
names['nodenr'].append(coord)
names['zrel'].append(coord)
index[name] = ch
return names, index
def _unified_channel_names(self): def _unified_channel_names(self):
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment