0

the code written was

f = open('data_x.txt', 'r')
values=f.read() 
values=f.readline() 

and when tring to call in other step in abaqus script

mdb.models['Model-1'].SmoothStepAmplitude(data=('data_x'), name='Amp-x',    timeSpan=STEP)

its giving an error TypeError:data; found string, expecting tuple

  • aside from your actual question, you are not reading correctly. `f.read` reads the entire file. The following `readline` will then always return an end of file or an error, so `values` does not hold the data you think. – agentp Jul 20 '16 at 12:29

2 Answers2

1

When you want to pass data to SmoothStepAmplitude, you need to pass the data you read from a file or get in some other way. It's not possible to define a name of a file and make Abaqus read it for you.

If you look at the documentation (Abaqus Scripting Reference, 3.10.1), you will see that data needs to be a sequence of pairs of floats.

If you defined the data manually, it would be something like:

my_data = [(10, 1), (20, 2)]
mdb.models['Model-1'].SmoothStepAmplitude(data=my_data, name='Amp-x',    timeSpan=STEP)
hgazibara
  • 1,832
  • 1
  • 19
  • 22
  • thats fine but we dont want to feed it manually thats why we have created a loop in python and the output from program is stored in data_x.txt form and trying to feed it into abaqus script as far as errors seen this time its stating data is found in term of strings but expecting tuple.so,is there any solution for this. – Manohar Reddy Jul 20 '16 at 11:18
  • 1
    @ManoharReddy exactly, the point is you need to give `data=` the *data* (which it appears you intended to assign to `values`), do not give it the name of the file. – agentp Jul 20 '16 at 12:25
0

You should make sure that the data at each NODE is stored as a list or tuple;you could print your data to see if they are in the correct form.

For example, Data in myData.txt are:

  • 1 0.01
  • 2 0.02
  • 3 0.03

If you want to read the second column of these datas, like this:

f = open(r"myData.txt", "r")
lines=f.readlines()

values=[]
for line in lines:
   values.append(line.split( ))  

# for j in range(len(values)):
    # print ('values:',j,values[j][1])

myData =[0]*len(lines)
for i in range(len(myData)):
    myData[i]=[(values[i][1])]

print('myData:',myData)

the true form is [['0.01'], ['0.02'], ['0.03']]; but the sequence ['0.01', '0.02', '0.03'] may cause error.

Good luck!