コード例 #1
0
ファイル: verification.py プロジェクト: ptrbortolotti/WEIS
def verify(name, a=1, b=1, f=1, mod=1, phase=1):
    if name == 'OC3':
        filename = '../designs/OC3spar.yaml'
        i = 0
        Adof = [1, 3, 5, 15, 24]
        Bdof = [1, 3, 5, 15, 24]
        Fdof = [1, 3, 5]
    elif name == 'OC4':
        filename = '../designs/OC4semi.yaml'
        i = 1
        Adof = [1, 3, 5, 6, 15, 24]
        Bdof = [1, 3, 5, 6, 15, 24]
        Fdof = [1, 3, 5]

    wamitfiles = [['spar.1', 'spar.3'], ['marin_semi.1', 'marin_semi.3']]
    # get the values from the referenced wamit data to compare results to
    A_wamit, B_wamit, w_wamit = getWamit1(file=wamitfiles[i][0])
    mod_wamit, w_wamit, phase_wamit = getWamit3(file=wamitfiles[i][1])

    # read in the desired yaml file and set up initial variables
    with open(filename) as file:
        design = yaml.load(file, Loader=yaml.FullLoader)

    depth = float(design['mooring']['water_depth'])
    w = np.arange(0.05, 5, 0.05)

    # Create modelA where potModMaster is 1, so strip theory is used for all
    design['potModMaster'] = 1
    modelA = raft.Model(design, w=w, depth=depth)  # set up model
    modelA.setEnv()  # set basic wave and wind info
    modelA.calcSystemProps(
    )  # get all the setup calculations done within the model

    # Create modelB where potModMaster is 2, so only BEM is used for all
    design['potModMaster'] = 2
    modelB = raft.Model(design, w=w, depth=depth)  # set up model
    modelB.setEnv()  # set basic wave and wind info
    modelB.calcSystemProps(
    )  # get all the setup calculations done within the model

    fowtA = modelA.fowtList[0]
    fowtB = modelB.fowtList[0]

    if a == 1:
        plotAddedMass(fowtA, fowtB, A_wamit, w_wamit, A=Adof)
    if b == 1:
        plotDamping(fowtA, fowtB, B_wamit, w_wamit, B=Bdof)
    if f == 1:
        plotForcing(fowtA,
                    fowtB,
                    mod_wamit,
                    phase_wamit,
                    w_wamit,
                    F=Fdof,
                    mod=mod,
                    phase=phase)
コード例 #2
0
ファイル: runRAFT.py プロジェクト: zhaoweisonake/RAFT
def runRAFT(fname_design, fname_env):
    '''
    This the main function for running the raft model in standalone form, where inputs are contained in the specified input files.
    '''

    # open the design YAML file and parse it into a dictionary for passing to raft

    with open(fname_design) as file:
        design = yaml.load(file, Loader=yaml.FullLoader)

    print("Loading file: " + fname_design)
    print(f"'{design['name']}'")

    depth = float(design['mooring']['water_depth'])

    # --- BEM ---
    # (preprocessing step:) Generate and load BEM hydro data
    capyData = []

    capyTestFile = f'./test_data/mesh_converge_0.750_1.250.nc'

    w = np.arange(0.05, 2.8,
                  0.05)  # frequency range (to be set by modeling options yaml)
    '''
    # load or generate Capytaine data
    if capyDataExists:
        wDes, addedMass, damping, fEx = capy.read_capy_nc(capyTestFile, wDes=w)
    else:
        wCapy, addedMass, damping, fEx = capy.call_capy(meshFName, w)
        
    # package results to send to model
    capyData = (wCapy, addedMass, damping, fEx)
    '''

    # --- Create and run the model ---

    model = raft.Model(design, w=w, depth=depth, BEM=capyData)  # set up model

    model.setEnv(
        Hs=8, Tp=12, V=10, Fthrust=float(
            design['turbine']['Fthrust']))  # set basic wave and wind info

    model.calcSystemProps(
    )  # get all the setup calculations done within the model

    model.solveEigen()

    model.calcMooringAndOffsets(
    )  # calculate the offsets for the given loading

    model.solveDynamics(
    )  # put everything together and iteratively solve the dynamic response

    model.plot()

    plt.show()

    return model
コード例 #3
0
    def setUpClass(self):

        raft_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
        input_file = os.path.join(raft_dir, 'designs/OC3spar.yaml')
        with open(input_file) as file:
            design = yaml.load(file, Loader=yaml.FullLoader)

        self.model = raft.Model(design)
        self.model.analyzeUnloaded()
        self.fowt = self.model.fowtList[0]
        self.pdiff = 0.01
コード例 #4
0
def runRAFT(fname_design, fname_env):
    '''
    This the main function for running the raft model in standalone form, where inputs are contained in the specified input files.
    '''

    # open the design YAML file and parse it into a dictionary for passing to raft

    with open(fname_design) as file:
        design = yaml.load(file, Loader=yaml.FullLoader)

    print("Loading file: " + fname_design)
    print(f"'{design['name']}'")

    depth = float(design['mooring']['water_depth'])

    # now off potMod in the design dictionary to avoid BEM analysis
    for mi in design['platform']['members']:
        mi['potMod'] = False

    # set up frequency range
    w = np.arange(0.05, 5,
                  0.05)  # frequency range (to be set by modeling options yaml)

    # --- Create and run the model ---

    model = raft.Model(design, w=w, depth=depth)  # set up model

    model.setEnv(
        Hs=8, Tp=12, V=10, Fthrust=float(
            design['turbine']['Fthrust']))  # set basic wave and wind info

    model.calcSystemProps(
    )  # get all the setup calculations done within the model

    model.solveEigen()

    model.calcMooringAndOffsets(
    )  # calculate the offsets for the given loading

    model.solveDynamics(
    )  # put everything together and iteratively solve the dynamic response

    model.plot()

    plt.show()

    return model
コード例 #5
0
ファイル: test_omdao_OC4semi.py プロジェクト: WISDEM/RAFT
fname_design = os.path.join(os.path.join('..', 'designs'), 'OC4semi.yaml')

# open the design YAML file and parse it into a dictionary for passing to raft
with open(fname_design) as file:
    design = yaml.load(file, Loader=yaml.FullLoader)
design['potModMaster'] = 1

# grab the depth (currently needs to be passed separately)
depth = float(design['mooring']['water_depth'])

# set up frequency range for computing response over
w = np.arange(0.05, 5,
              0.05)  # frequency range (to be set by modeling options yaml)

# Create and run the model
model = raft.Model(design, w=w, depth=depth)

model.setEnv(spectrum="unit")

model.calcSystemProps()

model.solveEigen()

model.calcMooringAndOffsets()

model.solveDynamics()

results = model.calcOutputs()
print('-----------------')
testPass = test(prob, results)
コード例 #6
0
# example script for running RAFT from a YAML input file

import numpy as np
import matplotlib.pyplot as plt
import yaml
import raft

# open the design YAML file and parse it into a dictionary for passing to raft
with open('VolturnUS-S_example.yaml') as file:
    design = yaml.load(file, Loader=yaml.FullLoader)

# Create the RAFT model (will set up all model objects based on the design dict)
model = raft.Model(design)  

# Evaluate the system properties and equilibrium position before loads are applied
model.analyzeUnloaded()

# Compute natural frequencie
model.solveEigen()

# Simule the different load cases
model.analyzeCases(display=1)

# Plot the power spectral densities from the load cases
model.plotResponses()

# Visualize the system in its most recently evaluated mean offset position
model.plot(hideGrid=True)

plt.show()
コード例 #7
0
ファイル: omdao_raft.py プロジェクト: ptrbortolotti/WEIS
    def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):

        turbine_opt = self.options['turbine_options']
        mooring_opt = self.options['mooring_options']
        members_opt = self.options['member_options']
        modeling_opt = self.options['modeling_options']

        #turbine_npts = turbine_opt['npts']

        nmembers = members_opt['nmembers']
        member_npts = members_opt['npts']
        member_npts_lfill = members_opt['npts_lfill']
        #member_npts_rho_fill = members_opt['npts_rho_fill']
        member_ncaps = members_opt['ncaps']
        member_nreps = members_opt['nreps']
        member_shapes = members_opt['shape']
        member_scalar_t = members_opt['scalar_thicknesses']
        member_scalar_d = members_opt['scalar_diameters']
        member_scalar_coeff = members_opt['scalar_coefficients']

        nlines = mooring_opt['nlines']
        nline_types = mooring_opt['nline_types']
        nconnections = mooring_opt['nconnections']

        # set up design
        design = {}
        design['type'] = ['input dictionary for RAFT']
        design['name'] = ['spiderfloat']
        design['comments'] = ['none']

        design['potModMaster'] = int(modeling_opt['potModMaster'])
        design['XiStart'] = float(modeling_opt['XiStart'])
        design['nIter'] = int(modeling_opt['nIter'])
        design['dlsMax'] = float(modeling_opt['dlsMax'])

        # TODO: these float conversions are messy
        design['turbine'] = {}
        design['turbine']['mRNA'] = float(inputs['turbine_mRNA'])
        design['turbine']['IxRNA'] = float(inputs['turbine_IxRNA'])
        design['turbine']['IrRNA'] = float(inputs['turbine_IrRNA'])
        design['turbine']['xCG_RNA'] = float(inputs['turbine_xCG_RNA'])
        design['turbine']['hHub'] = float(inputs['turbine_hHub'])
        design['turbine']['Fthrust'] = float(inputs['turbine_Fthrust'])
        design['turbine']['yaw_stiffness'] = float(
            inputs['turbine_yaw_stiffness'])
        design['turbine']['tower'] = {}
        design['turbine']['tower']['name'] = 'tower'
        design['turbine']['tower']['type'] = 1
        design['turbine']['tower']['rA'] = inputs['turbine_tower_rA']
        design['turbine']['tower']['rB'] = inputs['turbine_tower_rB']
        design['turbine']['tower']['shape'] = turbine_opt['shape']
        design['turbine']['tower']['gamma'] = inputs['turbine_tower_gamma']
        design['turbine']['tower']['stations'] = inputs[
            'turbine_tower_stations']
        if turbine_opt['scalar_diameters']:
            design['turbine']['tower']['d'] = float(inputs['turbine_tower_d'])
        else:
            design['turbine']['tower']['d'] = inputs['turbine_tower_d']
        if turbine_opt['scalar_thicknesses']:
            design['turbine']['tower']['t'] = float(inputs['turbine_tower_t'])
        else:
            design['turbine']['tower']['t'] = inputs['turbine_tower_t']
        if turbine_opt['scalar_coefficients']:
            design['turbine']['tower']['Cd'] = float(
                inputs['turbine_tower_Cd'])
            design['turbine']['tower']['Ca'] = float(
                inputs['turbine_tower_Ca'])
            design['turbine']['tower']['CdEnd'] = float(
                inputs['turbine_tower_CdEnd'])
            design['turbine']['tower']['CaEnd'] = float(
                inputs['turbine_tower_CaEnd'])
        else:
            design['turbine']['tower']['Cd'] = inputs['turbine_tower_Cd']
            design['turbine']['tower']['Ca'] = inputs['turbine_tower_Ca']
            design['turbine']['tower']['CdEnd'] = inputs['turbine_tower_CdEnd']
            design['turbine']['tower']['CaEnd'] = inputs['turbine_tower_CaEnd']
        design['turbine']['tower']['rho_shell'] = float(
            inputs['turbine_tower_rho_shell'])

        design['platform'] = {}
        design['platform']['members'] = [dict() for i in range(nmembers)]
        for i in range(nmembers):
            m_name = f'platform_member{i+1}_'
            m_shape = member_shapes[i]
            mnpts_lfill = member_npts_lfill[i]
            mncaps = member_ncaps[i]
            mnreps = member_nreps[i]
            mnpts = member_npts[i]

            design['platform']['members'][i]['name'] = m_name
            design['platform']['members'][i]['type'] = i + 2
            design['platform']['members'][i]['rA'] = inputs[m_name + 'rA']
            design['platform']['members'][i]['rB'] = inputs[m_name + 'rB']
            design['platform']['members'][i]['shape'] = m_shape
            design['platform']['members'][i]['gamma'] = float(inputs[m_name +
                                                                     'gamma'])
            design['platform']['members'][i]['potMod'] = discrete_inputs[
                m_name + 'potMod']
            design['platform']['members'][i]['stations'] = inputs[m_name +
                                                                  'stations']

            # updated version to better handle 'diameters' between circular and rectangular members
            if m_shape == 'circ' or m_shape == 'square':
                if member_scalar_d[i]:
                    design['platform']['members'][i]['d'] = [
                        float(inputs[m_name + 'd'])
                    ] * mnpts
                else:
                    design['platform']['members'][i]['d'] = inputs[m_name +
                                                                   'd']
            elif m_shape == 'rect':
                if member_scalar_d[i]:
                    design['platform']['members'][i]['d'] = [
                        inputs[m_name + 'd']
                    ] * mnpts
                else:
                    design['platform']['members'][i]['d'] = inputs[m_name +
                                                                   'd']
            ''' original version of handling diameters
            if member_scalar_d[i]:
                design['platform']['members'][i]['d'] = float(inputs[m_name+'d'])
            else:
                design['platform']['members'][i]['d'] = inputs[m_name+'d']
            '''
            if member_scalar_t[i]:
                design['platform']['members'][i]['t'] = float(inputs[m_name +
                                                                     't'])
            else:
                design['platform']['members'][i]['t'] = inputs[m_name + 't']
            if member_scalar_coeff[i]:
                design['platform']['members'][i]['Cd'] = float(inputs[m_name +
                                                                      'Cd'])
                design['platform']['members'][i]['Ca'] = float(inputs[m_name +
                                                                      'Ca'])
                design['platform']['members'][i]['CdEnd'] = float(
                    inputs[m_name + 'CdEnd'])
                design['platform']['members'][i]['CaEnd'] = float(
                    inputs[m_name + 'CaEnd'])
            else:
                design['platform']['members'][i]['Cd'] = inputs[m_name + 'Cd']
                design['platform']['members'][i]['Ca'] = inputs[m_name + 'Ca']
                design['platform']['members'][i]['CdEnd'] = inputs[m_name +
                                                                   'CdEnd']
                design['platform']['members'][i]['CaEnd'] = inputs[m_name +
                                                                   'CaEnd']
            design['platform']['members'][i]['rho_shell'] = float(
                inputs[m_name + 'rho_shell'])
            if mnreps > 0:
                design['platform']['members'][i]['heading'] = inputs[m_name +
                                                                     'heading']
            if mnpts_lfill > 0:
                design['platform']['members'][i]['l_fill'] = inputs[m_name +
                                                                    'l_fill']
                design['platform']['members'][i]['rho_fill'] = inputs[
                    m_name + 'rho_fill']
            if ((mncaps > 0) or (inputs[m_name + 'ring_spacing'] > 0)):
                # Member discretization
                s_grid = inputs[m_name + 'stations']
                s_height = s_grid[-1] - s_grid[0]
                # Get locations of internal structures based on spacing
                ring_spacing = inputs[m_name + 'ring_spacing']
                n_stiff = 0 if ring_spacing == 0.0 else int(
                    np.floor(s_height / ring_spacing))
                s_ring = (np.arange(1, n_stiff + 0.1) - 0.5) * (ring_spacing /
                                                                s_height)
                #d_ring = np.interp(s_ring, s_grid, inputs[m_name+'d'])
                d_ring = np.interp(s_ring, s_grid,
                                   design['platform']['members'][i]['d'])
                # Combine internal structures based on spacing and defined positions
                s_cap = np.r_[s_ring, inputs[m_name + 'cap_stations']]
                t_cap = np.r_[inputs[m_name + 'ring_t'] * np.ones(n_stiff),
                              inputs[m_name + 'cap_t']]
                di_cap = np.r_[d_ring - 2 * inputs[m_name + 'ring_h'],
                               inputs[m_name + 'cap_d_in']]
                # Store vectors in sorted order
                isort = np.argsort(s_cap)
                design['platform']['members'][i]['cap_stations'] = s_cap[isort]
                design['platform']['members'][i]['cap_t'] = t_cap[isort]
                design['platform']['members'][i]['cap_d_in'] = di_cap[isort]

        design['mooring'] = {}
        design['mooring']['water_depth'] = inputs['mooring_water_depth']
        design['mooring']['points'] = [dict() for i in range(nconnections)]
        for i in range(0, nconnections):
            pt_name = f'mooring_point{i+1}_'
            design['mooring']['points'][i]['name'] = discrete_inputs[pt_name +
                                                                     'name']
            design['mooring']['points'][i]['type'] = discrete_inputs[pt_name +
                                                                     'type']
            design['mooring']['points'][i]['location'] = inputs[pt_name +
                                                                'location']

        design['mooring']['lines'] = [dict() for i in range(nlines)]
        for i in range(0, nlines):
            ml_name = f'mooring_line{i+1}_'
            design['mooring']['lines'][i]['name'] = f'line{i+1}'
            design['mooring']['lines'][i]['endA'] = discrete_inputs[ml_name +
                                                                    'endA']
            design['mooring']['lines'][i]['endB'] = discrete_inputs[ml_name +
                                                                    'endB']
            design['mooring']['lines'][i]['type'] = discrete_inputs[ml_name +
                                                                    'type']
            design['mooring']['lines'][i]['length'] = inputs[ml_name +
                                                             'length']
        design['mooring']['line_types'] = [dict() for i in range(nline_types)]
        for i in range(0, nline_types):
            lt_name = f'mooring_line_type{i+1}_'
            design['mooring']['line_types'][i]['name'] = discrete_inputs[
                lt_name + 'name']
            design['mooring']['line_types'][i]['diameter'] = float(
                inputs[lt_name + 'diameter'])
            design['mooring']['line_types'][i]['mass_density'] = float(
                inputs[lt_name + 'mass_density'])
            design['mooring']['line_types'][i]['stiffness'] = float(
                inputs[lt_name + 'stiffness'])
            design['mooring']['line_types'][i]['breaking_load'] = float(
                inputs[lt_name + 'breaking_load'])
            design['mooring']['line_types'][i]['cost'] = float(inputs[lt_name +
                                                                      'cost'])
            design['mooring']['line_types'][i][
                'transverse_added_mass'] = float(
                    inputs[lt_name + 'transverse_added_mass'])
            design['mooring']['line_types'][i][
                'tangential_added_mass'] = float(
                    inputs[lt_name + 'tangential_added_mass'])
            design['mooring']['line_types'][i]['transverse_drag'] = float(
                inputs[lt_name + 'transverse_drag'])
            design['mooring']['line_types'][i]['tangential_drag'] = float(
                inputs[lt_name + 'tangential_drag'])

        # grab the depth
        depth = float(design['mooring']['water_depth'])

        # set up frequency range for computing response over
        w = inputs['frequency_range']

        # create and run the model
        model = raft.Model(design, w=w, depth=depth)
        model.setEnv(spectrum="unit")
        model.calcSystemProps()
        model.solveEigen()
        model.calcMooringAndOffsets()
        model.solveDynamics()
        results = model.calcOutputs()

        outs = self.list_outputs(values=False, out_stream=None)
        for i in range(len(outs)):
            if outs[i][0].startswith('properties_'):
                name = outs[i][0].split('properties_')[1]
                outputs['properties_' + name] = results['properties'][name]
            elif outs[i][0].startswith('response_'):
                name = outs[i][0].split('response_')[1]
                if np.iscomplex(results['response'][name]).any():
                    outputs['response_' + name] = np.abs(
                        results['response'][name])
                else:
                    outputs['response_' + name] = results['response'][name]