pyNastran
pyNastran copied to clipboard
op4 sparse ascii and binary readers failing on bigger stiffness matrices
I'm (again) trying to read the (l-level) stiffness matrix in linear statics KLL (pulled out right before the SSG3 call as either sparse ascii or sparse binary (i don't care if binary or ascii here)) from an .op4. Basically I'm doing the same as in my previous issue but the matrices are larger now with KLL having 89034 rows and columns. While everything worked fine up to 22k rows and columns, I'm getting the following tracebacks when doing
from pyNastran.op4.op4 import OP4 op4 = OP4() KLL = op4.read_op4('KLL.op4','KLL','default')
For sparse binary KLL:
Traceback (most recent call last):
File "
For sparse ascii KLL:
Traceback (most recent call last):
File "
I am glad to provide the model with the DMAP code required to output the stiffness matrix (I cannot reproduce the error with the static solid shell bar as this seems to be a problem related to the matrix size). I appended the matrices.
Kind regards, Chris
The ASCII file is fixed. There was an issue with the following:
Input-logical-default=FALSE. BIGMAT is applicable only when IUNIT < 0. BIGMAT=FALSE selects the format that uses a string header as described under Remark 1. But, if the matrix has more than 65535 rows, then BIGMAT will automatically be set to TRUE regardless of the value specified.
I'm not sure what's going on with the binary file yet. It gets further, but it's still wrong.
What exactly had to be fixed for the ASCII file to be read? Something in the .op4 reader, the .op4 file of the matrix or the DMAP statements to write the matrix?
I gather that op4._read_matrix_ascii does not recognize the BIGMAT property because the number of rows is not negative in record 1 as it somehow should be according to the DMAP guide. Therefore op4._get_irow_small_ascii is called and fails to read the records of the BIGMAT ASCII file, right?
For now I just hardcoded is_big_mat = True in _read_matrix_ascii and it worked
Oh...ooops...I never committed it.
From line 170 of op4.py in the new version
if nrows < 0: # if less than 0, big
is_big_mat = True
elif nrows > 0:
is_big_mat = False
-
if nrows > 65535:*
-
is_big_mat = True* else: raise RuntimeError('unknown BIGMAT. nRows=%s' % nrows) if self.debug: self.log.info('is_big_matrix = %s' % is_big_mat)
I added the bolded lines
On Tue, Mar 22, 2016 at 11:42 AM, wrtc90 [email protected] wrote:
What exactly had to be fixed for the ASCII file to be read? Something in the .op4 reader, the .op4 file of the matrix or the DMAP statements to write the matrix?
I gather that op4._read_matrix_ascii does not recognize the BIGMAT property because the number of rows is not negative in record 1 as it somehow should be according to the DMAP guide. Therefore op4._get_irow_small_ascii is called and fails to read the records of the BIGMAT ASCII file, right?
For now I just hardcoded is_big_mat = True in _read_matrix_ascii and it worked
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/SteveDoyle2/pyNastran/issues/293#issuecomment-199957152
Oooh ok. Thanks!
Hello,
I follow up this conversation on an extra error when reading op4 containing big matrices. The error I get is the following:
"in _read_matrix_ascii ncols, nrows, form, matrix_type = line[0:32].split() ValueError: not enough values to unpack (expected 4, got 3)"
This is due to the fact that the line of my op4 file contains the following string: line = ' 9552018-9552018 6 1KAA 1P,3E22.15'
As a consequence, the algorithm is not able to split correctly nrows and ncols, and gives back the following:
['9552018-9552018', '6', '1KAA']
instead of: ['9552018', '-9552018', '6', '1KAA']
Could that be fixed?
Thanks, Fabiola Cavaliere