Gyroid

Show off your FreeCAD projects here!
User avatar
microelly2
Posts: 4319
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Gyroid

Postby microelly2 » Tue Jan 29, 2019 6:06 pm

bp_955.png
bp_955.png (147.6 KiB) Viewed 1604 times
for gyroid see https://youtu.be/VIcZdc42F0g
the model is created by 3 sketches to generate a Surface and a lot of Draft arrays.
schupin
Posts: 287
Joined: Sun Jan 21, 2018 1:43 pm

Re: Gyroid

Postby schupin » Tue Jan 29, 2019 6:15 pm

Nice, I'm playing with TPMS based structures at work :)

I'm using trigonometry approximations to find the surfaces. How did you made it ? You solved the plateau's law or find some approximations ?
User avatar
microelly2
Posts: 4319
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Gyroid

Postby microelly2 » Tue Jan 29, 2019 7:13 pm

schupin wrote:
Tue Jan 29, 2019 6:15 pm
I'm using trigonometry approximations to find the surfaces. How did you made it ? You solved the plateau's law or find some approximations ?
I use scipy minimize to find the minimum area surface

Code: Select all

#---------------------------
# finde otimale innenpole

import numpy as np
import scipy
from scipy.optimize import minimize


methods=[ 
			'Nelder-Mead' ,
			'Powell' ,
			'CG' ,
			'BFGS' ,
			'L-BFGS-B', 
			'TNC',
			'COBYLA',
			'SLSQP',
]


alpha=[App.ActiveDocument.BePlane.Shape.Face1.CenterOfMass]*4
ptsa=np.array(App.ActiveDocument.BePlane.Shape.Face1.Surface.getPoles())

def areaMin(alpha):
	'''function to minimize'''

	poles=ptsa
	alpha=alpha.reshape(2,2,3)
	poles[1:3,1:3]=alpha

	bs=Part.BSplineSurface()
	bs.buildFromPolesMultsKnots(poles,[4,4],[4,4],[0,1],[0,1],False,False,3,3)
	return bs.toShape().Area



for method in methods:

	tol=10**5
	rc=minimize(areaMin,alpha,method=method,tol=tol)

	print (rc.success,rc.message)
	alpha=np.array(list(rc.x)).reshape(2,2,3)

	poles=ptsa
	poles[1:3,1:3]=alpha

	bs=Part.BSplineSurface()
	bs.buildFromPolesMultsKnots(poles,[4,4],[4,4],[0,1],[0,1],False,False,3,3)

	Part.show(bs.toShape())

	new=bs.toShape().Area
	old=App.ActiveDocument.BePlane.Shape.Area
	print (method," improvement %",round((old-new)/old*100,2),new)

	#----------------------------


For the gyroid I use 4 x 7 poles nurbs, it's a little bit more complex but the same idea.
User avatar
hammax
Posts: 809
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee

Re: Gyroid

Postby hammax » Wed Jan 30, 2019 6:45 am

… had also my "close encounters of the third kind" with gyroid.
But I only used surface-tool. Is the result of surface minimal?
Attachments
Gyroid_n.FCStd
FC.18.15713
(217.63 KiB) Downloaded 21 times
Gyroid_n.PNG
Gyroid_n.PNG (86.46 KiB) Viewed 1513 times
User avatar
microelly2
Posts: 4319
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Gyroid

Postby microelly2 » Wed Jan 30, 2019 8:06 am

hammax wrote:
Wed Jan 30, 2019 6:45 am
… had also my "close encounters of the third kind" with gyroid.
But I only used surface-tool. Is the result of surface minimal?
I remember your solution. I don't know whether the surface wb calculates minimal surfaces.
My idea is to optimize a given surface by modifiing the inner poles to get a minimum area.
For small models scipy.optimize.minimize works.
I will have a look at surface wb faces again and try to optimize them.
User avatar
microelly2
Posts: 4319
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Gyroid

Postby microelly2 » Wed Jan 30, 2019 2:40 pm

I have compared the surface result against the optimized scipy-version
Surface::GeomFillSurface is not a mimimal surface

Here the results for a 4 x 4 testcase
..
('Nelder-Mead', True, 'Optimization terminated successfully.', 16080.548992338268)
('Powell', True, 'Optimization terminated successfully.', 15643.54680362999)
('CG', True, 'Optimization terminated successfully.', 15643.54680362999)
('BFGS', True, 'Optimization terminated successfully.', 15643.54680362999)
('L-BFGS-B', True, 'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL', 15643.54680362999)
('TNC', True, 'Local minima reach (|pg| ~= 0)', 15643.54680362999)
('COBYLA', True, 'Optimization terminated successfully.', 15708.577614427331)
('SLSQP', True, 'Optimization terminated successfully.', 15708.577614427331)
>>>
>>>

>>> suf=App.ActiveDocument.addObject("Surface::GeomFillSurface","Surface")
>>> suf.BoundaryList=[App.ActiveDocument.Shape003,('Edge4','Edge3','Edge2','Edge1')]
>>> _=App.activeDocument().recompute()
>>> suf.Shape.Area
15773.11692233747

There is no big difference but it is a difference 15773 and 15643
yellow:Surface WB, pink optimized
bp_956.png
bp_956.png (105.92 KiB) Viewed 1453 times
Surface WB - nice structure
bp_957.png
bp_957.png (26.48 KiB) Viewed 1453 times
minimum surface - not so nice
bp_958.png
bp_958.png (20.58 KiB) Viewed 1453 times
User avatar
hammax
Posts: 809
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee

Re: Gyroid

Postby hammax » Thu Jan 31, 2019 8:28 am

… to get minimal surfaces, the soap bubble should be the physical method.
I only used arcs for the border lines in the elemental gyroid-cube.
Applying a curvature comb, there is a discontinuity at the cubes corners for arcs.
Should there be a better solution when using sinus curves? (But which amplitude???)

Gyroid_n_2.PNG
Gyroid_n_2.PNG (91.09 KiB) Viewed 1363 times
User avatar
microelly2
Posts: 4319
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Gyroid

Postby microelly2 » Thu Jan 31, 2019 8:52 am

hammax wrote:
Thu Jan 31, 2019 8:28 am
… to get minimal surfaces, the soap bubble should be the physical method.
I only used arcs for the border lines in the elemental gyroid-cube.
Applying a curvature comb, there is a discontinuity at the cubes corners for arcs.
Should there be a better solution when using sinus curves? (But which amplitude???)
Gyroid_n_2.PNG
I do experiments with a 4 x 9 nurbs where I start with arcs (Bezier approx.) as borders too.
in a next step I will modify the border segment to other Bezier curves and compare the results.
this all can be reduced parametric to one sketch with 4 points, so experiments will become simple.
User avatar
hammax
Posts: 809
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee

Re: Gyroid

Postby hammax » Thu Jan 31, 2019 11:30 am

… I tried to draw such a gyroid basic edge by sketching some sinus like curve with BSpline.
To control the amplitude only one value must be changed in the master sketch.
The clones are following the master. => primary cube cell
8 primaries (4 placements, 4 mirrored placements) => secondary cube cell.

Gyroid_n_5.PNG
+stereo
Gyroid_n_5.PNG (155.96 KiB) Viewed 1193 times
Attachments
Gyroid_sin_0.FCStd
FC.18.15713
(237.38 KiB) Downloaded 20 times