Dynamic character substitution.

J

John Bausano

Hello all,



I've been using Ansys which is a commercial FEA package which can be
controlled through its own scripting language they call APDL. Now I'm
trying to write some stand alone code in Python to supplement my current
efforts.



In Ansys I can do something like this.



*do,n,1,3 #loop
through n

*dim,data%n%,1000,2 #creates variables
arrays data1(1000,2), data2(1000,2)..

*vread,data%n%,filename%n% #fills arrays with data
from filename1,.



Thanks



john
 
T

Tim Roberts

John Bausano said:
Hello all,

I've been using Ansys which is a commercial FEA package which can be
controlled through its own scripting language they call APDL. Now I'm
trying to write some stand alone code in Python to supplement my current
efforts.

In Ansys I can do something like this.

*do,n,1,3 #loop through n

*dim,data%n%,1000,2 #creates variables
arrays data1(1000,2), data2(1000,2)..

*vread,data%n%,filename%n% #fills arrays with data
from filename1,.

Generally, you need to think about your problem in a slightly different
way. Instead of thinking about creating variables called data1 and data2,
think about creating a dictionary called "data" which contains three
elements. For example:

data = {}
for n in range(3):
data[n] = read_from( 'filename%d' % n )

It IS possible to create variables on the fly, but except in very special
situations, it is almost never the right way to do things.
 
W

William Park

John Bausano said:
Hello all,



I've been using Ansys which is a commercial FEA package which can be
controlled through its own scripting language they call APDL. Now I'm
trying to write some stand alone code in Python to supplement my current
efforts.



In Ansys I can do something like this.



*do,n,1,3 #loop
through n

*dim,data%n%,1000,2 #creates variables
arrays data1(1000,2), data2(1000,2)..

*vread,data%n%,filename%n% #fills arrays with data
from filename1,.


I await English translation of the above.

--
William Park <[email protected]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,007
Latest member
Elvis60357

Latest Threads

Top