A Mystran writer error when using 1d element

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
johnwang
Posts: 808
Joined: Sun Jan 27, 2019 12:41 am

A Mystran writer error when using 1d element

Postby johnwang » Mon Sep 13, 2021 3:18 am

Edit:

There is error to apply Force at node.

Code: Select all

model.add_cbar(9, 1, (5, 4), x=[0.0, 0.0, 1.0], g0=None)


13:24:42  
13:24:42  [('node load on shape: BooleanFragments:Vertex5', {5: 1.0})]
13:24:42  Exception in thread Thread-31:
13:24:42  Traceback (most recent call last):
13:24:42    File "C:\FreeCAD_0.20.25541_Win-LPv12.5.4_vc17.x-x86-64\bin\lib\threading.py", line 932, in _bootstrap_inner
13:24:42      self.run()
13:24:42    File "C:\FreeCAD_0.20.25541_Win-LPv12.5.4_vc17.x-x86-64\bin\lib\threading.py", line 870, in run
13:24:42      self._target(*self._args, **self._kwargs)
13:24:42    File "C:\FreeCAD_0.20.25541_Win-LPv12.5.4_vc17.x-x86-64\Mod\Fem\femsolver\task.py", line 118, in protector
13:24:42      self.run()
13:24:42    File "C:\FreeCAD_0.20.25541_Win-LPv12.5.4_vc17.x-x86-64\Mod\Fem\femsolver\mystran\tasks.py", line 94, in run
13:24:42      path = w.write_solver_input()
13:24:42    File "C:\FreeCAD_0.20.25541_Win-LPv12.5.4_vc17.x-x86-64\Mod\Fem\femsolver\mystran\writer.py", line 110, in write_solver_input
13:24:42      model = add_con_force.add_con_force(pynasf, model, self)
13:24:42    File "C:\FreeCAD_0.20.25541_Win-LPv12.5.4_vc17.x-x86-64\Mod\Fem\femsolver\mystran\add_con_force.py", line 75, in add_con_force
13:24:42      exec(pynas_code)
13:24:42    File "<string>", line 4, in <module>
13:24:42  AttributeError: 'NoneType' object has no attribute 'add_force'
Regards,

John
Last edited by johnwang on Mon Sep 13, 2021 1:01 pm, edited 9 times in total.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
aerospaceweeb
Posts: 91
Joined: Fri Apr 09, 2021 3:26 am

Re: Need PBAR for CBAR in Mystran writer

Postby aerospaceweeb » Mon Sep 13, 2021 3:45 am

John,

I was just noticed this and wasn't quite sure what was going on.

I'd like to add to this that the bdf writer is going to need something more than just "default to writing pbar" as nastran/mystran has the unfortunate difficult of changing what the element type is based on the property that's applied to it.

You can't apply a PBUSH property card to a CBAR and you can't apply a PBAR to a CBUSH.

I'm not quite sure what the solution to this could be.
User avatar
johnwang
Posts: 808
Joined: Sun Jan 27, 2019 12:41 am

Re: Need PBAR for CBAR in Mystran writer

Postby johnwang » Mon Sep 13, 2021 7:23 am

aerospaceweeb wrote: Mon Sep 13, 2021 3:45 am I was just noticed this and wasn't quite sure what was going on.
Sorry, I should use ElementGeometry1D. The error is from this line: exec(pynas_code)
cbar.jpg
cbar.jpg (39.25 KiB) Viewed 800 times
cbar.FCStd
(20.63 KiB) Downloaded 9 times
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
mesheb82
Posts: 9
Joined: Tue Jul 27, 2021 4:18 am

Re: Need PBAR for CBAR in Mystran writer

Postby mesheb82 » Tue Sep 14, 2021 5:19 pm

aerospaceweeb wrote: Mon Sep 13, 2021 3:45 am John,

I was just noticed this and wasn't quite sure what was going on.

I'd like to add to this that the bdf writer is going to need something more than just "default to writing pbar" as nastran/mystran has the unfortunate difficult of changing what the element type is based on the property that's applied to it.

You can't apply a PBUSH property card to a CBAR and you can't apply a PBAR to a CBUSH.

I'm not quite sure what the solution to this could be.
If you were cross-referenced (which you'd do before you write the model out), you could call the _verify_bdf() method or do something which has slightly different assumptions (e.g., assume you don't have 0 length CBARs, 0 volume CTETRAs, invalid PBARLs). It'll more or less run the following check (among many others):

assert cbar_element.pid_ref.type in ['PBAR', 'PBARL', 'PBRSECT'], cbar_element

Patran/FEMAP refuse to write out elements that have no properties. They just get dropped with a warning. I'd take an approach of either don't let them write a model at all if there is an obvious error or filter the problematic cards with a warning.
aerospaceweeb
Posts: 91
Joined: Fri Apr 09, 2021 3:26 am

Re: A Mystran writer error when using 1d element

Postby aerospaceweeb » Wed Sep 15, 2021 12:54 am

@mesheb82

Understood.
I actually prefer something slightly different. I think I want to default to making them be cbushes with a default low stiffness, if there's no other properties applied, or write them out commented.

At the moment though, I have no idea how to even properly apply a 1d element property AT ALL to anything in freecad that isn't exclusively 1d elements. I can't even save out a bdf if it has more than one "mesh entity" in it, but I also can't apply multiple "properties" to different elements inside of one mesh entity... I think.
User avatar
johnwang
Posts: 808
Joined: Sun Jan 27, 2019 12:41 am

Re: Need PBAR for CBAR in Mystran writer

Postby johnwang » Wed Sep 15, 2021 3:48 am

mesheb82 wrote: Tue Sep 14, 2021 5:19 pm
Found out only "Rectangular" is supported ATM.

But when write PBARL card, the continuation sign at 10th Word ('+CONT1') of the first line and 1st word of the second line are not outputted.

Code: Select all

13:34:27  beamsection
13:34:27  # pbarl card, properties of a simple beam element (CBAR entry)
# defined by cross-sectional dimensions
dim = [10.0, 25.0]
model.add_pbarl(pid=1, mid=1, Type="BAR", dim=dim, nsm=0.0)
# pbarl.validate()


13:34:27  
13:34:27  <pyNastran.bdf.bdf.BDF object at 0x0000022761517550>
It is like:

Code: Select all

pyNastran.bdf.bdf.BDF.add_pbarl(pid=1, mid=1, Type="BAR", dim=dim, nsm=0.0)
Could you have a look? Thanks.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
johnwang
Posts: 808
Joined: Sun Jan 27, 2019 12:41 am

Re: A Mystran writer error when using 1d element

Postby johnwang » Wed Sep 15, 2021 5:23 am

Finally created a case file.

Saw a warning about A $ SIGN IN COL 1 FOLLOWED BY AN UPPER CASE LETTER. Don't know if FC can control this or rely on pyNastran?

mesh.dbf

Code: Select all

$pyNastran: version=msc
$pyNastran: punch=False
$pyNastran: encoding=utf-8
$pyNastran: nnodes=5
$pyNastran: nelements=9
$EXECUTIVE CONTROL DECK
SOL 101
CEND
$CASE CONTROL DECK
ECHO = NONE
TITLE = pyNastran for generating solverinput for for Mystran
SUBCASE 1
    DISPLACEMENT(SORT1,REAL) = ALL
    LOAD = 1
    SPC = 1
    SPCFORCES(SORT1,REAL) = ALL
    STRESS(SORT1,REAL,VONMISES,BILIN) = ALL
    SUBTITLE = Default
BEGIN BULK
$PARAMS
PARAM       POST      -1
$NODES
GRID           1              0.      0.      0.
GRID           2           1500.      0.      0.
GRID           3              0.   1500.      0.
GRID           4           1500.   1500.      0.
GRID           5            750.    750.   1500.
$ELEMENTS
CBAR           1       1       1       2      0.      0.      1.
CBAR           2       1       3       4      0.      0.      1.
CBAR           3       1       1       3      0.      0.      1.
CBAR           4       1       2       4      0.      0.      1.
CBAR           5       1       1       4      0.      0.      1.
CBAR           6       1       5       1      0.      0.      1.
CBAR           7       1       5       2      0.      0.      1.
CBAR           8       1       5       3      0.      0.      1.
CBAR           9       1       5       4      0.      0.      1.
$PROPERTIES
PBAR           1       14.9087-4
$MATERIALS
MAT1           1 210000.              .3
$LOADS
LOAD           1      1.      1.       2
FORCE          2       5              1.      0.      0.      1.
$SPCs
SPCADD         1
ENDDATA
Mystran output:

Code: Select all

   915150400

 MYSTRAN Version 12.1     Feb 12 2021 MYSTRAN developed by Dr Bill Case
*** Please report any problems to the author at dbcase29@gmail.com ***                                                                                                                                                                                          

 >> MYSTRAN BEGIN  :  9/15/2021 at 15: 4: 0.347 The input file is Mesh.bdf                                                                                                                                                                                                                                                        


 >> LINK  0 BEGIN

 *WARNING    : BE CAREFUL WITH LINES THAT BEGIN WITH A $ SIGN IN COL 1 FOLLOWED BY AN UPPER CASE LETTER IN EXEC OR CASE CONTROL.
               THE LINE CAN BE MISINTERPRETED AS A DIRECTIVE FOR THE BANDIT GRID RESEQUENCING ALGORITHM.
               SEE THE BANDIT.PDF FILE INSTALLED WHEN YOU RAN SETUP.EXE TO INSTALL MYSTRAN
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
bernd
Posts: 12215
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: A Mystran writer error when using 1d element

Postby bernd » Wed Sep 15, 2021 12:22 pm

FC does create a pyNastran file and calls pyNastran with exec to create the Mystran input file.
User avatar
johnwang
Posts: 808
Joined: Sun Jan 27, 2019 12:41 am

Re: A Mystran writer error when using 1d element

Postby johnwang » Wed Sep 15, 2021 12:41 pm

bernd wrote: Wed Sep 15, 2021 12:22 pm FC does create a pyNastran file and calls pyNastran with exec to create the Mystran input file.
C:\FreeCAD_0.20.25541_Win-LPv12.5.4_vc17.x-x86-64\Mod\Fem\femsolver\mystran\add_femelement_geometry.py

For this file, I made some changes, now support Rectangular, Circular and Pipe section with PBAR.

If use PBARL, I suggest the section list should add Rectangular_L Circular_L and Pipe_L to distinguish.

One question for the default value of Pipe: Diameter 25mm Thickness 10mm. Is this a popular size, only 5mm hole?

I am hoping there is a choice of CBAR or CROD for 1D element.
Also need add_con_displacement.py.
pipe.jpg
pipe.jpg (14.86 KiB) Viewed 380 times
add_femelement_geometry.py
(8.84 KiB) Downloaded 6 times
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
bernd
Posts: 12215
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: A Mystran writer error when using 1d element

Postby bernd » Wed Sep 15, 2021 6:18 pm

johnwang wrote: Wed Sep 15, 2021 12:41 pm
bernd wrote: Wed Sep 15, 2021 12:22 pm FC does create a pyNastran file and calls pyNastran with exec to create the Mystran input file.
C:\FreeCAD_0.20.25541_Win-LPv12.5.4_vc17.x-x86-64\Mod\Fem\femsolver\mystran\add_femelement_geometry.py

For this file, I made some changes, now support Rectangular, Circular and Pipe section with PBAR.

If use PBARL, I suggest the section list should add Rectangular_L Circular_L and Pipe_L to distinguish.

One question for the default value of Pipe: Diameter 25mm Thickness 10mm. Is this a popular size, only 5mm hole?

I am hoping there is a choice of CBAR or CROD for 1D element.
Will you go for a PR? How about pep8? Have you seen https://github.com/FreeCAD/FreeCAD/blob ... entions.md