Changing BDF PARAM

201 views
Skip to first unread message

kay

unread,
Jul 26, 2013, 6:04:54 AM7/26/13
to pynastra...@googlegroups.com
Hi,

I have a problem in changing solver PARAM values in the BDF files. I did not find anything useful in the documentation.

My goal:
change PARAM       POST       0
to PARAM       POST       -1

BDF.params seems to give access to the parameters:
$ print  BDF.params
{'POST': $ Direct Text Input for Bulk Data
PARAM       POST       0
, 'PRTMAXIM': PARAM   PRTMAXIM     YES
}

What I tried:

BDF.params["POST"].value = -1

but this did not change anything, as the output of BDF.params stays the same.
$ print  BDF.params
{'POST': $ Direct Text Input for Bulk Data
PARAM       POST       0
, 'PRTMAXIM': PARAM   PRTMAXIM     YES
}

I can change the string in BDF.params["POST"] but I'd rather use dedicated methods to set values.

I also tried 
newPARAM = pyNastran.bdf.cards.params.PARAM
newPARAM.key = "POST"
newPARAM.value = -1
BDF.add_PARAM(newPARAM, allowOverwrites=True)

but this adds the obejct to the value, whicht of course does not work:
$ print  BDF.params
{'POST': <class 'pyNastran.bdf.cards.params.PARAM'>
, 'PRTMAXIM': PARAM   PRTMAXIM     YES
}

Thanks for any input,
kay



steve

unread,
Jul 26, 2013, 11:43:35 AM7/26/13
to pynastra...@googlegroups.com
There's are bugs in the code that was introduced in v0.6 to support PARAM cards with multiple fields.  I need to push a bug release anyways, so that'll be in there.

In the current version of the code, the correct way to change the parameter is:

BDF.params["POST"].values[0] = -1


I'm updating the code to allow:
BDF.params["POST"].update_values(value1, value2=None)

as well as (broken in v0.6.1):
card = None
data = ['POST', -1]
newPARAM = PARAM(card, data, comment='')
BDF.params['POST'] = newPARAM

Additionally, as changing the self.value parameter does not properly update the self.values list of parameters, self.value will be removed (as well as self.value1 and self.value2 for length=2 PARAMs).

Steve

kay

unread,
Jul 26, 2013, 4:58:08 PM7/26/13
to pynastra...@googlegroups.com
Very well!
I wasn't aware which values/lists are used to update and which ones are just representations.
Removing redundant values and having a method that updates everything would be nice.
Thank you Steve!

kay

unread,
Aug 6, 2013, 9:54:26 AM8/6/13
to pynastra...@googlegroups.com
Just an additional info for users that want to add PARAMS in version v0.6.1 (broken according to Steve) :

A workaround is to use an existing param, then modify it and add it to the BDF.params.
Example to add: PARAM, BUCKLING, 1 

# deepcopy and existing param card
param = copy.deepcopy(BDF.params["POST"])
# set the key and value of this card
param.key = 'BUCKLING'
param.value = 1
# add the card to BDF.params
BDF.params['BUCKLING'] = param
Reply all
Reply to author
Forward
0 new messages