Zapis do plików fil w Abaqus
|
1 2 |
*EL FILE,FREQ=1 S |
|
1 2 |
*EL FILE,FREQ=1 S |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
from abaqusConstants import * from math import * import odbAccess import os import multiprocessing as mp ################# CONFIGS ##################### odbFiles = ['MICRO_COMPR_XX', 'MICRO_COMPR_YY', 'MICRO_SHEAR_XY'] # seperate new odb files with comma maxPercent = 0.0001 # Percent of elements with maximum values which is taken to determinate average maximum value cpus = 4 # How many CPUs do you want to use - how many odbs will be accessed in the same time. ############################################### def avgMaxFromPercentList(l, percent, revSort): l.sort(reverse=revSort) maxElements = int(ceil(len(l) * maxPercent)) lmax = l[:maxElements] avg = sum(lmax) / float(len(lmax)) return avg def Analise(resultFile): print resultFile + "\t[START]" try: os.remove(resultFile + '_MAX.txt') except OSError: pass odb = odbAccess.openOdb(resultFile+'.odb', readOnly=True) step=odb.steps['Step-1'] frames = step.frames maxStrain = 0 maxStress = 0 # Stress/Strain Curve for frame in frames: # Max stress / strain stress=frame.fieldOutputs['S'].getSubset(position=INTEGRATION_POINT).values strain=frame.fieldOutputs['PEEQ'].getSubset(position=INTEGRATION_POINT).values count = len(stress) stressList = [None] * count strainList = [None] * count for i in range(0, count): stressList[i] = stress[i].mises strainList[i] = strain[i].data newStress = avgMaxFromPercentList(stressList, maxPercent, True) if newStress > maxStress: maxStress = newStress newStrain = avgMaxFromPercentList(strainList, maxPercent, True) if newStrain > maxStrain: maxStrain = newStrain file = open(resultFile+'_MAX.txt', 'w') file.write('{0}\t{1}\n'.format(maxStrain, maxStress)) file.close() odb.close() print resultFile + "\t[DONE]" if __name__ == '__main__': pool = mp.Pool(processes=cpus) pool.map(Analise, odbFiles) pool.close() # no more tasks pool.join() # wrap up current tasks print "Finished!" |
Skrypt pobiera wartość maksymalną naprężeń Misesa i ekwiwalentnych odkształceń z n% elementów z największymi wartościami, wśród wszystkich kroków czasowych symulacji.
Skrypt pobiera tensor naprężeń z pliku wynikowego abaqusa a następnie tworzy krzywą odkształcenie/naprężenie. Skrypt działa równolegle Skrypt pobiera maksymalne wartości z ostatniego kroku obliczeń i zapisuje je do pliku
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
__author__ = "Krzysztof Bzowski" __version__ = "1.0.0" from abaqusConstants import * from math import * import odbAccess import multiprocessing as mp import os ################# CONFIGS ##################### odb11File = 'SSRVE_11' odb12File = 'SSRVE_12' odb22File = 'SSRVE_22' maxPercent = 0.01 ############################################### def avgMaxFromPercentList(l, percent, revSort): l.sort(reverse=revSort) maxElements = int(ceil(len(l) * maxPercent)) lmax = l[:maxElements] avg = sum(lmax) / float(len(lmax)) return avg def Analize(resultFile, direction, inOrder): try: os.remove(resultFile + '.txt') except OSError: pass try: os.remove(resultFile + '_MAX.txt') except OSError: pass odb = odbAccess.openOdb(resultFile+'.odb', readOnly=True) step=odb.steps['Step-1'] frames = step.frames # Stress/Strain Curve for frame in frames: stress=frame.fieldOutputs['S'].getSubset(position=INTEGRATION_POINT).values strain=frame.fieldOutputs['PE'].getSubset(position=INTEGRATION_POINT).values volumes=frame.fieldOutputs['EVOL'].values count = len(volumes) summVol = 0 summStress = 0 summStrains = 0 for i in range(0, count): s = stress[i].data[direction] # S p = strain[i].data[direction] # PE v = volumes[i].data # VOLUME summVol += v summStress += s*v summStrains += p*v avgStress = summStress/summVol avgStrain = summStrains/summVol myFile = open(resultFile+'.txt', 'a') myFile.write('{0}\t{1}\n'.format(abs(avgStrain), abs(avgStress))) myFile.close() # Max stress / strain lastFrame = frames[-1] stress=lastFrame.fieldOutputs['S'].getSubset(position=INTEGRATION_POINT).values strain=lastFrame.fieldOutputs['PE'].getSubset(position=INTEGRATION_POINT).values count = len(stress) stressList = [None] * count strainList = [None] * count for i in range(0, count): stressList[i] = stress[i].data[direction] # S strainList[i] = strain[i].data[direction] # PE maxStress = avgMaxFromPercentList(stressList, maxPercent, inOrder) maxStrain = avgMaxFromPercentList(strainList, maxPercent, inOrder) file = open(resultFile+'_MAX.txt', 'w') file.write('{0}\t{1}\n'.format(maxStrain, maxStress)) file.close() odb.close() if __name__ == '__main__': print __name__ direction11 = 0 direction22 = 1 direction12 = 3 p11 = mp.Process(target=Analize, args=(odb11File, direction11, False)) p22 = mp.Process(target=Analize, args=(odb22File, direction22, False)) p12 = mp.Process(target=Analize, args=(odb12File, direction12, True)) p11.start() p22.start() p12.start() p11.join() p22.join() p12.join() |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
#include <math.h> #include <iostream> using namespace std; extern "C" void uhard(double *, double *, double *, double *, double *, double *, double *, double *, int *, int *, int *, int *, int *, int *, char *, int *, double *, int *, double *, double *, int*, double *); /** User subroutine UHARD: is called at all material calculation points of elements for which the material definition includes user-defined isotropic hardening or cyclic hardening for metal plasticity; - can be used to define a material's isotropic yield behavior; - can be used to define the size of the yield surface in a combined hardening model; - can include material behavior dependent on field variables or state variables; - and requires, when appropriate, that the values of the derivatives of the yield stress (or yield surface size in combined hardening models) be defined with respect to the strain, strain rate, and temperature. */ void uhard(double *syield, double *hard, double *eqplas, double *eqplasrt, double *time, double *dtime, double *temp, double *dtemp, int *noel, int *npt, int *layer, int *kspt, int *kstep, int *kinc, char *cmname, int *nstatev, double *statev, int *numfieldv, double *predef, double *dpred, int *numprops, double *props) { // USER CODING TO DEFINE: // SYIELD - (sigma_0) - Yield stress for isotropic plasticity. Yield surface size for combined hardening. // hard[0] - Variation of SYIELD with respect to the equivalent plastic strain // hard[1] - Variation of SYIELD with respect to the equivalent plastic strain rate, This quantity is not used with the combined hardening model. // hard[2] - Variation of SYIELD with respect to temperature, This quantity is required only in adiabatic, fully coupled temperature-displacement, and thermal-electrical-structural analyses. // statev@nstatev - Array containing the user - defined solution - dependent state variables at this point.These are supplied as values at the beginning of the increment or as values updated by other user subroutines and must be returned as values at the end of the increment. // VARIABLES PASSED IN FOR INFORMATION: // eqplas - Equivalent plastic strain // eqplasrt - Equivalent plastic strain rate // time[0] - Value of step time at the beginning of the current increment. // time[1] - Value of total time at the beginning of the current increment. // dtime - Time increment // temp - Temperature at the beginning of the increment. // dtemp - Increment of temperature. // noel - Element number. // npt - Integration point number. // layer - Layer number(for composite shells and layered solids). // kspt - Section point number within the current layer. // kstep - Step number. // kinc - Increment number. // cmname - User - specified material name, left justified. // nstatv - User - specified number of solution - dependent state variables associated with this material // numfieldv - Number of field variables. // predef@numfieldv - Array of interpolated values of predefined field variables at this material point at the start of the increment based on the values read in at the nodes(initial values at the beginning of the analysis and current values during the analysis). // dpred@numfieldv - Array of increments of predefined field variables at this material point for this increment; this includes any values updated by user subroutine USDFLD. // numprops - Number of hardening properties entered for this user - defined hardening definition. // props@numprops - Array of hardening properties entered for this user - defined hardening definition. double a = 800; double n = 0.2; const double zero = 0.0; double eps = 0; if(*eqplas == zero) { eps = 0.01; } // syield - Naprezenie - obliczone na podstawie odksztalcenia eqpla *syield = a * powf(eps, n); // hard[0] - wartosc pochodnej po odksztalceniu hard[0] = a * n * powf(eps, n - 1); // hard[1] - wartosc pochodnej po predkosci odksztalcenia // hard[2] - wartosc pochodnej po temperaturze return; } |
HELP:
|
1 |
abaqus debug help |
ŚRODOWISKO: Abaqus < 6.14.x – abaqus_v6.env lub Abaqus >= 2016: Dassault Systemes\SimulationServices\V6R2016x\win_b64\SMA\site\win86_64.env
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
compile_cpp=['cl', '/c', '/W0', '/MD', '/TP', '/EHsc', '/DNDEBUG', '/DWIN32', '/DTP_IP', '/D_CONSOLE', '/DNTI', '/DFLT_LIC', '/DOL_DOC', '/D__LIB__', '/DHKS_NT', '/D_WINDOWS_SOURCE', '/DFAR=', '/D_WINDOWS', '/DABQ_WIN86_64', '%P', # '/O1', # <-- Optimization '/Zi', # <-- Debug symbols '/I%I'] compile_fmu=['win64CmpWrp', '-m64', '-msvc9', 'cl', '/LD', '/D_WINDOWS', '/TC', '/W0', '/I%I'] compile_fortran=['ifort', '/c','/DABQ_WIN86_64', '/extend-source', '/fpp', '/iface:cref', '/recursive', '/Qauto-scalar', '/QxSSE3', '/QaxAVX', '/heap-arrays:1', '/Od', '/Ob0', # <-- Optimization Debugging '/Zi', # <-- Debugging '/include:%I'] link_sl=['LINK', '/nologo', '/NOENTRY', '/INCREMENTAL:NO', '/subsystem:console', '/machine:AMD64', '/NODEFAULTLIB:LIBC.LIB', '/NODEFAULTLIB:LIBCMT.LIB', '/DEFAULTLIB:OLDNAMES.LIB', '/DEFAULTLIB:LIBIFCOREMD.LIB', '/DEFAULTLIB:LIBIFPORTMD.LIB', '/DEFAULTLIB:LIBMMD.LIB', '/DEFAULTLIB:kernel32.lib', '/DEFAULTLIB:user32.lib', '/DEFAULTLIB:advapi32.lib', '/FIXED:NO', '/dll', '/debug', # <-- Debugging '/def:%E', '/out:%U', '%F', '%A', '%L', '%B', 'oldnames.lib', 'user32.lib', 'ws2_32.lib', 'netapi32.lib', 'advapi32.lib'] link_exe=['LINK', '/nologo', '/INCREMENTAL:NO', '/subsystem:console', '/machine:AMD64', '/STACK:20000000', '/NODEFAULTLIB:LIBC.LIB', '/NODEFAULTLIB:LIBCMT.LIB', '/DEFAULTLIB:OLDNAMES.LIB', '/DEFAULTLIB:LIBIFCOREMD.LIB', '/DEFAULTLIB:LIBIFPORTMD.LIB', '/DEFAULTLIB:LIBMMD.LIB', '/DEFAULTLIB:kernel32.lib', '/DEFAULTLIB:user32.lib', '/DEFAULTLIB:advapi32.lib', '/FIXED:NO', '/LARGEADDRESSAWARE', '/debug', # <-- Debugging '/out:%J', '%F', '%M', '%L', '%B', '%O', 'oldnames.lib', 'user32.lib', 'ws2_32.lib', 'netapi32.lib', 'advapi32.lib'] |
EXAMPLE:
|
1 2 |
compilervars.bat intel64 abaqus -debug -standard -input Job-1 -user myuhard -job Job-1 -interactive |
abaqus interactive input=JobA cpus=4 job=JobA
|
1 2 3 4 5 6 7 8 9 10 11 12 |
#!/bin/bash for FILE in *.inp; do echo "Processing $FILE"; x=`grep -ni -m1 "*Element, type=DC2D8" $FILE | cut -f1 -d: | awk '{ SUM += $1 + 1} END { print SUM }'` y=`grep -ni -m1 "*Nset" $FILE |cut -f1 -d: | awk '{ SUM += $1 - 1} END { print SUM }'` sed -n "$x,$y p" $FILE | sed "s/,/ /g" | awk '{print $2, $3, $4, $5, $6, $7, $8, $9}' > $FILE.pre count=`wc -l $FILE.pre | cut -f1 -d\ ` sed "1i$count" $FILE.pre > $FILE.out rm -f $FILE.pre mv -f $FILE.out $FILE done; |
set FILE=file.inp grep -ni -m1 „*Element, type=DC2D8” %FILE% | cut -f1 -d: | awk „{ SUM += $1 + 1} END { print SUM }” grep -ni -m1 „*Nset” %FILE% |cut -f1 -d: | awk „{ SUM += $1 – 1} END { print SUM }”