{"id":209,"date":"2015-01-06T18:10:23","date_gmt":"2015-01-06T17:10:23","guid":{"rendered":"https:\/\/kszyh.kisim.eu.org\/?p=209"},"modified":"2015-01-06T18:10:23","modified_gmt":"2015-01-06T17:10:23","slug":"pobieranie-najwiekszej-wartosci-naprezenia-i-odksztalcenia-w-abaqusie","status":"publish","type":"post","link":"https:\/\/kszyh.kisim.eu.org\/?p=209","title":{"rendered":"Pobieranie najwi\u0119kszej warto\u015bci napr\u0119\u017cenia i odkszta\u0142cenia w Abaqusie"},"content":{"rendered":"<p>&nbsp;<\/p>\n<pre class=\"lang:python decode:true \">from abaqusConstants import *\r\nfrom math import *\r\nimport odbAccess\r\nimport os\r\nimport multiprocessing as mp\r\n\r\n################# CONFIGS #####################\r\nodbFiles = ['MICRO_COMPR_XX', 'MICRO_COMPR_YY', 'MICRO_SHEAR_XY']  # seperate new odb files with comma\r\nmaxPercent = 0.0001                              # Percent of elements with maximum values which is taken to determinate average maximum value    \r\ncpus = 4                                         # How many CPUs do you want to use - how many odbs will be accessed in the same time.      \r\n###############################################\r\n\r\ndef avgMaxFromPercentList(l, percent, revSort):\r\n    l.sort(reverse=revSort)   \r\n    maxElements = int(ceil(len(l) * maxPercent))\r\n    lmax = l[:maxElements]\r\n    avg =  sum(lmax) \/ float(len(lmax))\r\n    return avg\r\n\r\n\r\ndef Analise(resultFile):\r\n    print resultFile + \"\\t[START]\"\r\n\r\n    try:\r\n        os.remove(resultFile + '_MAX.txt')\r\n    except OSError:\r\n        pass\r\n        \r\n    odb = odbAccess.openOdb(resultFile+'.odb', readOnly=True)\r\n    step=odb.steps['Step-1']\r\n\r\n    frames = step.frames\r\n\r\n    maxStrain = 0\r\n    maxStress = 0\r\n    # Stress\/Strain Curve\r\n    for frame in frames:\r\n        # Max stress \/ strain \r\n        stress=frame.fieldOutputs['S'].getSubset(position=INTEGRATION_POINT).values\r\n        strain=frame.fieldOutputs['PEEQ'].getSubset(position=INTEGRATION_POINT).values  \r\n        \r\n        count = len(stress)\r\n        stressList = [None] * count\r\n        strainList = [None] * count\r\n        for i in range(0, count):\r\n            stressList[i] = stress[i].mises      \r\n            strainList[i] = strain[i].data   \r\n     \r\n\r\n        newStress = avgMaxFromPercentList(stressList, maxPercent, True)\r\n        if newStress &gt; maxStress:\r\n            maxStress = newStress\r\n            \r\n        newStrain = avgMaxFromPercentList(strainList, maxPercent, True)\r\n        if newStrain &gt; maxStrain:\r\n            maxStrain = newStrain\r\n    \r\n        \r\n    file = open(resultFile+'_MAX.txt', 'w')\r\n    file.write('{0}\\t{1}\\n'.format(maxStrain, maxStress))\r\n    file.close()\r\n    odb.close()\r\n    \r\n    print resultFile + \"\\t[DONE]\"\r\n\r\n    \r\nif __name__ == '__main__': \r\n    pool = mp.Pool(processes=cpus)\r\n    pool.map(Analise, odbFiles)\r\n    pool.close() # no more tasks\r\n    pool.join()  # wrap up current tasks\r\n    \r\n    print \"Finished!\"\r\n\r\n<\/pre>\n<p>Skrypt pobiera warto\u015b\u0107 maksymaln\u0105 napr\u0119\u017ce\u0144 Misesa i ekwiwalentnych odkszta\u0142ce\u0144 z n% element\u00f3w z najwi\u0119kszymi warto\u015bciami, w\u015br\u00f3d wszystkich krok\u00f3w czasowych symulacji.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; from abaqusConstants import * from math import * import odbAccess import os import multiprocessing as mp ################# CONFIGS ##################### odbFiles = [&#8217;MICRO_COMPR_XX&#8217;, 'MICRO_COMPR_YY&#8217;, 'MICRO_SHEAR_XY&#8217;] # seperate new odb files with comma maxPercent = 0.0001 # Percent of elements with maximum values which is taken to determinate average maximum value&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/kszyh.kisim.eu.org\/?p=209\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[63],"tags":[12,67],"class_list":["post-209","post","type-post","status-publish","format-standard","hentry","category-python-2","tag-abaqus","tag-mechanika"],"_links":{"self":[{"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=209"}],"version-history":[{"count":1,"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/209\/revisions"}],"predecessor-version":[{"id":210,"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/209\/revisions\/210"}],"wp:attachment":[{"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}