spacether/pycalculix

Wrong formating on 32bit windows

AVozelj opened this issue · 6 comments

I am getting (for hole in plate full example):
File "...\WinPython-32bit-3.4.2.4\python-3.4.2\lib\site-packages\pycalculix\results_file.py", line 772, in __get_vals
substr = float(substr)

ValueError: could not convert string to float: '0-2.22222E+0'

Reading of row 13 in .frd file is a problem (same issue on XP and Win7 32bit).

After some investigation i found out that 32bit ccx cause a problem - frd output is not consistent.
(does not follow fixed format specified)

Maybe we should add some kind of frd cleaning function:

def editfrdline(self,line):
    num=[]
    stri=line
    if stri[1:3]=='-1':
        stri=stri[13:]
        for i in range(0,2):
            fid=stri.find('E')
            powl=4
            if stri[fid+1]=='-' or stri[fid+1]=='+':
                powl+=1
            val1=stri[:fid+powl]
            stri=stri[fid+powl:]
            num.append(float(val1))
        num.append(float(stri))
        return line[0:13]+"%12.5e" % num[0]+"%12.5e" % num[1]+"%12.5e" % num[2]

above works for reparing of displacement results and goes line by line ... a little bit time consuming, I know.

Is the error in the 32 bit formatting consistent? If so we could hard code it into the environment module.

No, some rows in *.frd are OK, some not. Row length differs. As I see it depends on value.

Do you now pandas? Just another idea how we can read results in database manner. I am quite fan of it. Today I implement temporary solution of how to read displacement on 32 bit. Once you read data in dataframe you can do many things, for example calculate equivalent stress.

Per the file format documentation:
CGX 2.7 documentation, Results Format, Nodal Results
The results using 32 bit CCX are producing 'long format' format=1 results

The formatting for displacements stress etc should be:
(1X,I2,I10,6E12.5)

But we are seeing:
Formatting: (1X,I2,I10,1E12.5,1E13.5,1E13.5)
Fields: unused_field,unused_field, node number, data1, data2, data3, data4, data5, data6
It appears that the second and third data columns sometimes take up 13 spaces, sometimes 12
This may be a problem with all columns

Can you implement a solution in regex rather than with pandas? Pandas adds another required include, which I'd like to avoid.

I read about frd formats.
Pandas was just a suggestion.

I fixed this issue in the below commit:
2f2796c
Frd files are now edited to have the correct fixed formatting on win32 systems.