Abaqus/Python read MappedField data from csv-file

1k views Asked by At

I want to specify the following analytical field with Python (Abaqus):

mdb.models['Model-1'].MappedField(name='AnalyticalField-1', description='', 
        regionType=POINT, partLevelData=False, localCsys=None, 
        pointDataFormat=XYZ, fieldDataType=SCALAR, xyzPointData=((0.0, 0.0, 
        0.0, 100.0), (-0.5, -0.5, 0.0, 50.0), (0.5, -0.5, 0.0, 50.0), (-0.5, 
        0.5, 0.0, 50.0), (0.5, 0.5, 0.0, 50.0)))

How can I do this by reading the xyzPointData from a csv-file, which looks like

[Data]
X , Y , Z , Temperature 

0.0, 0.0, 0.0, 100.0
-0.5, -0.5, 0.0, 50.0
0.5, -0.5, 0.0, 50.0 
-0.5, 0.5, 0.0, 50.0
0.5, 0.5, 0.0, 50.0 

? (Certainly I have more than only five points) Perhaps there is a simple way, but I didn't find the solution yet. So thanks for your help.

1

There are 1 answers

0
SoB On

agentp: not only how to read, but rather get it into a suitable form. mquantin: thank you for the keywords. That is what I searched for. A solution is:

path = "/home/user/test.csv"
datalist = []
with open(path, "rb") as fp:
    for row in fp.readlines():
        tmp = row.split(",")
        try:
            datalist.append((float(tmp[0]), float(tmp[1]), float(tmp[2]), float(tmp[3])))
        except:pass

mdb.models['Model-1'].MappedField(name='AnalyticalField-1', description='', 
        regionType=POINT, partLevelData=False, localCsys=None, 
        pointDataFormat=XYZ, fieldDataType=SCALAR, xyzPointData=datalist)