SteveDoyle2 / pyNastran

A Python-based interface tool for Nastran's file formats
Other
384 stars 147 forks source link

add_cbeam method handles g0/x differently than add_cbar #758

Closed ChristopheBozec closed 6 months ago

ChristopheBozec commented 6 months ago

When writing the card for a CBEAM, the orientation vector is not exported:

from pyNastran.bdf.bdf import BDF
nastran_model = BDF()
nastran_model.add_cbeam(1001, 1001, [1, 2], [0., 1., 0.], '')
nastran_model.write_bdf('output_test_cbeam.bdf', size=8)

The exported file looks like:

$pyNastran: version=msc
$pyNastran: punch=True
$pyNastran: encoding=utf-8
$pyNastran: nnodes=0
$pyNastran: nelements=1
$ELEMENTS
CBEAM       1001    1001       1       2

I would have expected to get: CBEAM 1001 1001 1 2 0. 1. 0.

Am I doing something wrong ?

SteveDoyle2 commented 6 months ago

Try specifying x and g0 explicitly. There are other parameters that those terms than you might br setting. Options also get moved around, so it’s good practice regardless.

It also looks like you’re specifically offt as ‘’, which is not a valid option. ‘GGG’ is the default.

On Tue, Feb 20, 2024 at 09:18 ChristopheBozec @.***> wrote:

When writing the card for a CBEAM, the orientation vector is not exported:

from pyNastran.bdf.bdf import BDF nastran_model = BDF() nastran_model.add_cbeam(1001, 1001, [1, 2], [0., 1., 0.], '') nastran_model.write_bdf('output_test_cbeam.bdf', size=8)

The exported file looks like:

$pyNastran: version=msc $pyNastran: punch=True $pyNastran: encoding=utf-8 $pyNastran: nnodes=0 $pyNastran: nelements=1 $ELEMENTS CBEAM 1001 1001 1 2

I would have expected to get: CBEAM 1001 1001 1 2 0. 1. 0.

Am I doing something wrong ?

— Reply to this email directly, view it on GitHub https://github.com/SteveDoyle2/pyNastran/issues/758, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAICUWMT5S23YPR4CF6YMHTYUTLE5AVCNFSM6AAAAABDRRUPL6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGE2DIOBYGM4TEMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

SteveDoyle2 commented 6 months ago

Actually, most likely your offt blank option is actually g0 and that is taking priority over x.

On Tue, Feb 20, 2024 at 09:52 Steven Doyle @.***> wrote:

Try specifying x and g0 explicitly. There are other parameters that those terms than you might br setting. Options also get moved around, so it’s good practice regardless.

It also looks like you’re specifically offt as ‘’, which is not a valid option. ‘GGG’ is the default.

On Tue, Feb 20, 2024 at 09:18 ChristopheBozec @.***> wrote:

When writing the card for a CBEAM, the orientation vector is not exported:

from pyNastran.bdf.bdf import BDF nastran_model = BDF() nastran_model.add_cbeam(1001, 1001, [1, 2], [0., 1., 0.], '') nastran_model.write_bdf('output_test_cbeam.bdf', size=8)

The exported file looks like:

$pyNastran: version=msc $pyNastran: punch=True $pyNastran: encoding=utf-8 $pyNastran: nnodes=0 $pyNastran: nelements=1 $ELEMENTS CBEAM 1001 1001 1 2

I would have expected to get: CBEAM 1001 1001 1 2 0. 1. 0.

Am I doing something wrong ?

— Reply to this email directly, view it on GitHub https://github.com/SteveDoyle2/pyNastran/issues/758, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAICUWMT5S23YPR4CF6YMHTYUTLE5AVCNFSM6AAAAABDRRUPL6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGE2DIOBYGM4TEMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ChristopheBozec commented 6 months ago

I tried with nastran_model.add_cbeam(1001, 1001, [1, 2], [0., 1., 0.]) first but I was getting an error because g0 was not defined as it is not optional, so I tried blanking it with '' but that might be overriding the vector, indeed. How am I supposed to write it in order to specify only the vector ?

SteveDoyle2 commented 6 months ago

Explicitly call out the optional arguments. Optional arguments go in order of how they are listed in the function. G0 is an integer and not a string.

On Tue, Feb 20, 2024 at 10:45 ChristopheBozec @.***> wrote:

I tried with nastran_model.add_cbeam(1001, 1001, [1, 2], [0., 1., 0.]) first but I was getting an error because g0 was not defined as it is not optional, so I tried blanking it with '' but that might be overriding the vector, indeed. How am I supposed to write it in order to specify only the vector ?

— Reply to this email directly, view it on GitHub https://github.com/SteveDoyle2/pyNastran/issues/758#issuecomment-1954852586, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAICUWNFGCK3QVLVUPOWUWLYUTVMLAVCNFSM6AAAAABDRRUPL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJUHA2TENJYGY . You are receiving this because you commented.Message ID: @.***>

ChristopheBozec commented 6 months ago

My problem is that neither X nor g0 are optional, therefore I have to define a g0, and it always overrides X. I am a beginner in python so I might be missing something obvious. How would you generate the line below ? CBEAM 1001 1001 1 2 0. 1. 0.

SteveDoyle2 commented 6 months ago

One of them is required, not both. In your case, g0 should be None.

These are all fine.

nastran_model.add_cbeam(1001, 1001, [1, 2], [0., 1., 0.])

nastran_model.add_cbeam(1001, 1001, [1, 2], x=[0., 1., 0.])

nastran_model.add_cbeam(1001, 1001, [1, 2], x=[0., 1., 0.], g0=None)

nastran_model.add_cbeam(1001, 1001, [1, 2], x=[0., 1., 0.], g0=None, offt='GGG')

On Tue, Feb 20, 2024 at 11:27 AM ChristopheBozec @.***> wrote:

My problem is that neither X nor g0 are optional, therefore I have to define a g0, and it always overrides X. I am a beginner in python so I might be missing something obvious. How would you generate the line below ? CBEAM 1001 1001 1 2 0. 1. 0.

— Reply to this email directly, view it on GitHub https://github.com/SteveDoyle2/pyNastran/issues/758#issuecomment-1954913185, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAICUWJOKIHLVOBYVSNS3B3YUT2LXAVCNFSM6AAAAABDRRUPL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJUHEYTGMJYGU . You are receiving this because you commented.Message ID: @.***>

ChristopheBozec commented 6 months ago

Your first two lines return the same error I was getting : TypeError: AddCards.add_cbeam() missing 1 required positional argument: 'g0'

The third one works, I will go with that. Thanks a lot !

SteveDoyle2 commented 6 months ago

Oh...gotcha...those first two are no good. They would work if it was a CBAR. They should be optional. I'll update that.

These are fine though.

nastran_model.add_cbeam(1001, 1001, [1, 2], [0., 1., 0.], None)

nastran_model.add_cbeam(1001, 1001, [1, 2], x=[0., 1., 0.], g0=None)

On Tue, Feb 20, 2024 at 12:08 PM ChristopheBozec @.***> wrote:

Your first two lines return the same error I was getting : TypeError: AddCards.add_cbeam() missing 1 required positional argument: 'g0'

The third one works, I will go with that. Thanks a lot !

— Reply to this email directly, view it on GitHub https://github.com/SteveDoyle2/pyNastran/issues/758#issuecomment-1954972536, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAICUWM3LIS7HEPXMGSTSJ3YUT7C3AVCNFSM6AAAAABDRRUPL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJUHE3TENJTGY . You are receiving this because you commented.Message ID: @.***>

SteveDoyle2 commented 6 months ago

I updated the CBEAM to have similar defaults as the CBAR on the add_card method.