-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Su Tian
authored and
Su Tian
committed
Aug 12, 2020
0 parents
commit 8bd7efb
Showing
41 changed files
with
3,493 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| import os | ||
| import sys | ||
| import traceback | ||
| import datetime as dt | ||
| import subprocess as sbp | ||
| import msgpi.presg as psg | ||
| import msgpi.sg as sgm | ||
| import msgpi.io.iosc as miosc | ||
| import msgpi.io.iovabs as miovabs | ||
|
|
||
|
|
||
| def solve(sg_xml, analysis, solver, scrnout=True): | ||
| """ | ||
| Parameters | ||
| ---------- | ||
| sg_xml : str | ||
| File name of SG design parameters (XML format) | ||
| analysis : str | ||
| Analysis to be carried out | ||
| h - homogenization | ||
| d - dehomogenization/localization/recover | ||
| f - initial failure strength | ||
| fe - initial failure envelope | ||
| fi - initial failure indices and strength ratios | ||
| solver : str | ||
| Format of the generated input file ('vabs' or 'swiftcomp') | ||
| """ | ||
|
|
||
| # Preprocess | ||
| sg_in, smdim = psg.preSG(sg_xml, analysis, solver) | ||
|
|
||
| # Solve | ||
| run(sg_in, analysis, solver, smdim, scrnout) | ||
|
|
||
| # Parse results | ||
| print(' - reading results...') | ||
| if analysis == 'h': | ||
| if solver == 'vabs': | ||
| sm = miovabs.readVABSOutHomo(sg_in + '.k') | ||
| elif solver == 'swiftcomp': | ||
| sm = miosc.readSCOutHomo(sg_in + '.k', smdim) | ||
| return sm | ||
| elif analysis == 'd': | ||
| pass | ||
| elif 'f' in analysis: | ||
| results = miosc.readSCOutFailure(sg_in, analysis) | ||
| return results | ||
|
|
||
|
|
||
| def run(input_name, analysis, solver, smdim, scrnout=True): | ||
| """ Run codes | ||
| Parameters | ||
| ---------- | ||
| solver : str | ||
| Excect command string of the code ('vabs' or 'swiftcomp') | ||
| input_name : str | ||
| Name of the input file | ||
| analysis : str | ||
| Analysis to be carried out | ||
| h - homogenization | ||
| d or l - dehomogenization/localization/recover | ||
| f - initial failure strength | ||
| fe - initial failure envelope | ||
| fi - initial failure indices and strength ratios | ||
| smdim : int | ||
| Dimension of the macroscopic structural model | ||
| :param scrnout: Print solver messages | ||
| :type scrnout: bool | ||
| """ | ||
| try: | ||
| analysis_long = { | ||
| 'h': 'homogenization', | ||
| 'ha': 'homogenization aperiodic', | ||
| 'd': 'recover', | ||
| 'l': 'dehomogenization', | ||
| 'la': 'dehomogenization aperiodic', | ||
| 'lg': 'dehomogenization gmsh format', | ||
| 'lag': 'dehomogenization aperiodic gmsh format', | ||
| 'f': 'initial failure strength', | ||
| 'fe': 'initial failure envelope', | ||
| 'fi': 'initial failure indices strength ratios' | ||
| } | ||
| msg = ' - running {cn} for {an}...\n' | ||
|
|
||
| if solver == 'vabs': | ||
| solver = solver + 'iii' | ||
| cmd = [solver, input_name] | ||
|
|
||
| if solver == 'swiftcomp': | ||
| cmd.append(str(smdim) + 'D') | ||
| if 'd' in analysis: | ||
| analysis = analysis.replace('d', 'l') | ||
| cmd.append(analysis.upper()) | ||
|
|
||
| cmd = ' '.join(cmd) | ||
|
|
||
| # try: | ||
| if scrnout: | ||
| sys.stdout.write(msg.format( | ||
| cn=solver, an=analysis_long[analysis] | ||
| )) | ||
| sys.stdout.flush() | ||
| sbp.call(cmd) | ||
| else: | ||
| FNULL = open(os.devnull, 'w') | ||
| sbp.call(cmd, stdout=FNULL, stderr=sbp.STDOUT) | ||
| # except: | ||
| # sys.stdout.write('failed\n') | ||
| # sys.stdout.flush() | ||
| # return | ||
| # else: | ||
| # sys.stdout.write('done\n') | ||
| # sys.stdout.flush() | ||
| except: | ||
| e = traceback.format_exc() | ||
| print(e) | ||
|
|
||
|
|
||
| def runBatch(): | ||
|
|
||
| return |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| import csv | ||
| import os | ||
| import sys | ||
| import numpy as np | ||
| import xml.etree.ElementTree as et | ||
|
|
||
|
|
||
| class Layer(object): | ||
| def __init__(self): | ||
| self.material = '' | ||
| self.thickness = 0 | ||
| self.lamina = None | ||
| self.angle = 0 | ||
| self.begin = 0 | ||
| self.end = 0 | ||
|
|
||
| def __str__(self): | ||
| return 'begin: {0}, end: {1}, material: {2}, thickness: {3}, angle: {4}'.format( | ||
| self.begin, self.end, self.material, self.thickness, self.angle | ||
| ) | ||
|
|
||
| def readIXGENLine(self, line, cs, fmt=0, tb=''): | ||
| line = line.split() | ||
| if (fmt == 0): | ||
| self.material = ' '.join(line[5:-3]) | ||
| self.thickness = line[-3] | ||
| self.angle = float(line[-2]) | ||
| if (cs == 1): | ||
| self.begin = float(line[1]) | ||
| self.end = float(line[2]) | ||
| elif (cs == 2): | ||
| self.begin = float(line[3]) | ||
| self.end = float(line[4]) | ||
| elif (fmt == 1): | ||
| self.material = ' '.join(line[4:-1]) | ||
| self.thickness = line[-1] | ||
| if (cs == 1): | ||
| if (tb == 'top'): | ||
| self.end = float(line[0]) | ||
| elif (tb == 'bottom'): | ||
| self.end = float(line[1]) | ||
| elif (cs == 2): | ||
| if (tb == 'top'): | ||
| self.end = float(line[2]) | ||
| elif (tb == 'bottom'): | ||
| self.end = float(line[3]) | ||
| elif (fmt == 2): | ||
| self.material = ' '.join(line[1:-2]) | ||
| self.thickness = line[-2] | ||
| self.angle = float(line[-1]) | ||
|
|
||
|
|
||
| class Layup(object): | ||
| def __init__(self, name=''): | ||
| self.name = name | ||
| self.layers = [] | ||
|
|
||
|
|
||
| class CrossSection(object): | ||
| """ Stores all information of a cross section. | ||
| This object is used to store and pass data of a cross section | ||
| between VABS/SC, GEBT, and preprocessors. | ||
| """ | ||
|
|
||
| def __init__(self, name): | ||
| self.name = name | ||
|
|
||
| self.name_template = '' #: Base name of the main input file template | ||
| self.name_baseline = '' #: Base name of the base lines file | ||
| self.name_layup = '' #: Base name of the layups file | ||
| self.fn_vabs_in = self.name + '.sg' #: File name of the VABS input | ||
| self.fn_sc_in = self.name + '.sg' #: File name of the SwiftComp input | ||
| # self.fn_gmsh_msh = self.name + '.msh' #: File name of the Gmsh mesh file | ||
|
|
||
| self.num_layertypes = 0 #: Number of layer types | ||
| self.layertypes = {} #: Layer types {lid: [mid, ply angle], ...} | ||
| self.element_layertype = {} | ||
| self.element_theta1 = {} | ||
|
|
||
| self.pitch = 0.0 #: Pitch angle of the cross section | ||
| self.k11 = 0.0 #: Initial twist k_{11} | ||
| self.k12 = 0.0 #: Initial curvature k_{12} | ||
| self.k13 = 0.0 #: Initial curvature k_{13} | ||
| self.cos11 = 1.0 #: Obliqueness. Cosine of the angle between y_1 and x_1 | ||
| self.cos21 = 0.0 #: Obliqueness. Cosine of the angle between y_2 and x_1 | ||
|
|
||
| self.trapeze = 0 #: Flag for trapeze effect | ||
| self.vlasov = 0 #: Flag for Vlasov model | ||
|
|
||
| # Effective properties | ||
| self.mc = None #: Mass center | ||
| self.gc = None #: Geometric center | ||
| self.tc = None #: Tension center | ||
| self.sc = None #: Shear center | ||
|
|
||
| self.mass = None #: Mass matrix (6x6) | ||
| self.masc = None #: Mass matrix at mass center (6x6) | ||
| self.eden = None #: Effective density (mass per unit length) | ||
| self.ecsm = None #: Effective classical stiffness matrix (4x4) | ||
| self.eccm = None #: Effective classical compliance matrix (4x4) | ||
| self.etsm = None #: Effective timoshenko stiffness matrix (6x6) | ||
| self.etcm = None #: Effective timoshenko compliance matrix (6x6) | ||
|
|
||
| # Global results for recovery/dehomogenization | ||
| self.gdisplacements = np.zeros(3) #: Global displacements [u1, u2, u3] | ||
| #: Global rotations [[c11, c12, c13], [c21, c22, c23], [c31, c32, c33]] | ||
| self.grotations = np.eye(3) | ||
| self.gforces = np.zeros(3) #: Global forces (VABS) [F1, F2, F3] | ||
| self.gmoments = np.zeros(3) #: Global moments (VABS) [M1, M2, M3] | ||
| #: Global distributed forces (VABS) [[f1, f2, f3], [d1f1, d1f2, d1f3], [d2f1, d2f2, d2f3], [d3f1, d3f2, d3f3]] | ||
| self.gdforces = np.zeros((4, 3)) | ||
| #: Global distributed moments (VABS) [[m1, m2, m3], [d1m1, d1m2, d1m3], [d2m1, d2m2, d2m3], [d3m1, d3m2, d3m3]] | ||
| self.gdmoments = np.zeros((4, 3)) | ||
| #: Indicate whether the generalized loads are stresses or strains (SwiftComp) | ||
| self.gmeasure = 'stress' | ||
| #: Global straints (SwiftComp) [] | ||
| self.gloads = np.zeros(6) | ||
|
|
||
| #: Load for the horizontal axis for failure envelope (SwiftComp) | ||
| self.feaxis1 = '' | ||
| #: Load for the vertical axis for failure envelope (SwiftComp) | ||
| self.feaxis2 = '' | ||
| #: Number of evaluation points along each axis for failure envelope (SwiftComp) | ||
| self.fendiv = 10 | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.