• No results found

Abaqus Scripting Seminar Oct1st

N/A
N/A
Protected

Academic year: 2021

Share "Abaqus Scripting Seminar Oct1st"

Copied!
29
0
0

Loading.... (view fulltext now)

Full text

(1)

3D S. C OM © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Enhance your productivity

by using Abaqus Scripting

Shikta Mishra

Technical Specialist, Simulia Central

(2)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Motivation

Python Basics

Abaqus Python

Abaqus Object Model

Plug-ins

Demonstration: RSG Dialog Builder

(3)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Motivation: why customize Abaqus?

Provides automated

environment for experienced

analysts

Provides

advanced analysis functionality

to non-FEA users

C

ustom

iz

ed

application

Customized versions of

Abaqus provide an

effective analysis tool for

a wide range of user

expertise …

Automate repetitive tasks

Model building

Job submission and monitoring

Postprocessing

Prescribe default behavior

Extend functionality

Enhance the interface

Graphical

Nongraphical

(4)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Why Python?

(5)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Scripting Language v/s Programming Language

This information is taken from Scripting: Higher Level

Programming for the 21

st

Century

by Ousterhout J.K.

Scripting

Language

Programming

Language

High Level

(# Instr/Stmnt)

Low Level

(# Instr/Stmnt)

Weakly Typed

Strongly Typed

Rapid Development

Rapid Run-Time

Examples: Python,

Tcl, Perl, etc

Examples: C, C++,

Fortran, etc

(6)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20

14

Example using common syntax rules:

# simple example

max = 5; i = 0

x, y, z = 1, 2, 3

while i <= max:

square = i**2 + x*y

cube = i**3 - z

print i, square, cube

i = i + 1 # increment index

for j in ['ASN',1,2]:

pass

print 'The example is completed\

now print a long message'

Semicolon for two statements

blank lines ignored

Comments start with # and continue to the end

of the line

Backslash for line

continuation

Indentation

delimits blocks

(such as loops)

The amount of

indentation is

arbitrary but

must be

consistent for a

block

An empty block is denoted with the pass

statement

The syntax forces the user to write readable

code and enables productivity

(7)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Python Scripting Style Guide

Suggested style guidelines for writing python scripts

The style guide is available from Knowledge Base Article

QA00000008185

Abaqus provides a style guide to help maintain script consistency.

A consistent style:

Generally makes scripts easier to debug and maintain

Can establish conventions that parallel the object model

(8)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Accessing Python

From Abaqus/CAE

(9)

3D S. C OM © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Accessing Python

Use

sys.version

to query the version of Python that is being used

>>>

import sys

>>> sys.version

'2.7.3 (default, May 1 2014, 02:56:01) [MSC v.1600 64 bit (AMD64)]'

From Command Prompt

To quit python interpreter from a command prompt use:

Ctrl Z – Enter (for windows)

(10)

3D S. C OM © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Running Python

You may not bypass the Abaqus/CAE kernel like this:

abaqus python myscript.py

abaqus script myscript.py

abaqus cae startup = myscript.py

abaqus cae script = myscript.py

abaqus viewer startup = myscript.py

Running

Python

(11)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Abaqus Scripting Interface Basics

command

line interface

(CLI)

Abaqus/CAE

Abaqus/CAE

kernel

Abaqus/Standard

Abaqus/Explicit

output database file

input file

Python interpreter

replay

files

script

GUI

commands

(12)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Building Scripts

Macro Manager

Abaqus Replay(.rpy) File

(13)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Replay File Example

Creating a script that rotates the model in current display

Steps:

1) In Abaqus/CAE rotate the model by a specifying an increment in the

dialog box.

session.currentViewportName.view.rotate(xAngle=10,

yAngle=0,zAngle=0,mode=MODEL

)

2) Cut and paste this command into a new text file. Add a Python statement to loop over the command:

for x in range(36):

session.currentViewportName.view.rotate(xAngle=10,

yAngle=0,zAngle=0, mode=MODEL

)

(14)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Replay File Example

(15)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Integrated Development Environment : Abaqus PDE

The IDE built into Abaqus is known as Abaqus

Python Development Environment (PDE)

Separate application

Accessible from within Abaqus/CAE or independently

Step through a Python script running in the Abaqus/CAE

kernel or GUI

(16)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Abaqus Object Model

The Abaqus Scripting Interface extends Python with new types of objects.

The hierarchy and the relationship between these objects is called the Abaqus Object model.

Object 1 Object 2

Object 4 Object 5

(17)

17

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20

14

The object model describes the relationships between objects.

Use commands to access objects by stepping through the hierarchy of objects in the

object model

cell4 = mdb.models['block'].parts['crankcase'].cells[4]

Abaqus Object Model

A Part owns features,

datums, etc.

A Model owns parts

cell with index 4

part named crankcase

Model database

mdb

Variable cell4

model named

(18)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Abaqus Object Model

Object Attributes : Members and Methods

Identifying Constructors and Repositories

p = mdb.models['Model-1'].Part(name='Part-1',

dimensionality=THREE_D, type=DEFORMABLE_BODY)

The path to the constructor is

mdb.models['Model-1'].Part

The new Part object is placed into the parts repository

mdb.models['Model-1'].parts['Part-1']

(19)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Postprocessing with Abaqus Scripting

Output Database Object Model

Contains model data and results data

Results data in the ODB are categorized as Field Data or History Data.

The Odb object is normally available from inside or outside of Abaqus/Viewer or Abaqus/CAE.

Field Data

(20)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Postprocessing with Abaqus Scripting Interface

In this example a kernel script has been developed to

interact with an output database file through the Abaqus

Scripting Interface

The script searches for the maximum value of von Mises

(21)

3D S. C OM © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

# scr_auto_run1.py

import os

jobs=['auto_job1', 'auto_job2', 'auto_job3']

path = 'C:\\Abaqus6\\Commands\\abq6141'

#path = r'C:\Abaqus6\Commands\abq6141'

#path = 'C:/Abaqus6/Commands/abq6141'

for job in jobs:

print 'job:', job

cmd = '%s job=%s inter' % (path, job)

os.system(cmd)

Same behavior

Job Submission

Example: Auto submit three Abaqus jobs, one-at-a-time

(22)

3D S. C OM © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

# scr_auto_run2.py

import job

jobs=['auto_job1', 'auto_job2', 'auto_job3']

for job in jobs:

job = mdb.JobFromInputFile(

name = job, inputFileName = job + '.inp',

type = ANALYSIS)

job.submit()

job.waitForCompletion()

Job Submission

Example: Auto submit three Abaqus jobs, one-at-a-time (cont’d)

(23)

3D S. C OM © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Abaqus Environment file (abaqus_v6.env) can contain abaqus scripting interface

commands

onCaeStartup() function

Example: Auto create materials upon opening a CAE session

onJobStartup() function

def onJobStartup():

print 'The job is starting'

onJobCompletion() function

def onJobCompletion ():

print 'The result files have been copied to workdir'

def onCaeStartup():

# Material properties - read them from a file

execfile('my_material_library.py')

(24)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Plug-ins

Kernel Plug-in

GUI Plug-in

What is a plug-in?

An Abaqus plug-in is a piece of software that is automatically installed into

Abaqus/CAE to extend its functionality.

(25)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Resources

Knowledge Base Article QA00000008694 (DSx.Client Care:

www.3ds.com/support/knowledge-base

) contains a list of SIMULIA supplied

(26)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Really Simple GUI

It is an Abaqus/CAE plug-in

Plug-ins → Abaqus → RSG Dialog Builder

Interactive tool for building a Graphical User Interface (GUI)

Includes widgets (controls)

(27)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

RSG Demonstration

Diagram showing definitions

Hit OK to build model, analyze, and display

results, this executes the kernel script

Text entry boxes for

(28)

3D S. C OM/ SI M U LI A © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

Next steps …

Find all the upcoming eSeminars from

SIMULIA home page

eSeminar Replay: Watch for email with details

Register for a Training Class

3ds.com/simulia-training

Find all eSeminar replay since 2014 in

3ds.com/slc

Register and Attend RUMs

3ds.com/simulia/

(29)

3D S. C OM © D as sa ult S ys tè m es | C on fide nt ial In fo rm at ion | 10 /6 /2 01 5 | r ef .: 3D S_ D oc um en t_ 20 14

References

Related documents

The effect of single, simultaneous and sequential delivery of BMP-2 and BMP-7 incorporated to the scaffolds by two different techniques, into and onto chitosan fibers, were studied

With the rich theory of foreign origami geometry (Geretschläger, 1995), origami has been widely used in many fields such as aerospace design, automotive

The list is folded in half horizontally across the center just above the title Ben Hur on the left hand list, which is on the outside of the folded sheet.. In the presentation,

L’organisation comptable avant tous nous permet de classer chronologiquement un dossier avant qu’il soit traité après le classement on passe aux écritures comptables, ce dernier est

Thus, the data were collected at 30, 60 and 90 days after the emergence of the following variables: Plant Height (PH) - measured between the soil level and the apex of the plants

Besides fast algorithms like BLAST and FASTA, Smith-Waterman algorithm was used to search protein databases which guarantee the optimal alignments of the query

VHF DSC distress alert with MMSI, position, nature, working ch16 received by VHF DSC ship or coast stations in radio range ≈30nm Await VHF DSC distress acknowledge from CS or

LumberKings #1 starter Edwin Diaz showed why he was ranked #5 among Mariners prospects by Baseball America with a seven inning shutout performance over the Peoria