Newbie: openscad -> FEM model problem

About the development of the FEM module/workbench.

Moderator: bernd

shinkansen
Posts: 15
Joined: Thu Nov 18, 2021 9:45 pm

Newbie: openscad -> FEM model problem

Post by shinkansen »

As a new user watch out in case I'm asking something incredibly dumb...

My ideal workflow would be to design/draw in openscad and the FEM in freecad and tweak the design there to get the performance I want before going back to openscad to finish my design.

I've got two problems at the moment:

(1) I'm finding it hard to define a material for the model - the problem is there's no solid volume to select, my model appears to just be surfaces and I don't know how to make it solid. This might be a misunderstanding on my part but I "got around" it by exploiting the "if no geometry is selected all remaining ones will be used". I suspect this is incorrect and the materialsolid properties don't look right.

(2) When I run my model I get "non positive Jacobian" errors which kind of makes sense if I've screwed up in (1) like I think I have.

I strongly suspect I've missed a step which will turn my openscad into a proper solid but I'm stumped and can't work out where to go from here.
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Newbie: openscad -> FEM model problem

Post by chennes »

A couple of questions: first, what version of FreeCAD are you using? (see the banner at the top of the screen here for details on how to get the relevant info) Second, what is your setting for "maximum number of faces for polygons (fn)" in the "General Settings" tab of the OpenSCAD workbench preferences? Finally, can you post your OpenSCAD file here?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
shinkansen
Posts: 15
Joined: Thu Nov 18, 2021 9:45 pm

Re: Newbie: openscad -> FEM model problem

Post by shinkansen »

I'm using version 0.19 from the ubuntu freecad ppa

OS: Ubuntu 21.10 (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: 0d9536ed3e8c7f40197b5606e1b7873625e1d6fe
Python version: 3.9.6
Qt version: 5.15.2
Coin version: 4.0.0
OCC version: 7.5.2
Locale: English/United Kingdom (en_GB)
shinkansen
Posts: 15
Joined: Thu Nov 18, 2021 9:45 pm

Re: Newbie: openscad -> FEM model problem

Post by shinkansen »

maximum number of faces for polygons = 16

FWIW $fn=180 in my openscad file but I'm not using anything I think freecad needs to break into polygons (no hull etc).
shinkansen
Posts: 15
Joined: Thu Nov 18, 2021 9:45 pm

Re: Newbie: openscad -> FEM model problem

Post by shinkansen »

$fn=180;
nugget=.01;// to facilitate better F5 rendering
wall=15;height=20;
sz=140;
radius=7;length=20+radius;

difference(){
union(){
difference(){
// main body
cube([sz,sz,height]);

// main side slits
translate([wall,wall,-nugget])cube([(sz-4*wall)/2,sz-2*wall,height+2*nugget]);
translate([sz/2+wall,wall,-nugget])cube([(sz-4*wall)/2,sz-2*wall,height+2*nugget]);

// dogbone holes
translate([sz/4,wall/2,0])dogbone(R=radius);
translate([sz-(sz/4),wall/2,0])dogbone(R=radius);
translate([sz/4,sz-wall/2,0])dogbone(R=radius);
translate([sz-(sz/4),sz-wall/2,0])dogbone(R=radius);
translate([wall/2,sz/4,0])rotate([0,0,90])dogbone(R=radius);
translate([wall/2,sz-(sz/4),0])rotate([0,0,90])dogbone(R=radius);
translate([sz-wall/2,sz/4,0])rotate([0,0,90])dogbone(R=radius);
translate([sz-wall/2,sz-(sz/4),0])rotate([0,0,90])dogbone(R=radius);
}

// mounting plates left,right,middle
translate([0,sz/2-wall,-3])cube([wall*2,wall*2,height+3]);
translate([sz-2*wall,sz/2-wall,-3])cube([wall*2,wall*2,height+3]);
translate([sz/2-(sz-wall*5)/2,wall*1.5,0])cube([sz-5*wall,sz-3*wall,height+3]);
}

// screw holes
translate([sz-wall*1.5,sz/2-wall/2,0])screw();
translate([sz-wall*1.5,sz/2+wall/2,0])screw();
translate([wall*1.5,sz/2-wall/2,0])screw();
translate([wall*1.5,sz/2+wall/2,0])screw();

// bolt hole
translate([sz/2,sz/2,-nugget])cylinder(r=5,h=height+10+2*nugget);
}

module screw(){
translate([0,0,-3-nugget])cylinder(r=3,h=height+2*nugget);
translate([0,0,height+nugget-4])cylinder(r1=3,r2=5,h=4);
}
shinkansen
Posts: 15
Joined: Thu Nov 18, 2021 9:45 pm

Re: Newbie: openscad -> FEM model problem

Post by shinkansen »

Apologies - this bit of code was off the screen and didn't get included - add to above to get the model:

module dogbone(L=20,W=4,H=20,R=6){
//L=20;W=4;R=5;H=10;

translate([-L/2,0,-nugget])cylinder(h=H+2*nugget,r=R);
translate([+L/2,0,-nugget])cylinder(h=H+2*nugget,r=R);
translate([-L/2,-W/2,-nugget])cube([L,W,H+2*nugget]);
}
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Newbie: openscad -> FEM model problem

Post by chennes »

shinkansen wrote: Fri Nov 19, 2021 8:39 am I'm using version 0.19 from the ubuntu freecad ppa
Can you try the weekly? I've modified the OpenSCAD importer quite a bit in the 0.20 development cycle.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
shinkansen
Posts: 15
Joined: Thu Nov 18, 2021 9:45 pm

Re: Newbie: openscad -> FEM model problem

Post by shinkansen »

I tried the weekly build - loading my previous freecad project the shape was there but I could not add a material to it (the circle button just stayed greyed out) and the run model button stayed grey.

I went back to starting again but couldn't import the openscad model because of:

18:23:28 Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/.mount_FreeCA9FYrPa/usr/Mod/OpenSCAD/importCSG.py", line 116, in open
tmpfile=callopenscad(filename)
File "/tmp/.mount_FreeCA9FYrPa/usr/Mod/OpenSCAD/OpenSCADUtils.py", line 193, in callopenscad
check_output2([osfilename,'-o',outputfilename, inputfilename])
File "/tmp/.mount_FreeCA9FYrPa/usr/Mod/OpenSCAD/OpenSCADUtils.py", line 163, in check_output2
raise OpenSCADError('%s %s\n' % (stdoutd.strip(),stderrd.strip()))
<class 'OpenSCADUtils.OpenSCADError'>: " /usr/bin/openscad: /tmp/.mount_FreeCA9FYrPa/usr/lib/libQt5Core.so.5: version `Qt_5.15' not found (required by /usr/bin/openscad)\n/usr/bin/openscad: /tmp/.mount_FreeCA9FYrPa/usr/lib/libQt5Core.so.5: version `Qt_5.15' not found (required by /lib/libqscintilla2_qt5.so.15)\n"
shinkansen
Posts: 15
Joined: Thu Nov 18, 2021 9:45 pm

Re: Newbie: openscad -> FEM model problem

Post by shinkansen »

Can't get around the missing library problem detailed below: I guess the magic of AppImage is broken. openscad runs fine and the freecad-openscad patth is correct - can't see a way to fix this using the existing AppImage package.
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Newbie: openscad -> FEM model problem

Post by keithsloan52 »

Not that familiar with FEM workbench but is this close to what you require?
Image 24-11-2021 at 20.50.jpeg
Image 24-11-2021 at 20.50.jpeg (98.16 KiB) Viewed 3579 times
FemTest.scad
(1.69 KiB) Downloaded 32 times
FemTest.FCStd
(156.82 KiB) Downloaded 30 times
This was with FreeCAD 0.19.1 on a Mac.
Import FemTest.scad
Switch to FEM workbench
Click on Analysis ( Big A )
Select Difference001 in Tree View
Click on FEM Material ( Yellow Sphere )

You will have to Mesh and add constraints I believe
Post Reply