Monday, November 2, 2009

Abaqus Licence Caller

Hey Friends,
Are u Using remote abaqus license from ur institute/Company ?
Are u facing problem to get abaqus license from Institute/Company because its limited number ?
Are u looking for an automatic program which will open Abaqus CAE when licenses get available?


Then here is the solution!!

AbaqusCaller.py



## This is a simple script to call "abaqus cae". The AbaqusCaller.py Script
## will check the availability of licenses, if no licence available for some
## reason, the script will again call the 'abaqus cae' with in next given second
from os import system
from time import sleep, ctime
## her u can define sleeping time
sleeppingTime=5## 5 sec before trying the second attempt
##---------------------
count=1
print 'Attempting to call ABAQUS CAE at:',ctime().split()[3]
print ' Attempt No: ', count
a=system('abaqus cae')
while count<100000:
if a==1:
sleep(sleeppingTime)
print 'Attempting to call ABAQUS CAE at:',ctime().split()[3]
print ' Attempt No: ', count+1
a=system('abaqus cae')
count=count+1



AbaqusCaller.py will search for the license until u get a one and open Abaqus cae!!

Then,
1. Download the script from attachment
2. Place it at the folder where you want to open abaqus cae.
3. Double click on AbaqusCaller.py.
4. Hope u have already installed python compiler , if not follow the below link to install python
http://www.python.org/ftp/python/2.6.2/python-2.6.2.msi


Tuesday, October 27, 2009

Inverse analysis in Abaqus with Python

What is inverse analysis?
inverse analysis are those problems where the solution is already known, based on the solution, parameters or inputs for the analysis are to be determined.

Problem statement :
For example we know the maximum value of stress in a particular location in the structure. we want to find out the young's modulus of the material corresponding to the solution known. lets say young's modulus varies from 50 to 200 GPa..

Solution
This problem can be solved in abaqus with help of python scripting.

the algorithem is as follows






Prerequisite

1. Abaqus kernal scripting
2. knowledge of optimization algorithms

The idea is as follows:

step1 : Using python write a function named myFunction(Youngs), where you have to modify your input file and run the analysis by taking "Youngs" as an argument . submit the job and wait for completion.

step2 : Inside the same function, from the output database of the analysis just submitted take the stress corresponding to particular region as specified in example problem definition. return it to optimization function.

def myFunction(Youngs):
mdb=openMdb( 'NameModel. cae')
mdb.models['Name'].materials['STEEL'].elastic.setValues(table=((Youngs,0.3),))
mdb.Job(name= 'NameOfJob' , model='Name' , type=ANALYSIS,
explicitPrecision= SINGLE, nodalOutputPrecisio n=SINGLE,
description= '', parallelizationMeth odExplicit= DOMAIN,
multiprocessingMode =DEFAULT, numDomains=1, userSubroutine= '',
numCpus=1, memory=50, memoryUnits= PERCENTAGE, getMemoryFromAnalysis=True,
echoPrint=OFF, modelPrint=OFF, contactPrint= OFF, historyPrint= OFF)
mdb.jobs['JobNAME' ].submit( consistencyCheck ing=OFF)
mdb.jobs['JobNAME' ].waitForCompletion()
##--- Odb business---- -----
odb=openOdb( path='JobNAME. odb')
return Stress## get ur stress corresponding to the specified point and return it
odb.close()






where mdb(model data base) commands are used to alter the inp file. Youngs will come as an argument from optimizer as shown in the figure.

step3: write ur optimization algorithm here
ex: golden search method :


from math import log, sqrt
def bracket(myFunction,x1, h):
c = 1.618033989
f1 = f(x1)
x2 = x1 + h; f2 = f(x2)
# Determine downhill direction and change sign of h if needed
if f2 > f1:
h = -h
x2 = x1 + h; f2 = f(x2)
# Check if minimum between x1 - h and x1 + h
if f2 > f1: return x2,x1 - h
# Search loop
for i in range (100):
h = c*h
x3 = x2 + h; f3 = f(x3)
if f3 > f2: return x1,x3
x1 = x2; x2 = x3
f1 = f2; f2 = f3
print 'Bracket did not find a mimimum'

def search(f,a,b, tol=1.0e- 9):
nIter = -2.078087*log( tol/abs(b- a))
R = 0.618033989
C = 1.0 - R
# First telescoping
x1 = R*a + C*b; x2 = C*a + R*b
f1 = f(x1); f2 = f(x2)
# Main loop
for i in range(int(nIter) ):
if f1 > f2:
a = x1
x1 = x2; f1 = f2
x2 = C*a + R*b; f2 = f(x2)
else:
b = x2
x2 = x1; f2 = f1
x1 = R*a + C*b; f1 = f(x1)
if f1 < f2: return x1,f1
else: return x2,f2



finally run the analysis like this
xStart = 50## initial guess for optimization
h = 0.01
x1,x2 = bracket(Function1,xStart, h)
x,fMin = search(Function1,x1, x2)
print 'x =',x
raw_input ('\nPress return to exit')

This algorithm works based on iterative procedures that require starting values of the design variables x. If myFunction(args) has several local minima, the initial choice of x determines which of these will be computed. There fore there is no guaranteed way of finding the global optimal point. One suggested procedure is to make several computer runs using different starting points and pick the best result. or go for some unconventional methods like Genitic Algorithm or Simulated annealing.