Beispiel #1
0
from __future__ import division, print_function
import numpy as np
from os import sys
sys.path.append(r"C:\Users\nguarinz\workspace\FEM_PYTHON\main")
from datetime import datetime
import matplotlib.pyplot as plt
import preprocesor as pre
import postprocesor as pos
import assemutil as ass
import solutil as sol

start_time = datetime.now()

#%% PRE-PROCESSING
nodes, mats, elements, loads = pre.readin(folder="./")
DME, IBC, neq = ass.DME(nodes, elements)
print("Number of nodes: {}".format(nodes.shape[0]))
print("Number of elements: {}".format(elements.shape[0]))
print("Number of equations: {}".format(neq))

#%% SYSTEM ASSEMBLY
KG = ass.assembler(elements, mats, nodes, neq, DME)
RHSG = ass.loadasem(loads, IBC, neq)

#%% SYSTEM SOLUTION
UG = sol.static_sol(KG, RHSG)
if not (np.allclose(KG.dot(UG), RHSG)):
    print("The system is not in equilibrium!")
end_time = datetime.now()
print('Duration for system solution: {}'.format(end_time - start_time))
Beispiel #2
0
import matplotlib.pyplot as plt

start_time = datetime.now()
name = raw_input('Enter the job name: ')
#   MODEL ASSEMBLY
#
# Reads the model
nodes, mats, elements, loads = pre.readin()
# Activate to generate echo files
#pre.echomod(nodes, mats, elements, loads)
# Retrieves problem parameters
ne, nn, nm, nl, COORD = pre.proini(nodes, mats, elements, loads)
# Counts equations and creates BCs array IBC
neq, IBC = ass.eqcounter(nn, nodes)
# Computes assembly operator
DME, IELCON = ass.DME(IBC, ne, elements)
# Assembles Global Stiffness Matrix KG
KG = ass.matassem(IBC, mats, elements, nn, ne, neq, COORD, DME, IELCON)
# Assembles Global Rigth Hand Side Vector RHSG
RHSG = ass.loadasem(loads, IBC, neq, nl)

#   SYSTEM SOLUTION
#
# Solves the system
UG = np.linalg.solve(KG, RHSG)
print(np.allclose(np.dot(KG, UG), RHSG))
end_time = datetime.now()
print('Duration for system solution: {}'.format(end_time - start_time))

#   POST-PROCCESSING
#
Beispiel #3
0
def Struct_DYN(folder):
    """  
    Parameters:
    ----------
    folder = Location of input files
    """
    warnings.filterwarnings("ignore")
    #--------------------------------------------------------------------------------------------------------------------------------------
    # Pre-processing
    inipar, nodes, mats, elements, Nodal_loads, Msvar, ILF, Seismo_signal, const = pre.readin(
        folder)
    ninc, T, dt, ac, theta = pre.intparams(inipar)
    DME, IBC, neq = ass.DME(nodes, elements)
    const = cst.IBC_const(IBC, const)
    #--------------------------------------------------------------------------------------------------------------------------------------
    # System assembly
    Up, Vp = sol.inicond_U_V(neq)
    KG, MG, CG, Msvar, IGF, ILF = ass.assembler(inipar, Up, Msvar, ILF,
                                                elements, mats, nodes, neq,
                                                DME, ac, const)
    cst_neq, neq = cst.neq_cst(const, neq)
    Up, Vp = sol.inicond_U_V(
        cst_neq)  # New initial conditions after constraints
    Tfund, Tmin = modal.eigen(inipar, MG, KG)
    RHSG, DeltaT, ninc, inipar = ass.loadasem(IBC, MG, Seismo_signal,
                                              Nodal_loads, neq, ninc, inipar,
                                              Tmin, const)
    ninc, T, dt, ac, theta = pre.intparams(inipar)
    KG, MG, CG, Msvar, IGF, ILF = ass.assembler(inipar, Up, Msvar, ILF,
                                                elements, mats, nodes, neq,
                                                DME, ac, const)
    print("----------------------")
    print("Number of nodes: {}".format(nodes.shape[0]))
    print("Number of elements: {}".format(len(elements)))
    print("Number of equations: {}".format(neq))
    print("Number of equations after constraints: {}".format(cst_neq))
    print("----------------------")
    print("Natural periods of the system : ", Tfund)
    print("----------------------")
    print("Time step for solution: {} sec".format(DeltaT))
    print("Number of time increments: {}".format(ninc))
    print("----------------------")
    #--------------------------------------------------------------------------------------------------------------------------------------
    # System solution
    start_time = datetime.now()
    U, MvarsGen, ILFGen = sol.system_sol(inipar, Up, Vp, neq, RHSG, MG, KG, CG,
                                         DME, Msvar, ILF, elements, mats,
                                         nodes, ac, const, cst_neq)
    end_time = datetime.now()
    print("Duration for the system's solution: {}".format(end_time -
                                                          start_time))
    #--------------------------------------------------------------------------------------------------------------------------------------
    # Post-processing
    start_time = datetime.now()
    U = cst.Posproc_disp_cst(neq, ninc, const, U)
    end_time = datetime.now()
    print('Duration for post processing: {}'.format(end_time - start_time))
    print("----------------------")
    print('Analysis terminated successfully!')
    print("----------------------")
    return (U, folder, IBC, nodes, elements, ninc, T, MvarsGen, ILFGen)