Пример #1
0
def load_study_gui(std_name, form):
    std = study.Study()
    std.tmp_dir = TMP_DIR
    std.name = std_name
    std = std.load()
    saved_from_gui = len(std.params_from_gui) != 0
    if not saved_from_gui:
        reconstruct_params_from_gui(std)
    form.read_params_from_gui(std.params_from_gui)
    return saved_from_gui
Пример #2
0
def load_study(std_name):
    std = study.Study()
    std.tmp_dir = TMP_DIR
    std.name = std_name
    std = std.load()
    std_name = find_std_name(std_name)
    __main__.stds[std_name] = std
    __main__.openMdb(pathName=std_name + '.cae')
    vpname = __main__.session.currentViewportName
    __main__.session.viewports[vpname].setValues(displayedObject=None)
    mdb = __main__.mdb
    if std.ccs[0].model_name in mdb.models.keys():
        mod = mdb.models[std.ccs[0].model_name]
        p = mod.parts['Shell']
        __main__.session.viewports[vpname].setValues(displayedObject=p)
        a = mod.rootAssembly
        a.regenerate()

    for cc in std.ccs:
        if not cc.model_name in mdb.models.keys():
            print('Could not load objects for model {0}!'.format(
                cc.model_name))
            continue
        abaqus_functions.set_colors_ti(cc)
Пример #3
0
def create_study(**kwargs):
    # setting defaults
    pl_table = kwargs.get('pl_table')
    pload_step = kwargs.get('pload_step')
    d_table = kwargs.get('d_table')
    ax_table = kwargs.get('ax_table')
    lbmi_table = kwargs.get('lbmi_table')
    cut_table = kwargs.get('cut_table')
    betadeg = kwargs.get('betadeg', 0.)
    omegadeg = kwargs.get('omegadeg', 0.)
    betadegs = kwargs.get('betadegs')
    omegadegs = kwargs.get('omegadegs')

    imp_num = {}
    imp_num['pl'] = kwargs.get('pl_num')
    imp_num['d'] = kwargs.get('d_num')
    imp_num['ax'] = kwargs.get('ax_num')
    imp_num['lbmi'] = kwargs.get('lbmi_num')
    imp_num['cut'] = kwargs.get('cut_num')
    imp_tables = {}
    imp_tables['pl'] = kwargs.get('pl_table')
    imp_tables['d'] = kwargs.get('d_table')
    imp_tables['ax'] = kwargs.get('ax_table')
    imp_tables['lbmi'] = kwargs.get('lbmi_table')
    imp_tables['cut'] = kwargs.get('cut_table')
    num_params = {}
    num_params['pl'] = 2
    num_params['d'] = 4
    num_params['ax'] = 2
    num_params['lbmi'] = 1
    num_params['cut'] = 3
    num_models = 1
    for k in ['pl', 'd', 'ax', 'lbmi', 'cut']:
        if imp_num[k] == 0:
            continue
        imp_table = imp_tables[k]
        num_models = max(num_models, len(imp_table) - (num_params[k] + 1))
    #
    # Cleaning up input values
    #
    # laminate
    laminate = np.atleast_2d([i for i in kwargs.get('laminate') if i])
    kwargs['laminate'] = laminate
    kwargs['stack'] = [float(i) for i in laminate[:, 2] if i != '']
    stack = kwargs['stack']
    kwargs['laminapropKeys'] = [
        i if i != '' else laminate[0, 0] for i in laminate[:len(stack), 0]
    ]
    kwargs['plyts'] = [
        float(i) if i != '' else float(laminate[0, 1])
        for i in laminate[:len(stack), 1]
    ]
    #TODO currently only one allowable is allowed for stress analysis
    kwargs['allowables'] = [kwargs['allowables'] for _ in stack]
    #allowablesKeys = [float(i) if i != '' else laminate[0,3] \
    #         for i in laminate[:len(stack),1]]
    #
    # load asymmetry
    #
    #TODO list comprehension for these guys below
    la = kwargs.get('la')
    if la == 0:
        betadegs = []
        omegadegs = []
    elif la == 1:
        betadegs = [betadeg for i in range(num_models)]
        omegadegs = [omegadeg for i in range(num_models)]
    elif la == 2:
        if betadegs is not None:
            new_betadegs = []
            for betadeg in betadegs:
                if betadeg:
                    new_betadegs.append(betadeg[0])
            betadegs = new_betadegs
        else:
            betadegs = []
        if omegadegs is not None:
            new_omegadegs = []
            for omegadeg in omegadegs:
                if omegadeg:
                    new_omegadegs.append(omegadeg[0])
            omegadegs = new_omegadegs
        else:
            omegadegs = []
    num_models = max(num_models, len(betadegs), len(omegadegs))
    #
    # damping
    #
    if not kwargs['artificial_damping1']:
        kwargs['damping_factor1'] = None
    if not kwargs['artificial_damping2']:
        kwargs['damping_factor2'] = None
    #
    std_name = find_std_name(kwargs.get('std_name'))
    #
    dirname = os.path.join(TMP_DIR, std_name, 'outputs')
    if not os.path.isdir(dirname):
        os.makedirs(dirname)
    #
    #
    std = study.Study()
    __main__.stds[std_name] = std
    std.name = std_name
    std.rebuild()
    for cc in std.ccs:
        cc.rebuilt = False
        cc.created_model = False
    for i in range(1, num_models + 1):
        cc = conecyl.ConeCyl()
        for attr in ccattrs:
            setattr(cc, attr, kwargs[attr])
        # adding load asymmetry
        i_model = i - 1
        if i_model < len(betadegs):
            cc.betadeg = betadegs[i_model]
        if i_model < len(omegadegs):
            cc.omegadeg = omegadegs[i_model]
        # adding perturbation loads
        i_model = i + num_params['pl']
        if i_model < len(pl_table):
            for j in range(imp_num['pl']):
                theta = pl_table[0][j]
                pt = pl_table[1][j]
                pltotal = pl_table[i_model][j]
                cc.impconf.add_pload(theta, pt, pltotal, step=pload_step)
        # adding single buckles
        i_model = i + num_params['d']
        if i_model < len(d_table):
            for j in range(imp_num['d']):
                theta0 = d_table[0][j]
                z0 = d_table[1][j]
                a = d_table[2][j]
                b = d_table[3][j]
                wb = d_table[i_model][j]
                cc.impconf.add_dimple(theta0, z0, a, b, wb)
        # adding axisymmetrics
        i_model = i + num_params['ax']
        if i_model < len(ax_table):
            for j in range(imp_num['ax']):
                z0 = ax_table[0][j]
                b = ax_table[1][j]
                wb = ax_table[i_model][j]
                cc.impconf.add_axisymmetric(z0, b, wb)
        # adding linear buckling mode-shaped imperfections
        i_model = i + num_params['lbmi']
        if i_model < len(lbmi_table):
            for j in range(imp_num['lbmi']):
                mode = lbmi_table[0][j]
                scaling_factor = lbmi_table[i_model][j]
                cc.impconf.add_lbmi(mode, scaling_factor)
        # adding cutouts
        i_model = i + num_params['cut']
        if i_model < len(cut_table):
            for j in range(imp_num['cut']):
                theta = cut_table[0][j]
                pt = cut_table[1][j]
                numel = cut_table[2][j]
                d = cut_table[i_model][j]
                cc.create_cutout(theta, pt, d, numel)
        std.add_cc(cc)
    std.create_models(write_input_files=False)
    #for i in range(pload_num):
    #    num_models = max(len(pl_table),len(d_table),len(cut_table))
    return
Пример #4
0
def create_study(**kwargs):
    # setting defaults
    pl_table = kwargs.get('pl_table')
    cb_table = kwargs.get('cb_table')
    pload_step = kwargs.get('pload_step')
    d_table = kwargs.get('d_table')
    ax_table = kwargs.get('ax_table')
    lbmi_table = kwargs.get('lbmi_table')
    cut_table = kwargs.get('cut_table')

    ppi_enabled = kwargs.get('ppi_enabled')
    ppi_extra_height = kwargs.get('ppi_extra_height')
    ppi_table = kwargs.get('ppi_table')
    ffi_scalings = kwargs.get('ffi_scalings')
    while len(ffi_scalings) > 0 and ffi_scalings[-1] in [(0, False), False]:
        ffi_scalings = ffi_scalings[:-1]
    betadeg = kwargs.get('betadeg', 0.)
    omegadeg = kwargs.get('omegadeg', 0.)
    betadegs = kwargs.get('betadegs')
    omegadegs = kwargs.get('omegadegs')

    imp_num = {}
    imp_num['pl'] = kwargs.get('pl_num')
    imp_num['cbi'] = kwargs.get('cb_num')
    imp_num['d'] = kwargs.get('d_num')
    imp_num['ax'] = kwargs.get('ax_num')
    imp_num['lbmi'] = kwargs.get('lbmi_num')
    imp_num['cut'] = kwargs.get('cut_num')
    imp_tables = {}
    imp_tables['pl'] = pl_table
    imp_tables['cbi'] = cb_table
    imp_tables['d'] = d_table
    imp_tables['ax'] = ax_table
    imp_tables['lbmi'] = lbmi_table
    imp_tables['cut'] = cut_table
    num_params = {}
    num_params['pl'] = 2
    num_params['cbi'] = 2
    num_params['d'] = 4
    num_params['ax'] = 2
    num_params['lbmi'] = 1
    num_params['cut'] = 3
    num_models = 1
    for k in ['pl', 'cbi', 'd', 'ax', 'lbmi', 'cut']:
        if imp_num[k] == 0:
            continue
        imp_table = imp_tables[k]
        num_models = max(num_models, len(imp_table) - (num_params[k] + 1))
    num_models = max(num_models, len(ffi_scalings))
    #
    # Cleaning up input values
    #
    # laminate
    laminate = np.atleast_2d([i for i in kwargs.get('laminate') if i])
    kwargs['laminate'] = laminate
    kwargs['stack'] = [float(i) for i in laminate[:, 2] if i != '']
    stack = kwargs['stack']
    kwargs['laminapropKeys'] = [
        i if i != '' else laminate[0, 0] for i in laminate[:len(stack), 0]
    ]
    kwargs['plyts'] = [
        float(i) if i != '' else float(laminate[0, 1])
        for i in laminate[:len(stack), 1]
    ]
    #TODO currently only one allowable is allowed for stress analysis
    kwargs['allowables'] = [kwargs['allowables'] for _ in stack]
    #allowablesKeys = [float(i) if i != '' else laminate[0,3] \
    #         for i in laminate[:len(stack),1]]
    #
    # load asymmetry
    #
    #TODO list comprehension for these guys below
    la = kwargs.get('la')
    if la == 0:
        betadegs = []
        omegadegs = []
    elif la == 1:
        betadegs = [betadeg for i in range(num_models)]
        omegadegs = [omegadeg for i in range(num_models)]
    elif la == 2:
        if betadegs is not None:
            new_betadegs = []
            for betadeg in betadegs:
                if betadeg:
                    new_betadegs.append(betadeg[0])
            betadegs = new_betadegs
        else:
            betadegs = []
        if omegadegs is not None:
            new_omegadegs = []
            for omegadeg in omegadegs:
                if omegadeg:
                    new_omegadegs.append(omegadeg[0])
            omegadegs = new_omegadegs
        else:
            omegadegs = []
    num_models = max(num_models, len(betadegs), len(omegadegs))
    #
    # damping
    #
    if not kwargs['artificial_damping1']:
        kwargs['damping_factor1'] = None
    if not kwargs['artificial_damping2']:
        kwargs['damping_factor2'] = None
    #
    std_name = find_std_name(kwargs.get('std_name'))
    #
    dirname = os.path.join(TMP_DIR, std_name, 'outputs')
    if not os.path.isdir(dirname):
        os.makedirs(dirname)
    #
    #
    std = study.Study()
    __main__.stds[std_name] = std
    std.name = std_name
    std.rebuild()
    for cc in std.ccs:
        cc.rebuilt = False
        cc.created_model = False
    for i in range(1, num_models + 1):
        cc = conecyl.ConeCyl()
        for attr in ccattrs:
            setattr(cc, attr, kwargs[attr])
        # adding load asymmetry
        i_model = i - 1
        if i_model < len(betadegs):
            cc.betadeg = betadegs[i_model]
        if i_model < len(omegadegs):
            cc.omegadeg = omegadegs[i_model]
        # adding perturbation loads
        i_model = i + num_params['pl']
        if i_model < len(pl_table):
            for j in range(imp_num['pl']):
                theta = pl_table[0][j]
                pt = pl_table[1][j]
                pltotal = pl_table[i_model][j]
                cc.impconf.add_pload(theta, pt, pltotal, step=pload_step)
        #Adding constant buckle
        i_model = i + num_params['cbi']
        if i_model < len(cb_table):
            for j in range(imp_num['cbi']):
                theta = cb_table[0][j]
                pt = cb_table[1][j]
                cbtotal = cb_table[i_model][j]
                cc.impconf.add_cb(theta, pt, cbtotal, step=pload_step)
        # adding single buckles
        i_model = i + num_params['d']
        if i_model < len(d_table):
            for j in range(imp_num['d']):
                theta0 = d_table[0][j]
                z0 = d_table[1][j]
                a = d_table[2][j]
                b = d_table[3][j]
                wb = d_table[i_model][j]
                cc.impconf.add_dimple(theta0, z0, a, b, wb)
        # adding axisymmetrics
        i_model = i + num_params['ax']
        if i_model < len(ax_table):
            for j in range(imp_num['ax']):
                z0 = ax_table[0][j]
                b = ax_table[1][j]
                wb = ax_table[i_model][j]
                cc.impconf.add_axisymmetric(z0, b, wb)
        # adding linear buckling mode-shaped imperfections
        i_model = i + num_params['lbmi']
        if i_model < len(lbmi_table):
            for j in range(imp_num['lbmi']):
                mode = lbmi_table[0][j]
                scaling_factor = lbmi_table[i_model][j]
                cc.impconf.add_lbmi(mode, scaling_factor)
        # adding cutouts
        i_model = i + num_params['cut']
        if i_model < len(cut_table):
            for j in range(imp_num['cut']):
                theta = cut_table[0][j]
                pt = cut_table[1][j]
                numel = cut_table[2][j]
                d = cut_table[i_model][j]
                cutout = cc.impconf.add_cutout(theta,
                                               pt,
                                               d,
                                               numel_radial_edge=numel)
        ## adding ply piece imperfection
        if ppi_enabled:
            info = []
            for row in ppi_table:
                if row is False:
                    continue  # False may be appended if there is only one row
                keys = [
                    'starting_position', 'rel_ang_offset', 'max_width',
                    'eccentricity'
                ]
                try:
                    info.append(
                        dict((key, float(row[i])) for i, key in enumerate(keys)
                             if row[i] != ''))
                except ValueError, e:
                    raise ValueError(
                        'Invalid non-numeric value in Ply Piece Imperfection table:'
                        + e.message.split(':')[-1])
            cc.impconf.add_ppi(info, ppi_extra_height)
        # adding fiber fraction imperfection
        i_model = i - 1
        if i_model < len(ffi_scalings):
            global_sf, use_ti = ffi_scalings[i_model]
            if global_sf == 0:
                global_sf = None
            if use_ti or (global_sf is not None):
                cc.impconf.add_ffi(nominal_vf=kwargs['ffi_nominal_vf'],
                                   E_matrix=kwargs['ffi_E_matrix'],
                                   nu_matrix=kwargs['ffi_nu_matrix'],
                                   use_ti=use_ti,
                                   global_sf=global_sf)
        std.add_cc(cc)