pyNastran v0.6.0 has been released!

43 views
Skip to first unread message

Steve Doyle

unread,
May 8, 2013, 1:07:23 AM5/8/13
to pynast...@googlegroups.com

Steve Doyle

unread,
May 8, 2013, 1:32:48 AM5/8/13
to pynast...@googlegroups.com
oops :)

pyNastran v0.6 is now released.  pyNastran is a free open-source Python wrapper for the Nastran BDF, OP2, and OP4.

The BDF Reader supports roughly 220 cards and links them together in order to make it easier to access.  An example:

>>> bdf = BDF()
>>> bdf.read_bdf(bdf_filename_in)
>>> node2 = bdf.nodes[2]
>>> print node2
GRID           1         120.322-4.82872 1.13362
>>> print node2.Position()
array([120.322, -4.82872, 1.13362])
>>> node2.nid = 4
>>> print node2  # change the node ID
GRID           4         120.322-4.82872 1.13362
>>> bdf.write_bdf(bdf_filename_out)

You can change any of the parameters stored on the cards, which makes it a lot easier run an optimization problem.  There are methods to interface with the case control deck as well, so you can create new/edit/delete load cases.  The BDF reader also supports INCLUDE files and type checking, which makes it a lot easier to debug a Nastran BDF.


The OP2 reader is most popular feature.  It reads the vast majority of tables (stress, strain, displacement, velocity, accelration, eigenvalues, eigenvectors, spc/mpc forces, etc.) in both their static form (e.g. SOL 101) and their "transient" form.  A "transient" variable could be a time, load step or a frequency.  Each unique OP2 data table is stored as a separate result, so if you can identify it in the F06, there's a good chance the OP2 reader will read it properly.

>>> op2 = OP2()
>>> op2.read_op2(op2_filename_in)
>>> op2.write_f06(f06_filename_out)
>>> stress = op2.plateStress[3]  # get the plate stress for load case 3
>>> eid = 100
>>> iLayer = 1
>>> print stress.oxx[eid][iLayer] # ovm is a dictionary of von 
2100.0


I hope people find it useful.  If you're stuck trying to use it or have a suggestion, let me know.  Best of all, it's free.

Steve Doyle


On Tuesday, May 7, 2013 10:07:23 PM UTC-7, Steve Doyle wrote:

jonatha...@gmail.com

unread,
May 8, 2013, 8:03:55 PM5/8/13
to pynast...@googlegroups.com
Steve,

Glad to see the new release! I have a question about something I've had to work around with previous versions.

For example, oftentimes I find myself working with a subsection of the model (typically a bdf that is INCLUDEd in the main input deck) that has nodes and elements defined, but not the materials or properties. Does the bdf reader in v0.6 support this?

-Jonathan

Steve Doyle

unread,
May 8, 2013, 8:20:30 PM5/8/13
to pynast...@googlegroups.com, jonatha...@gmail.com
Jonathan,

No it does not, but it doesn't sound very hard.  I'm thinking something along these lines:

# this is supported.  punch=True skips the executive and case control decks
bdf.read_bdf(bdfname, xref=True/False, punch=True)

# the new option
bdf.read_bdf(bdfname, xref='partial', punch=True)

The xref='partial' making the assumption that cards may exist, but they're not required to.  This obvious disadvantage being the code won't yell at you if you're missing something, you do want.

Thoughts?

Steve

jonatha...@gmail.com

unread,
May 9, 2013, 7:13:56 PM5/9/13
to pynast...@googlegroups.com, jonatha...@gmail.com
Steve,

My feeling is that the fewer options the user has to be aware of, the easier it is for the user to make the code part of their workflow. I quite like the way Femap handles bulk data in these situations. Femap is agnostic as to whether or not all the pieces of the model is there, and the workflow is the same regardless - just click file->import and select the bulk data file. It would be nice if the reader read everything it could, and then if the user queried something that was undefined, it would merely print a warning message.

On a related note, I've been working with a super simple bdf that just has three lines. I'm getting an error that the 'BDF' object has no attribute '_line_streams'. You've clearly put a lot of effort into reformulating the BDF reader, and I'm unfamiliar with some of the new functionality. It will take me a while to understand the new program flow and why this error is getting thrown up.



GRID 1 0 0. 0. 0. 0
GRID 2 0 1. 0. 0. 0
CBAR 1 1 1 2 0. 1. 0.

Steven Doyle

unread,
May 9, 2013, 8:55:45 PM5/9/13
to jonatha...@gmail.com, pynast...@googlegroups.com
Jonathan,

I think the trouble I'm having with how o implement the functionality you're asking for is, what happens when element.Mass() is called and the property/node doesn't exist.  I can return None or 0, but both of those have problems.  I'm assuming IMAT supports methods like CBAR.Mass().

Also, what's are some of the function signatures for IMAT (e.g. read/write the BDF, edit a node, get the position, get the mass of a CBAR)?  I'm debating on whether or not to remove cross-referencing in order to improve performance.

You're in a block of code that should only execute after a crash.  It's for closing files in a way that doesn't bleed memory.  Do you have a script that can reproduce this problem?  Paul had the same issue and I've not been able to get the _line_streams error.  If you just comment out the call to _cleanup_file_streams, you should get an error that makes more sense.

Steve



--
You received this message because you are subscribed to the Google Groups "pyNastran dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pynastran-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



jonatha...@gmail.com

unread,
May 16, 2013, 4:31:47 PM5/16/13
to pynast...@googlegroups.com, jonatha...@gmail.com
Steve,

Sorry it's taken me so long to get back to you. I thought I'd provide you with some feedback that might help when you talk about pyNastran at the next pyloads webEx.

If you make a bdf file called '1bar2grid.bdf' using the sample example I posted previously with 2 grid points and 1 bar element, here are some example scripts and the errors I receive.

from pyNastran.bdf.bdf import BDF
mesh = BDF(debug=True, log=None)
mesh.read_bdf('1bar2grid.bdf',xref=True,punch=True)
ERROR: 'BDF' object has no attribute _line_streams'

from pyNastran.bdf.bdf import BDF
mesh = BDF(debug=True, log=None)
mesh.readBDF('1bar2grid.bdf',xref=True,punch=True)
ERROR: 'BDF' object has no attribute _line_streams'

from pyNastran.bdf.bdf import BDF
mesh = BDF(debug=True, log=None)
mesh.readBDF('1bar2grid.bdf',xref=False,punch=True)
ERROR: 'BDF' object has no attribute _line_streams'

It seems that running the first script causes pyNastran to get "stuck" in the _line_streams error. If I open a new Python session, I can run the third script without any issue.

Steve Doyle

unread,
May 16, 2013, 4:52:08 PM5/16/13
to pynast...@googlegroups.com
Jonathan,

I was finally able to reproduce the error, but only when I ran:

from pyNastran.bdf.bdf import BDF
mesh = BDF(debug=True, log=None)

mesh.read_bdf('bar.bdf',xref=True,punch=True)
mesh.read_bdf('bar.bdf',xref=False,punch=True)

The second call to read_bdf was causing it to fail.  I updated the cleanup step so the error message should be clearer, but I'm not sure it's going to fix the error.  Each time you call read_bdf, you must have a different set of files, so the following should work:

mesh1 = BDF(debug=True, log=None)
mesh1.read_bdf('bar.bdf',xref=True,punch=True)

mesh2 = BDF(debug=True, log=None)
mesh2.read_bdf('bar.bdf',xref=False,punch=True)

Try the attached file and see if it works...

Steve


On Tuesday, May 7, 2013 10:07:23 PM UTC-7, Steve Doyle wrote:

bdf.py
Reply all
Reply to author
Forward
0 new messages