Source code for Pabq.common_tools.abq_tools

# code to be evaluated for max field output value
# https://gist.github.com/crmccreary/1074551

"""
Module containing tools for Abaqus cae.

"""

from material import *
from part import *
from section import *
from interaction import *
from step import *
from job import *
from mesh import *

import os
import odbAccess
from abaqusConstants import *
import string
import pickle


[docs]class GeneralModel(object): """Class containing basic functionality for modeller scrtipts. Contains tools like 'save', 'submit', 'open_odb' etc. """
[docs] def __init__( self, add=None, solver=None, direct_submit=None, ncpus=None, write_input=None, save_cae=None, mdl_id=None ): """ Initialise a general model. Some basic properties are given for the model, like the basename and the solver type. Parameters ---------- add : bool, optional Is the current model going to be added to the Abaqus model database (mdb), leaving any preexisting models intact or is is a single model? In the second case, a new mdb is created and the default initial model "Model-1" is renamed accordingly. The second case is the default. solver : str, "implicit" or "explicit", optional Set the type of the solver that is going to be used. direct_submit : bool, optional Is the model going to me submitted directly after creation (True) or not (False). In the second case, make sure that the .cae and/or the .inp files are written, otherwise the modeller is rendered useless (no output). Default is True write_input : bool, optional Should the input file be written to file? Default is True ncups : int or "availabl", optional The number of parallel cpus to be used by the solver. It cold either take an integer value or the string "available", in which case it will look for an environment variable "NCPUS" on the system. The default value is 1. save_cae : bool, optional Should the model database be saved in a .cae file? Default is True mdl_id : str, optional Set the basename of the model. It is used as model name, as base name for other entities (e.g. the job). Default is "general_model" """ # Set all values of the session to be described in the coordinate # system with findAt commands instead of masks. session.journalOptions.setValues(replayGeometry=COORDINATE, recoverGeometry=COORDINATE) # Set some defaults # Will the model be submitted for analysis? if direct_submit is None: self.direct_submit = True else: self.direct_submit = direct_submit # How many cpus are going to be used if the model is submitted directly # for analysis? if ncpus is None: self.ncpus = 1 elif ncpus == "available": if "NCPUS" in os.environ.keys(): self.ncpus = int(os.environ["NCPUS"]) else: print("The \"NCPUS\" variable was not found in the environment") else: self.ncpus = ncpus # Will the input file .inp be written? if write_input is None: self.write_input = True else: self.write_input = write_input # Will the model be saved to a .cae file? if save_cae is None: self.save_cae = True else: self.save_cae = save_cae # Set the general name of the model. This is used as a base name for # other sub-objects. Usually, it is regulated externally from the # parametric execution and it describes the parameter values of the # current model in the parametric table. if mdl_id is None: mdl_id = 'general_model' self.name = mdl_id # Names given to various objects throughout the model. The base name is # used with an appended extension. self.names = { "model": self.name, "job": self.name + "_job", } # Is the current model going to be added to the Abaqus model database # (mdb), leaving any preexisting models intact or is is a single model? # In the second case, a new mdb is created and the default initial # model "Model-1" is renamed accordingly. The second case is the # default. if add is None: add = False self.add = add if self.add: mdb.Model(self.name) else: # Start new model database. Mdb() # Change the pre-existing model name. mdb.models.changeKey( fromName='Model-1', toName=self.name ) # Assign model object to a variable. self.mdl = mdb.models[self.name] # Set the solver to be used, "implicit" or "explicit". The default is # "implicit" if solver is None: solver = "implicit" self.solver = solver
[docs] def w_input(self): mdb.jobs[self.names["job"]].writeInput()
[docs] def save(self): mdb.saveAs(pathName=self.name + '.cae')
[docs] def submit(self, job=None): if job is None: job = mdb.jobs[self.names["job"]] # Submit buckling job job.submit(consistencyChecking=OFF) job.waitForCompletion() return
[docs] def open_odb(self): odb = odbAccess.openOdb(path=self.names["job"]+".odb", readOnly=True) return odb
[docs] @staticmethod def set_material(material_id): """ Create a dictionary with a material description. Parameters ---------- material_id : str ID of the material to be constructed. """ elasticity = { "table": ( (210000.0, 0.3), ) } density = { "table": ( (7.8e-09,), ) } plasticity = GeneralModel.plastic_table(material_id) material = { "elasticity": elasticity, "plasticity": {"table": plasticity["table"]}, "f_yield": plasticity["f_yield"], "density": density } return material
[docs] @staticmethod def plastic_table(material_id): plasticity_tables = {} # From the first batch of experiments plasticity_tables["100x100x4a_opp"] = { "f_yield": 467.806686073847, "table": ( (373.43631547085, 0), (392.970851225504, 0.000200451971084), (411.131017691171, 0.000438507587786), (428.066082818029, 0.000734072165102), (443.345652975648, 0.00109240400074), (456.918247553032, 0.001533007216262), (468.769327071082, 0.002041286581008), (478.831538956734, 0.002650443759378), (486.930823893333, 0.003356587016638), (493.363029680947, 0.004156124460515), (498.326978434551, 0.005040532548426), (502.339315603791, 0.005972136300958), (505.651018250467, 0.006960039058718), (508.434291007955, 0.007983713080771), (511.006611561743, 0.009031510696998), (513.321818681858, 0.010091206480344), (515.445775638692, 0.011154978501014), (517.414283682131, 0.012234151636168), (519.383049985771, 0.013319205262915), (521.312182441842, 0.014408976477184), (523.050550806222, 0.015510941844885), (524.730129395817, 0.016585454519036), (526.474557201175, 0.017676120066755), (528.165331114871, 0.018777041431015), (529.699726302101, 0.019874270674102), (531.279244911136, 0.020975952062276), (532.8881744504, 0.022054812200447), (534.389819231947, 0.023148566244053), (535.804160611812, 0.024241795418806), (537.314409554032, 0.025341865597852), (538.839916775104, 0.026442624750275), (540.149244809096, 0.02752028064664), (541.508608388936, 0.028610891461159), (542.898460607025, 0.029699306559004), (544.35664606531, 0.030797150034969), (545.582444366215, 0.031896729149712), (546.866999161205, 0.032966596906993), (548.253222823809, 0.034056154978516), (549.560163436199, 0.035151607060428), (550.753434453229, 0.036246396044449), (552.017134043043, 0.037341263284551), (553.319510557939, 0.038417310266565), (554.515804102943, 0.039504958107748), (555.655979904195, 0.040591392115276), (556.890869995904, 0.041684263885534), (558.16529101604, 0.042782262638475), (559.236978893757, 0.043856330370553), (560.370629685332, 0.04494141463413), (561.535357552213, 0.046032282722428), (562.732838254211, 0.047127478223954), (563.747469768428, 0.048220327482565), (564.892292604931, 0.049297273811132), (566.053960314743, 0.05038479313747), (567.193510675267, 0.05147851370485), (568.132600838333, 0.052567166167759), (569.268467525322, 0.053663938012566), (570.371495516159, 0.054739679852821), (571.389133923277, 0.055825952124363), (572.38087207864, 0.056920457022934), (573.462381158973, 0.05800476168728), (574.566761532847, 0.059107290375678), (575.487507558603, 0.060189118110548), (576.435949086156, 0.061275825664634), (577.541967560581, 0.062370980534642), (578.554858376878, 0.063469663448817), (579.487657224569, 0.064568940730094), (580.45716218613, 0.065647284451454), (581.493158849949, 0.066744143978849), (582.479082859013, 0.067839247530727), (583.327238985101, 0.068944445228136), (584.338276954489, 0.070052855467831), (585.341342178266, 0.071131680893893), (586.238939860013, 0.072229157475809), (587.085269564829, 0.073326366001809), (588.10621039725, 0.074428943457385), (589.083965264767, 0.075533838460821), (589.91737398542, 0.076620655030058), (590.726613530644, 0.077662738205716), (591.604449453406, 0.078575179653029), (592.312188777111, 0.07931159089281), ) } plasticity_tables["100x100x4a_adj"] = { "f_yield": 462.289079337569, "table": ( (380.674767115873, 0), (400.153269230093, 0.00019132836608), (417.32996344566, 0.000420565090937), (432.993355291109, 0.000716109722857), (446.265804357999, 0.001113547746088), (457.189914746895, 0.001626040446325), (466.342127876378, 0.002297240105834), (472.810793959955, 0.003067339640892), (477.125010010771, 0.003975675283538), (480.766536331587, 0.004966919768712), (483.829598864552, 0.006008607443721), (486.325900327403, 0.007094509325694), (488.514154559762, 0.008163066258797), (490.96117069434, 0.009252435243562), (493.152742451331, 0.010343059281566), (494.956244310742, 0.011432593126904), (496.958263703437, 0.012538869609012), (499.083619883617, 0.013612975635157), (500.941103359415, 0.014700047908894), (502.524171625476, 0.01578415813493), (504.385185243984, 0.01686962524236), (506.387500871044, 0.017967548856637), (507.958399179776, 0.019032344525351), (509.494605773501, 0.020106632935506), (511.262133603307, 0.021185688648738), (513.044726087832, 0.022264760703357), (514.466192951982, 0.023369572901021), (515.969770061488, 0.024413537557187), (517.686639597832, 0.025485061222305), (519.307256660799, 0.026565854033005), (520.514047920024, 0.027634089702001), (522.108541279714, 0.028731726444376), (523.694716943814, 0.029776363788385), (525.163901270969, 0.030851012277836), (526.294024278212, 0.031914573068349), (527.751830897576, 0.032985713439907), (529.455077447623, 0.034078278739), (530.644553796654, 0.035133455917571), (531.835833289686, 0.036197337691316), (533.251189510041, 0.03726464847277), (534.812236882371, 0.038339817470245), (535.857813453456, 0.039424076453715), (537.031494128635, 0.040471067318758), (538.595494225927, 0.041542614071943), (539.906769859236, 0.042613614920527), (540.804317559153, 0.04368204040953), (542.207903084023, 0.04477791273004), (543.57157676292, 0.04581828414259), (544.735195922689, 0.046891024295303), (545.688401317898, 0.047956230624864), (547.0231884546, 0.049025320217529), (548.361477474178, 0.050114301605323), (549.361667722946, 0.051167365794853), (550.382865111301, 0.052233714447141), (551.708575603893, 0.053302150325742), (552.985057083387, 0.054374449082288), (553.799643386474, 0.055454462626693), (554.862965022709, 0.056505576182522), (556.267778310998, 0.057578735581842), (557.362942173879, 0.058649616502485), (558.136953108632, 0.059721364347467), (559.412724560701, 0.060820114389914), (560.616045189455, 0.061864842977671), (561.585743163276, 0.062940772824378), (562.438558564162, 0.064011934819785), (563.637783045999, 0.065083784261829), (564.817525445938, 0.066187420258722), (565.642155002953, 0.06723613454929), (566.585058392929, 0.06831269902708), (567.786170498842, 0.069388463163211), (568.882117217718, 0.070467475560594), (569.557771688201, 0.071554219471576), (570.603938808283, 0.072614787105262), (571.769605065563, 0.073694633742018), (572.796370443901, 0.074776237564285), (573.522251926599, 0.075851529047184), (574.609492966747, 0.076955328494566), (575.712221568589, 0.078009562079207), (576.291649060737, 0.07870921214703), (576.760910892975, 0.079247945551507), ) } plasticity_tables["90x90x4a"] = { "f_yield": 434.324476123077, "table": ( (312.2481015, 0), (333.2725364, 0.0001), (353.345021, 0.0002), (372.1589049, 0.0004), (397.0990425, 0.0008), (411.2210499, 0.0011), (433.3087447, 0.0019), (446.5132532, 0.0032), (468.1238527, 0.0118), (478.8371029, 0.021), (489.1442425, 0.0302), (497.5897707, 0.0395), (506.2988453, 0.0488), (514.0637447, 0.0581), (521.0193253, 0.0673), (527.7538984, 0.0767), (534.3922261, 0.0861), (540.8474956, 0.0955), (546.6258455, 0.105), (551.9616813, 0.1145), (557.6676517, 0.1241), (564.0840393, 0.1337), ) } # From the second batch of experiments plasticity_tables["100x100x4b_opp"] = { "f_yield": 560.783998267618, "table": ( (318.00, 0.00000), (339.44, 0.00007), (360.63, 0.00013), (381.30, 0.00021), (401.43, 0.00030), (421.02, 0.00040), (439.86, 0.00052), (458.32, 0.00065), (476.31, 0.00080), (493.64, 0.00096), (510.38, 0.00115), (526.32, 0.00136), (541.36, 0.00160), (555.36, 0.00188), (568.85, 0.00218), (581.03, 0.00254), (591.46, 0.00295), (600.43, 0.00343), (607.94, 0.00398), (614.18, 0.00459), (619.26, 0.00528), (623.44, 0.00604), (626.73, 0.00684), (629.45, 0.00770), (631.62, 0.00858), (633.37, 0.00950), (634.92, 0.01044), (636.25, 0.01139), (637.68, 0.01237), (638.94, 0.01335), (640.37, 0.01433), (641.78, 0.01532), (643.14, 0.01632), (644.32, 0.01731), (645.33, 0.01830), (646.39, 0.01929), (647.39, 0.02030), (648.40, 0.02129), (649.49, 0.02229), (650.69, 0.02329), (651.89, 0.02428), (653.10, 0.02527), (654.14, 0.02626), (655.30, 0.02735), (656.24, 0.02834), (657.26, 0.02933), (658.01, 0.03032), (658.86, 0.03131), (659.83, 0.03229), (660.82, 0.03328), (661.88, 0.03428), (663.03, 0.03526), (664.12, 0.03625), (664.99, 0.03724), (665.89, 0.03822), (666.64, 0.03921), (667.37, 0.04019), (668.19, 0.04118), (669.20, 0.04218), (670.16, 0.04317), (671.25, 0.04415), (672.22, 0.04514), (673.13, 0.04613), (673.84, 0.04712), (674.64, 0.04811), (675.31, 0.04911), (676.14, 0.05010), (676.95, 0.05109), (677.90, 0.05209), (678.91, 0.05308), (679.87, 0.05408), (680.73, 0.05508), (681.46, 0.05608), (682.13, 0.05707), (682.85, 0.05807), (683.54, 0.05908), (684.38, 0.06008), (685.31, 0.06109), (686.31, 0.06209), (687.18, 0.06310), (688.03, 0.06411), (688.75, 0.06512), (689.34, 0.06612), (690.02, 0.06714), (690.71, 0.06815), (691.46, 0.06918), (692.36, 0.07020), (693.29, 0.07122), (694.22, 0.07224), (694.99, 0.07326), (695.71, 0.07428), (696.31, 0.07530), (696.89, 0.07633), (697.60, 0.07737), (698.17, 0.07805), (698.63, 0.07857), (699.21, 0.07908), (699.79, 0.07959), ) } plasticity_tables["100x100x4b_adj"] = { "f_yield": 540.267516382919, "table": ( (317.214045931238, 0), (339.405831957968, 0.000128280316584), (361.094139754129, 0.000182369622293), (382.347993841178, 0.000260661355608), (402.737107578553, 0.000357656551688), (422.485934339581, 0.000477940728734), (441.496986617866, 0.000616603143978), (459.73562237233, 0.000777511870068), (477.069692785333, 0.000951548529009), (493.637220179258, 0.001156382554084), (509.328907130105, 0.001383528427321), (524.085901318446, 0.001641524113195), (537.730140216298, 0.001936820835419), (550.948117879992, 0.002265940655031), (562.67434089319, 0.002647196790663), (572.76371788292, 0.003091740314129), (581.326644132961, 0.0035943796718), (588.684962083152, 0.004167634903635), (594.646940448655, 0.004805797652415), (599.51316941834, 0.005510123360234), (603.492662969197, 0.006273310405175), (606.694225829354, 0.007080288957726), (609.42479561735, 0.007928664560312), (611.755829123483, 0.008801001562212), (613.756045070784, 0.009705042372243), (615.555156548478, 0.010623136171243), (617.168001346922, 0.011551172959242), (618.653653972342, 0.012490993269426), (620.165768089564, 0.013442879475984), (621.607000754849, 0.014393215423183), (623.128289248503, 0.01534898274972), (624.584747672105, 0.016304544705523), (625.988923664852, 0.017256530426777), (627.381740956799, 0.018213905116622), (628.639917447367, 0.019172968369144), (629.902390215634, 0.020126093266217), (631.139503567681, 0.021081180206708), (632.311952476752, 0.022036436879375), (633.604636917447, 0.022989037267295), (634.897979423502, 0.023942784102264), (636.20243822997, 0.024894279775596), (637.480265886835, 0.025837201873493), (638.677072342324, 0.026783002829124), (639.76207851438, 0.027727375202906), (640.816258463253, 0.028669618545183), (641.986661387846, 0.029615084708348), (643.030047007087, 0.030561032315016), (644.164269868756, 0.03151016693588), (645.348623220769, 0.032453612598182), (646.518248917166, 0.0333994242988), (647.633039960756, 0.034343725055239), (648.706165692154, 0.035287027239933), (649.757805675675, 0.036228136346163), (650.716889455451, 0.037169798836701), (651.645081455586, 0.038116748979881), (652.641999285997, 0.039060273600564), (653.659283308415, 0.04000524431407), (654.778168597836, 0.040950317497757), (655.83057657221, 0.041896753552655), (656.888653251228, 0.042842769420914), (657.932984331904, 0.043791823431638), (658.822415414907, 0.044736290666332), (659.741499499916, 0.045678537039514), (660.567925130223, 0.046629434199734), (661.459551328403, 0.047579326167693), (662.394632445749, 0.048531072790063), (663.400281919757, 0.049484195182648), (664.393491776998, 0.050437994163537), (665.408281500913, 0.051389290206588), (666.394408559505, 0.05233940960761), (667.254146738194, 0.053294089869241), (668.04714997502, 0.054248539429867), (668.854934259729, 0.055205982672302), (669.649449503395, 0.056163495316907), (670.524884604315, 0.057119897957182), (671.502583780803, 0.058085144724931), (672.417762097209, 0.05904497343495), (673.321887837545, 0.060005939431736), (674.26621773751, 0.060971040858058), (675.044456900674, 0.061932357869854), (675.817779915348, 0.062895085270306), (676.566517073495, 0.063862600361283), (677.376581186269, 0.064836565571643), (678.172520639062, 0.065803023100965), (679.081031514337, 0.066774842218079), (679.968983839923, 0.067754993367822), (680.867716637507, 0.068728050970386), (681.627961539184, 0.069699140753234), (682.516531317919, 0.070680211753165), (683.203995815891, 0.071659159758988), (683.954079928516, 0.07263632507472), (684.645975028604, 0.073613501546139), (685.398517681705, 0.07459228175064), (686.26668849487, 0.075577531973091), (687.132497284341, 0.076565925254473), (687.96438020337, 0.077550141038776), (688.749715589807, 0.078462534016732), (689.317135622452, 0.079196013392186), ) } plasticity_tables["100x100x3b_opp"] = { "f_yield": 537.977920445402, "table": ( (351.61, 0.0000), (375.69, 0.0001), (398.82, 0.0002), (420.71, 0.0003), (441.45, 0.0004), (460.97, 0.0006), (479.27, 0.0008), (496.17, 0.0010), (511.64, 0.0013), (525.52, 0.0016), (537.58, 0.0020), (549.02, 0.0024), (557.64, 0.0030), (564.60, 0.0036), (570.01, 0.0043), (574.28, 0.0050), (577.49, 0.0059), (580.12, 0.0067), (582.22, 0.0076), (584.08, 0.0085), (585.80, 0.0095), (587.48, 0.0104), (589.08, 0.0113), (590.69, 0.0123), (592.37, 0.0132), (593.89, 0.0142), (595.34, 0.0151), (596.66, 0.0161), (598.02, 0.0170), (599.25, 0.0179), (600.64, 0.0189), (601.98, 0.0198), (603.44, 0.0208), (604.91, 0.0217), (606.28, 0.0226), (607.55, 0.0236), (608.76, 0.0245), (609.93, 0.0254), (611.00, 0.0263), (612.19, 0.0273), (613.46, 0.0282), (614.66, 0.0291), (616.02, 0.0300), (617.35, 0.0310), (618.47, 0.0319), (619.53, 0.0328), (620.56, 0.0337), (621.56, 0.0347), (622.70, 0.0356), (623.72, 0.0365), (624.91, 0.0374), (626.08, 0.0384), (627.28, 0.0393), (628.31, 0.0402), (629.28, 0.0411), (630.19, 0.0421), (631.11, 0.0430), (632.03, 0.0439), (633.04, 0.0448), (634.15, 0.0458), (635.27, 0.0467), (636.29, 0.0476), (637.33, 0.0485), (638.25, 0.0495), (639.04, 0.0504), (639.86, 0.0513), (640.74, 0.0523), (641.65, 0.0532), (642.56, 0.0541), (643.69, 0.0551), (644.66, 0.0560), (645.62, 0.0569), (646.47, 0.0578), (647.24, 0.0588), (647.99, 0.0597), (648.83, 0.0606), (649.61, 0.0616), (650.59, 0.0625), (651.57, 0.0635), (652.49, 0.0644), (653.39, 0.0653), (654.24, 0.0663), (654.92, 0.0672), (655.68, 0.0681), (656.39, 0.0691), (657.16, 0.0700), (658.06, 0.0710), (658.97, 0.0719), (659.92, 0.0729), (660.74, 0.0738), (661.48, 0.0748), (662.19, 0.0757), (662.85, 0.0767), (663.59, 0.0776), (664.34, 0.0786), (664.84, 0.0791), (665.39, 0.0795), (666.04, 0.0800), ) } plasticity_tables["100x100x3b_adj"] = { "f_yield": 537.759508389898, "table": ( (351.366455298604, 0), (374.714296089963, 0942672726E-05), (397.305144966293, 0.000173871869943), (418.935388378582, 0.000276992066789), (439.467688675606, 0.000406046306672), (458.842281373572, 0.000557079058465), (477.190208134372, 0.000740953897249), (494.165458404959, 0.000958118702858), (509.667209595246, 0.001217434063524), (523.512538842014, 0.001527256420165), (535.53927859646, 0.00190724679909), (546.540955743263, 0.002366857229399), (554.930936134551, 0.002927055876761), (561.133871644088, 0.003578536204347), (565.76978310959, 0.00430819191797), (569.325874756206, 0.005098607630478), (572.081980755752, 0.00593573324698), (574.363607924114, 0.00680576344731), (576.358319076052, 0.007698336336568), (578.133025714232, 0.008604755141282), (579.875763072159, 0.009521453705848), (581.609261783619, 0.010442598594106), (583.317999677471, 0.011371517151525), (584.98342039759, 0.012296622301192), (586.631697715229, 0.013222893472754), (588.227162119825, 0.014144506996543), (589.791184567808, 0.015070610639634), (591.212593326287, 0.015986829704172), (592.659560093493, 0.016905481925662), (594.107149269011, 0.017821534631712), (595.585171418955, 0.018735707915885), (597.181398676872, 0.019654454549507), (598.703457356223, 0.020565725364004), (600.132250875497, 0.021472380304156), (601.555721139392, 0.022381372060523), (602.919823950635, 0.023286325811491), (604.238760034631, 0.024191429779429), (605.545528088801, 0.02509528364053), (606.809869711142, 0.025999297477651), (608.177360877617, 0.026901857254472), (609.518376618302, 0.027801507794312), (610.862577107322, 0.028700802493693), (612.210464599589, 0.029600512863461), (613.512002088847, 0.030499031588795), (614.678347515439, 0.031397316885258), (615.81939973569, 0.032297844388523), (616.972251360579, 0.033200424287882), (618.147149819473, 0.034102320284614), (619.313903217555, 0.035005313699307), (620.518499093425, 0.035908831127834), (621.783543856913, 0.036808253806424), (622.936507639151, 0.03770757754034), (624.115627236792, 0.038612647043461), (625.205081437402, 0.039510897483178), (626.221278772313, 0.040412089445231), (627.264598643717, 0.041318427540861), (628.273432652686, 0.042220377797537), (629.315094537489, 0.043124518755771), (630.402994531187, 0.044032842313386), (631.527568772772, 0.044937220077101), (632.650420582342, 0.045841254909539), (633.691389843562, 0.046749602916416), (634.647102855211, 0.047652556694546), (635.592381782703, 0.048560961658703), (636.505927481697, 0.049469989814622), (637.400062271208, 0.050377747930557), (638.407291911428, 0.051284892544246), (639.437734272205, 0.052200082865039), (640.410710439797, 0.053111370475467), (641.417282812446, 0.054018514678375), (642.405167979268, 0.054930118771397), (643.315659391148, 0.055840348978144), (644.136858386396, 0.056750052813029), (644.966076152339, 0.057665882877167), (645.820244716298, 0.058580939435367), (646.710801977495, 0.059493843166874), (647.645205232788, 0.060411194193848), (648.588050861533, 0.061328000867522), (649.533543570977, 0.062247007910496), (650.452819351304, 0.063168792678375), (651.275145816219, 0.064086382986581), (652.085489695402, 0.065003003559014), (652.815060372842, 0.065928928628721), (653.641316634944, 0.066852866359744), (654.437202360748, 0.067778439120123), (655.28720661485, 0.068709729906517), (656.22925286538, 0.069635984916614), (657.083401772978, 0.070558611580862), (657.966261573947, 0.071490377885947), (658.793187960305, 0.072415649577216), (659.429278096249, 0.073339617096697), (660.222038123862, 0.074273920541835), (660.933379461984, 0.075203734780606), (661.682338158091, 0.076132742239839), (662.48926164527, 0.077067981107755), (663.344024894949, 0.078001081779051), (664.009128567367, 0.078655882687146), (664.573814974249, 0.079121120198648), ) } plasticity_tables["90x90x4b_opp"] = { "f_yield": 519.065428536314, "table": ( (350.03, 0.000000), (370.78, 0.000155), (390.80, 0.000249), (410.11, 0.000362), (428.41, 0.000495), (445.75, 0.000656), (462.03, 0.000835), (477.54, 0.001048), (491.93, 0.001293), (505.00, 0.001575), (516.86, 0.001919), (527.97, 0.002326), (537.14, 0.002822), (544.13, 0.003409), (549.48, 0.004087), (553.39, 0.004848), (556.33, 0.005677), (558.59, 0.006563), (560.37, 0.007490), (561.94, 0.008442), (563.32, 0.009422), (564.62, 0.010419), (565.82, 0.011429), (566.77, 0.012445), (567.66, 0.013480), (568.42, 0.014515), (569.14, 0.015561), (569.89, 0.016611), (570.75, 0.017672), (571.60, 0.018733), (572.53, 0.019799), (573.42, 0.020860), (574.19, 0.021924), (574.91, 0.022989), (575.55, 0.024052), (576.21, 0.025119), (576.87, 0.026186), (577.59, 0.027253), (578.40, 0.028318), (579.28, 0.029382), (580.20, 0.030446), (581.00, 0.031510), (581.66, 0.032571), (582.28, 0.033621), (582.85, 0.034676), (583.57, 0.035732), (584.28, 0.036786), (585.04, 0.037835), (585.99, 0.038888), (586.86, 0.039932), (587.57, 0.040974), (588.30, 0.042014), (588.93, 0.043055), (589.51, 0.044090), (590.16, 0.045131), (590.84, 0.046162), (591.66, 0.047198), (592.56, 0.048230), (593.40, 0.049263), (594.17, 0.050286), (594.86, 0.051314), (595.40, 0.052340), (596.06, 0.053368), (596.67, 0.054391), (597.39, 0.055419), (598.10, 0.056442), (598.97, 0.057465), (599.87, 0.058487), (600.61, 0.059506), (601.23, 0.060523), (601.90, 0.061540), (602.40, 0.062555), (603.04, 0.063574), (603.77, 0.064590), (604.53, 0.065614), (605.27, 0.066627), (606.19, 0.067643), (606.93, 0.068661), (607.59, 0.069675), (608.18, 0.070686), (608.72, 0.071701), (609.34, 0.072717), (610.00, 0.073732), (610.75, 0.074749), (611.52, 0.075767), (612.32, 0.076783), (613.10, 0.077798), (613.75, 0.078809), (614.03, 0.079335), (614.23, 0.079843), (614.63, 0.080352), (614.91, 0.080855), (615.25, 0.081360), (615.67, 0.081706), (615.98, 0.081792), (616.11, 0.081790), (616.12, 0.081792), (616.06, 0.081795), ) } plasticity_tables["90x90x4b_adj"] = { "f_yield": 500.507526661377, "table": ( (350.128130324382, 0), (369.872651446227, 0.000195748859661), (388.937005432004, 0.000303499400372), (407.045674158626, 0.00043405739506), (424.501730661409, 0.000584081220562), (441.069882487345, 0.000761373043126), (456.610248557341, 0.000968171457529), (471.021010727483, 0.00120630566931), (484.174076569665, 0.001486805824236), (495.75765372902, 0.001820663824378), (506.400798146896, 0.002222506324941), (515.282331323677, 0.002711978415225), (522.014863644342, 0.003290148991099), (527.280704925808, 0.00396606198732), (531.395380882424, 0.004718442630556), (534.661683488446, 0.005531159887136), (537.321319527028, 0.006392197144837), (539.517821191958, 0.007293731350527), (541.349347224525, 0.008202924913511), (542.999812114744, 0.009133569180216), (544.546347673466, 0.010077918012946), (545.988268640779, 0.011029153144369), (547.459178559453, 0.011984324191774), (548.902834838818, 0.012942186397582), (550.375231531105, 0.013906026374058), (551.774009120689, 0.014869458647817), (553.049210266212, 0.015831401387143), (554.196301452326, 0.016798166368896), (555.265513250882, 0.017758476641349), (556.329045961499, 0.018727628006731), (557.395410017341, 0.019691008816744), (558.506825288021, 0.020661926491139), (559.648602587803, 0.021630119135559), (560.869738450705, 0.022595025552737), (562.023926553868, 0.023565406096934), (563.080880302678, 0.02452821229653), (564.024944163755, 0.025491271747638), (564.954093052888, 0.026455972787564), (565.800105906953, 0.027424653748954), (566.726160279762, 0.028392967271757), (567.683613867667, 0.029356706038244), (568.722697319277, 0.030322406489434), (569.751772025669, 0.031287683058088), (570.846266214653, 0.032254407077187), (571.741614266262, 0.033223023300597), (572.656673763153, 0.034184099952692), (573.408515700272, 0.035148377723296), (574.215268315885, 0.036114969208437), (575.006338956826, 0.037080335220385), (575.891263630435, 0.038050249319337), (576.843231908183, 0.039013860843972), (577.854435667138, 0.039978788246654), (578.784034494848, 0.040940756991622), (579.724584866404, 0.041905854246095), (580.482692282238, 0.042868398999513), (581.260524673734, 0.043835153800531), (581.972201879969, 0.044801058836786), (582.717167545783, 0.045763537413642), (583.47384957165, 0.046730383918631), (584.347775002032, 0.047693723585528), (585.30457965489, 0.048656717103118), (586.273077631697, 0.049625900978245), (587.106334055278, 0.05059063702108), (587.897320282241, 0.051560207154851), (588.558308002305, 0.052517761557503), (589.242780850054, 0.053484269683022), (589.926277204113, 0.054453315562326), (590.70498270216, 0.055421468623753), (591.503827253653, 0.056388379957605), (592.411599542257, 0.057353280958241), (593.312534091445, 0.058318400895045), (594.149989712184, 0.059288170309771), (594.885887396497, 0.060250654186016), (595.580657150289, 0.061216639159545), (596.136606240443, 0.062183579908607), (596.792379063983, 0.063148411764571), (597.549334213369, 0.064122500487575), (598.339090621323, 0.065089253620111), (599.213016266709, 0.066061699408978), (600.041191700072, 0.067028581085032), (600.847633146121, 0.068000673213402), (601.547565284675, 0.068966380172816), (602.152206680761, 0.069938122169995), (602.807298766546, 0.070912660739427), (603.408411831196, 0.071882341642876), (604.127621470441, 0.072859046358724), (604.860098312381, 0.073832645667379), (605.657608872911, 0.07480087324288), (606.53411727464, 0.075776780181703), (607.272004645777, 0.076747370689278), (607.959442525458, 0.077721037998416), (608.517141600257, 0.078572298675309), (608.901629160067, 0.079278375647452), (609.253693249856, 0.079766729219836), (609.591162888066, 0.080252456192816), ) } if material_id in [ "C1B10M70_column_opp", "C1B09M90_column_opp", "C1B10M70_beam_opp", ]: current_mat = plasticity_tables.get( "100x100x4a_opp", "Invalid material id" ) elif material_id in [ "C1B10M70_column_adj", "C1B09M90_column_adj", "C1B10M70_beam_adj", ]: current_mat = plasticity_tables.get( "100x100x4a_adj", "Invalid material id" ) elif material_id in [ "C1B09M90_beam_opp", "C1B09M90_beam_adj", ]: current_mat = plasticity_tables.get( "90x90x4a", "Invalid material id" ) elif material_id in [ "C1B09M70_column_opp", "C1B10M90_column_opp", "C1B10M90_beam_opp", "C2B10M70_beam_opp", "C2B10M90_beam_opp", ]: current_mat = plasticity_tables.get( "100x100x4b_opp", "Invalid material id" ) elif material_id in [ "C1B09M70_column_adj", "C1B10M90_column_adj", "C1B10M90_beam_adj", "C2B10M70_beam_adj", "C2B10M90_beam_adj", ]: current_mat = plasticity_tables.get( "100x100x4b_adj", "Invalid material id" ) elif material_id in [ "C1B09M70_beam_opp", "C2B09M90_beam_opp", "C2B09M70_beam_opp", ]: current_mat = plasticity_tables.get( "90x90x4b_opp", "Invalid material id" ) elif material_id in [ "C1B09M70_beam_adj", "C2B09M90_beam_adj", "C2B09M70_beam_adj", ]: current_mat = plasticity_tables.get( "90x90x4b_adj", "Invalid material id" ) elif material_id in [ "C2B10M70_column_opp", "C2B10M90_column_opp", "C2B09M70_column_opp", "C2B09M90_column_opp", ]: current_mat = plasticity_tables.get( "100x100x3_opp", "Invalid material id" ) elif material_id in [ "C2B10M70_column_adj", "C2B10M90_column_adj", "C2B09M70_column_adj", "C2B09M90_column_adj", ]: current_mat = plasticity_tables.get( "100x100x3_adj", "Invalid material id" ) return(current_mat)
[docs]def find(name, path): """ Search for a file in a directory tree Parameters ---------- name : str filename path : str Root of the directory tree """ for root, dirs, files in os.walk(path): if name in files: return os.path.join(root, name)
# definition of a method to search for a keyword position
[docs]def get_block_position(model, block_prefix): """ Find a string and return the block number. Method to find a given string on the keywords file of a model and return an integer for the position of the first occurrence. Parameters ---------- model : class Abaqus model to search for keyword block_prefix : string String to look for Attributes ---------- Notes ----- References ---------- """ pos = 0 matches = [] for block in model.keywordBlock.sieBlocks: if string.lower(block[0:len(block_prefix)]) == string.lower(block_prefix): matches.append(pos) pos = pos + 1 return matches
[docs]def open_odb(odb_path): """ A more sophisticated open odb function. Parameters ---------- odb_path : string Path and filename of the database (without the '.odb' extension) Attributes ---------- Notes ----- References ---------- """ base, ext = os.path.splitext(odb_path) odb_path = base + '.odb' if odbAccess.isUpgradeRequiredForOdb(upgradeRequiredOdbPath=odb_path): print('odb %s needs upgrading' % (odb_path,)) path, file_name = os.path.split(odb_path) file_name = base + "_upgraded.odb" new_odb_path = os.path.join(path, file_name) odbAccess.upgradeOdb(existingOdbPath=odb_path, upgradedOdbPath=new_odb_path) odb_path = new_odb_path odb = odbAccess.openOdb(path=odb_path, readOnly=True) return odb
[docs]def field_max(odb, result): """ Look for the max value in a field output. Scan a field output on an abaqus result database and return the maximum value Parameters ---------- odb : class Abaqus model containing the field results result : class Field output result to search for max Attributes ---------- Notes ----- References ---------- """ result_field, result_invariant = result _max = -1.0e20 for step in odb.steps.values(): print('Processing Step:', step.name) for frame in step.frames: if frame.frameValue > 0.0: all_fields = frame.fieldOutputs if all_fields.has_key(result_field): stress_set = all_fields[result_field] for stressValue in stress_set.values: if result_invariant: if hasattr(stressValue, result_invariant.lower()): val = getattr(stressValue, result_invariant.lower()) else: raise ValueError('Field value does not have invariant %s' % (result_invariant,)) else: val = stressValue.data if val > _max: _max = val else: raise ValueError('Field output does not have field %s' % (result_field,)) return _max
[docs]def fetch_hist(odb, step_name, node_name, hist_out_name): """ Return a history output from an odb Parameters ---------- odb : str odb filename (without the extension) step_name : str Name of the step containing the history output node_name : str Name of the regarded node hist_out_name : str Name of the history output Return ------ tuple """ step = odb.steps[step_name] node = step.historyRegions[node_name] hist_out = node.historyOutputs[hist_out_name] data = hist_out.data return data
[docs]def write_all_history(odb, fh): db = {} for step_key in odb.steps.keys(): step = odb.steps[step_key] for hist_reg_key in step.historyRegions.keys(): hist_reg = step.historyRegions[hist_reg_key] for hist_out_key in hist_reg.historyOutputs.keys(): hist_out = hist_reg.historyOutputs[hist_out_key].data idx = hist_reg_key + "_" + hist_out_key if idx in db.keys(): db[idx] = db[idx] + list(hist_out) else: db[idx] = list(hist_out) with open(fh, "w") as f: f.write( "frame;" + str( db.keys() ).replace("'", "").replace(", ",";").strip("[]") ) f.write("\n") f.write( "#;" + str( [i.split("_")[-1] for i in db.keys() ] ).replace( "'", "" ).replace( ", ", ";" ).strip("[]") ) for i in range(len(db.values()[0])): f.write("\n") f.write(str(list(db.values())[0][i][0])+";") for j in db.values(): f.write(str(j[i][1])+";")
# Look for the max value in a history output # TO BE FIXED. THE REFERENCE POINTS (rp1key, ho1key etc.) ARE NOT GENERIC. # Fetch maximum load, displacement and LPF for a riks analysis. # The method assumes that a) the the odb is located in the current directory
[docs]def history_max(odb_obj, step_name): """ Look for the max value in a history output. Scan a history output on a step on an abaqus result database and return the maximum value. Currently, it returns LPF, load and disp history outputs. To be generalised. Parameters ---------- odb_obj : Abaqus database object Abaqus model filename. step_name : str Name of the step """ # my_odb = odbAccess.openOdb(path=odb_name) riks_step = odb_obj.steps[step_name] rp1key = riks_step.historyRegions.keys()[1] ho1key = riks_step.historyRegions[rp1key].historyOutputs.keys()[0] rp2key = riks_step.historyRegions.keys()[2] ho2key = riks_step.historyRegions[rp2key].historyOutputs.keys()[0] asskey = riks_step.historyRegions.keys()[0] hoasse = riks_step.historyRegions[asskey].historyOutputs.keys()[-1] load_hist = riks_step.historyRegions[rp1key].historyOutputs[ho1key].data disp_hist = riks_step.historyRegions[rp2key].historyOutputs[ho2key].data lpf_hist = riks_step.historyRegions[asskey].historyOutputs[hoasse].data maxpos = load_hist.index(max(load_hist, key=lambda x: x[1])) load = load_hist[maxpos][1] disp = -disp_hist[maxpos][1] lpf = lpf_hist[maxpos][1] return lpf, load, disp
[docs]def find_odb_in_cwd(all=False): all_odbs = [i for i in os.listdir(os.getcwd()) if i.split(".")[-1] == "odb"] if all: return all_odbs else: return all_odbs[0]
[docs]def fetch_eigenv(odb_name, step_name, n_eigen): """ Get eigenvalues. Return the eigenvalues of a perturbation buckling analysis from an abaqus database. Parameters ---------- odb_name : class Abaqus model containing the eigenvalues step_name : string Name of the step n_eigen : int Number of eigenvalues to return Attributes ---------- Notes ----- References ---------- """ bckl_odb = odbAccess.openOdb(path=odb_name + '.odb') bckl_step = bckl_odb.steps[step_name] # Gather the eigenvalues eigenvalues = () eigen_string = "" for J_eigenvalues in range(1, n_eigen + 1): current_eigen = float(bckl_step.frames[J_eigenvalues].description.split()[-1]) eigenvalues = eigenvalues + (current_eigen,) eigen_string = eigen_string + "%.3E " % current_eigen # Close the odb odbAccess.closeOdb(bckl_odb) # Return variables return eigenvalues, eigen_string
[docs]def exporter(data, filename): """ Eaport data to pickle Parameters ---------- data Variable containing the data to be exported filename : str Filename of the export file """ with open(filename, "wb") as fh: pickle.dump(data, fh)
[docs]def isnumber(x): """ Checks if the given object is numeric. Either `float` or `int` will return `True`. In any other case the return is `False`. Parameters ---------- x : any Object to be checked. Returns ------- boolean. """ return isinstance(x, int) or isinstance(x, float)
# def main(): # """ # Load FEM data for the 9 tested specimens. # """ # odb = "./016-030-specimens/RIKS-016-030-specimens" # step_name = "RIKS" # node_name = "Node ASSEMBLY.1" # hist_out_name = "RF3" # # sp1 = fetch_hist(odb, step_name, node_name, hist_out_name)