Creating a 3D-printable Lorenz attractor

The Lorenz attractor is a set of chaotic solutions of the Lorenz system which, when plotted, resemble a butterfly or figure eight. The Lorenz system is a system of ordinary differential equations first studied by Edward Lorenz in the 1960’s. It is notable for having chaotic solutions for certain parameter values and initial conditions. 

In Winter 2015, my colleague Professor Greg Dresden used the Lorenz attractor as an example in his course on Partial Differential Equations. At that time, I worked with Dave Pfaff in the IQ center at W&L to find a way to 3D print a physical model of the solution curves. Dave also created model of the solution curves that could be viewed with 3D glasses in our stereo 3D lab. To create the models we followed three steps:

Step 1:  Create points along the solution path (the Lorenz curve) using Mathematica. Here is the Mathematica code Greg developed for this purpose.

(* Here are the differential equations *)
leqns = {  x'[t] & == -3 (x[t] – y[t]),
y'[t] & == -x[t] z[t] + 28 x[t] – y[t],
z'[t] & == x[t] y[t] – z[t] };
(* Here, I define two paths, p1 and p2, which start at slightly-different initial values. *)
p1 = NDSolveValue[{leqns, x[0] == z[0] == 0, y[0] == 1}, Function[Evaluate[{x[\#], y[\#], z[\#]}]], {t, 0, 30}];
p2 = NDSolveValue[{leqns, x[0] == z[0] == 0.03, y[0] == 1},  Function[Evaluate[{x[\#], y[\#], z[\#]}]], {t, 0, 30}];
(* Let’s look at a plot of these two paths, to verify that they seem correct *)
pic1 = ParametricPlot3D[p1[t], {t, 0, 30}, AxesLabel -> {x, y, z}, PlotStyle -> {Red, Opacity [0.5]}];
pic2 = ParametricPlot3D[p2[t], {t, 0, 30}, AxesLabel -> {x, y, z},
PlotStyle -> {Black, Opacity [0.5]}];
(* Finally, we export them as two separate files *)
tableout1 = Table[p1[t], {t, 0, 30, 0.01}];
tableout2 = Table[p2[t], {t, 0, 30, 0.01}];
Export[“TableOut1.xls”, tableout1]
Export[“TableOut2.xls”, tableout2]

Step 2:  Use Excel to tweak the data into a form we can use.

  • Open the files in Excel.
  • Insert a column before the three columns of numbers, this is column A. Make the first row 1, and the second row 2 in column A. 
  • Highlight these two entries in column A, then drag the box down to row 3001. The numbers in column A will automatically fill in the correct numbers.
  • Highlight all of the numbers in all four columns. Click on Save As, then save the file as a Tab Delimited Text (.txt) file. 

Step 3:  Create the thickened Lorenz curve in Cinema 4D.

  • Open Cinema 4D
  • Construct the spline with the Lorenz data.
    • Left click and hold on the Spline button on the top row, then select the Linear (spline) button. Click once on the view-port to add one point.
    • Go to the Object Manager. On the right side, click on the Structure button. You’ll see the Point 0, with X, Y and Z coordinates. 
    • Click on the File button above the Object Manager. Click on Import ASCII Data… Open the .txt file created above.
    • Click on the 0th point (the one you added initially) and Delete it. The remaining points are from the Lorenz data (see figure.)
    • Click on the Objects button on the right side of the Object Manager. 
  • Thicken the spline for 3D printing.
    • Left click and hold on the Subdivision Surface button on the top menu, then select the Sweep button.
    • Left click and hold on the Spline button on the top row, then select the Circle button. Under the Attribute Manager, make the radius of the circle 3mm (0.3cm).
    • In the Object Manager, move the Circle and the Spline under the Sweep. The Circle should be above the Spline (see figure). The thickened spline is now complete, and the Lorenz curve can now be exported (as a .stl file) and then 3D-printed.

A thickened Lorenz curve in Cinema 4D is shown below on the left. Two curves can be added to the same plot in Cinema 4D and given different colors.  Dave Pfaff printed two such curves using the Project 260 3D printer at WLU. (This printer uses a gypsum-like powder hardened via a laser then finished with superglue.)  The Project 3D printer can print in color (using inkjet cartridges). Dave also designed a stand for the curves. This gives the beautiful model shown below on the right. Cinema 4D also allows the user to animate the curves. Dave created such an animation, which nicely shows the chaotic nature of the Lorenz attractor. The initial points of the two curves were very close, but in the long term, the curves diverge.

 

 

More quadratic surfaces

In July it was time to get back to designing and 3D printing some more math models. I had previously seen some beautiful models printed by Dave Pfaff on the Series 1 Pro, using its ability to print in a spiral. I wanted to print a large hyperboloid of one sheet using this printing technique.

So I went back to Cinema4D to design the model. I used the Function tool to make the hyperbola \(\frac{x^2}{4} -\frac{y^2}{9}=1\), which has asymptotes \( y=\pm \frac{3x}{2}\). I then used the Lathe tool to revolve the hyperbola around the \(y\)-axis and create a hyperboloid of one sheet. I knew, from the asymptotes, that the surface would have an angle  greater than \(45^\circ\) angle with the \(xz\)-plane. (Recall that in Cinema 4D, the \(y\)-axis points upwards where the \(z\)-axis usually points in mathematics.) Having a steep angle with the plane is important feature when 3D printing in a spiral. Since there won’t be any supports printed, a steep angle increases the chances of a good print.

At this point I used the surface I had created to make two different kinds of models. For the first model, I simply added a top and bottom to create a closed volume.  For the second model, I thickened the surface using the Extrude tool (2mm), again creating a closed volume. The extruded surface had raised top and bottom rims, which meant the model would not sit flat. So I selected all the point around the top (respectively bottom) rim and brought them down (resp. up) an appropriate distance. Apart from this, this thickened model needed very little doing to it. I then created a third model by adding equations and removing them from the thickened surface. This ended up being quite involved as I used the Bend Tool to make sure the equations sat nicely on the surface.

hyperboloid-tallIn order to get a spiral print, I took the first closed model, and adjusted the print settings on the Series 1 Pro printer. The top and bottom layers of the model are not printed; instead the nozzle goes around in a spiral, printing the surface 1 layer thick. Initially, we had trouble with both the fan and print speed settings. This meant the filament was not setting at the bottom of the model, leaving a gaps and giving a ragged appearance. After we slowed the print speed down and made sure the fan turned on after 1mm (rather than after 10mm), the prints turned out beautifully. The small model is about 13cm tall, and the large one about 20cm tall. These models can be found on Thingiverse here.

The next set of models was the hyperbolic paraboloid again, but this time I wanted to surface to look more like a saddle shape. To achieve this I went into Mathematica and use ParametricPlot3D command to plot the surface \(z=x^2-y^2\). Instead of displaying it inside a box, I had Mathematica just show the part of the surface inside the circle \(x^2+y^2=1\). To do this, I used the RegionFunction command.

hyper-paraboloid-form1  hyper-paraboloid-drying

I exported the Mathematica file as a .wrl to Cinema4D. Once there, I extruded the surface (again 2mm thick), then had to spend a significant amount of time repairing the mesh. To do this, I used the Optimize function, and also went around the surface repairing the mesh by hand (removing points, lines and faces, then using the Fill Polygon Hole tool to repair the gaps). I made two copies of the model, one with equations and one without. (I also built the equations in Cinema4D and extruded them. I then removed them from the surface using the Boole tool.) I 3D printed the resulting models on the FormLabs Form 1+ printer in clear and grey resin. The surfaces printed very well, though there were a fair number of supports to remove.

hyp-paraboloid-roundThese models can be found on Thingiverse here.

Monkey Saddle

Screen Shot 2015-07-27 at 1.19.21 PMIn order to make a monkey saddle I created the surface in Mathematica. I then exported it as a .wrl file and imported it into Cinema 4D. Once it was in Cinema 4D, like all surfaces, I made it the correct size, optimized the polygons and extruded them by 0.20 cm.

I then added an equation to the surface by punching it all the way through. This time with the equation I used Arial as the font instead of Times New Roman to hopefully avoid the issues we had with the formula when printing the hyperbolic paraboloid.monkeysaddle

I printed the monkey saddle using the liquid printer and the formula in Arial font ended up looking great. The model can be found on Thingiverse hereformula

Quadratic Surfaces – Hyperboloid of Two Sheets

The last quadratic surface I printed was a hyperboloid of two sheets.

Screen Shot 2015-07-20 at 1.25.54 PM For the hyperboloid of two sheets I created the entire object from scratch in Cinema 4D using the same process I used to create the cone and other similar objects. For this surface I used the same formula spline as the hyperboloid of one sheet \(x(t)=cosh(t), y(t)=sinh(t), z(t)=0\), and then rotated it to the correct orientation. I then used the lathe tool and rotated this spline 180 degrees since this was all it needed. Because of this I needed to use only 30 rotation segments for a total of 60 all around the object. 

Screen Shot 2015-07-20 at 1.25.32 PMI also had to reverse the normals on half of the object to make sure they were all aligned with the other half before I extruded the surface. I optimized the polygons to be sure the edges joined up into one object. I then extruded the surface to create my hyperboloid of two sheets. I copied this and put equations through one of them. I also made sure to Boole the edges of the hyperboloid to make them flat for printing. 

FullSizeRender 5 copy 2

 

Here is a picture of the final object! It can be found on Thingiverse here.

 

 

Quadratic Surfaces – Hyperbolic Paraboloid

The quadratic surface that gave me the most trouble was the hyperbolic paraboloid. This surface could not be created in Cinema 4D and had to be imported from Mathematica. When I imported the surface from Mathematica the center of the saddle had hundreds of little polygons that overlapped, which became a huge problem when I tried to extrude them to give the surface thickness.

I had to spend a long time experimenting to find the lowest number of plot points I could use in Mathematica and still get an accurate object.Screen Shot 2015-07-20 at 11.39.50 AM Once I had done this I did the same thing with the optimize tool in Cinema 4D to see how big I could make the polygons before the surface started to lose accuracy. The first time I went through all these steps the hyperbolic paraboloid I had chosen just didn’t work correctly. So, I went back to the beginning and created a new Mathematica file of a hyperbolic paraboloid, and spent some time deciding where to cut it off to create edges that were as straight as possible.

Screen Shot 2015-07-20 at 12.51.01 PM Once I had done this and imported the surface into Mathmatica I optimized the surface as much as it would allow and extruded it. Finally I had a surface I could print! I then added the hyperbolic paraboloid’s equation to the surface. Instead of just imprinted the equation, since the surface was so thin I punched it all the way through.photo

In order to print this surface I used the FormLabs liquid printer. When the object came out of the printer it looked great and only had a few minor flaws to fix after this first print. One of the issues was the size of the object; it was just a little too small. The other issue was that the 2 in the exponent of the equation didn’t quite form correctly because it was too small. The final issues was that the equation had a \(+\) sign where there should have been a \(–\) sign (oops). Screen Shot 2015-07-20 at 12.51.21 PMThe equation was little too long with a 0 that was missing its center.  To fix these problems I rearranged the equation (and fixed the sign issues) in Adobe Illustrator and then punched it through the surface again. The second print on the liquid printed I made 1.4 times larger than the last print.

FullSizeRender 2 copyThe final print still had issues with the formula but otherwise worked out well. We are currently looking into changing the font to see if that helps with this issue. This model can be found on Thingiverse here.

FullSizeRender 5

Using my experiences building this and the other quadratic surfaces, I’ve put together a set of instructions on how to build quadratic surfaces using Mathematica and Cinema 4D. This can be found here.

Quadratic Surfaces – Paraboloids

The next quadratic surfaces I printed were an elliptic paraboloid and a regular paraboloid.

Screen Shot 2015-07-20 at 1.09.14 PM

For the elliptic paraboloid I imported the surface from Mathematica. 

 

Screen Shot 2015-07-20 at 1.10.07 PM

 

I then optimized the polygons, extruded them by 0.20 cm to give the surface thickness. After that I used the boole tool to make the edge flat and added an equation through the surface.Screen Shot 2015-07-20 at 1.09.49 PM 

I created the regular paraboloid from scratch in Cinema 4D using the same process as the cone.  I used the formula spline \(x(t)=t, y(t)=t^2, z(t)=0\) and then used the lathe tool with 60 rotation segments to rotate it 360 degrees. I optimized the polygons and extruded them to give the surface thickness. I also made sure to “boole” the edge to make it flat and added an equation. 

I printed both paraboloids on the same build bed with the MakerBot 2X printer. They can be found on Thingiverse here and here.

 Screen Shot 2015-07-20 at 2.56.17 PM   Screen Shot 2015-07-20 at 2.56.34 PM

Quadratic Surfaces – Cone

The next quadratic surface I made was a cone. This is a particularly challenging object since the cone’s two halves meet at a single point in the center. In order to deal with this printing challenge, I originally attempted to create the object and add a certain amount of thickness to the middle so it would print correctly.

The first cone I made using a method similar to my other quadratic surfaces by using a spline with the formula \(x(t)=t, y(t)=1.5*t, z(t)=0\) (it was important to use the * otherwise Cinema 4D did not multiply) from \(t=-2\) to \(t=2\) and rotating it with the lathe tool 360 degrees with 72 subdivisions. Screen Shot 2015-07-20 at 12.43.22 PMThen I optimized the object by 0.02cm. With the first cone I made I reversed the normals so they were facing outwards from the cone surface. When I extruded the surface by 0.25cm this automatically gave center of the object more thickness. Unfortunately I realized that while it gave the center thickness, it also offset the lines of the cone so they didn’t match up, which is not what we wanted. In order to fix this problem I did the same thing but did not reverse the normals (so they were facing the inside) and extruded the surface to give the cone thickness.

Screen Shot 2015-07-20 at 12.43.53 PMWith this second cone I removed the center using the Boole Tool, and a cylinder of radius\(=0.25\)cm and height\(=2\cdot 0.25\cdot 1.5=0.75\)cm. We did this in order to preserve the lines of the cone and give it the support the object needed. After removing this cylinder from the center I then added one of the same dimensions in its place. IMG_4592We knew this print had a high potential to fail but decided to print it as a test to see what we might need to change in our design. We left it overnight and it was a huge mess the next morning. Clearly this design didn’t work and we needed to rethink it. 

I decided that creating both sides of the cone in one object was just not going to work. Instead I decided to create both halves separately and then connect them using a cylinder made from a sheet of clear overhead plastic (an idea that came from Henry Segerman’s Calculus Surfaces). Screen Shot 2015-07-20 at 12.32.47 PMIn order to do this I used the same formula spline except this time from only \(t=-2\) to \(t=0\) and copied and rotated it to create the second half. On one half I put the equation for the cone \(\frac{z^2}{4}=x^2+y^2\) and immediately ran into trouble. I had used too many subdivisions (72) and the object was not accepting the Boole with the equation. After creating many different cones with different subdivisions I found that 60 worked. Once this problem was solved I added the equations to one of the halves of my cone and printed it. When I added the equation I put it all the way through the surface and not just imprinted on it since the object had very little thickness to it.

photo Screen Shot 2015-07-20 at 2.20.57 PMThe print was successful but showed a few flaws in my design. One was the equations and how they were a little too big and how the fraction parts of it needed to be downsized to match the other parts of the equation. This was easy to fix in Adobe Illustrator by changing the font size in the fractions from 36 to 24. I also made sure the numbers in my equation were not italicized and just the variables were. The other design flaw I found was that the bottom of the cone was not completely flat and was angled from when I extruded the surface to give it thickness. To fix this I used a cylinder and “booled” the bottom of both cones to make them flat. I then reprinted my object and had great results. These objects can be found on Thingiverse here.

Quadratic Surfaces – Ellipsoid

Screen Shot 2015-07-15 at 2.43.58 PMMy next successful quadratic surface was an ellipsoid. This surface I simply imported from Mathematica and then added equations to it, using the same process as described in my post on the hyperboloid of one sheet.

The first ellipsoid I made in was \(\frac{x^2}{16}+\frac{y^2}{25}+\frac{z^2}{4}=1\). When I put my .STL file into the MakerBot Desktop program I noticed that the program created supported that went up to the equation because it was on a curved surface and cut into the object. I decided to print the object with these supports and the equation on the side of ellipse and no raft. 

ellipse1-fail2 copyThe first print I did of the ellipsoid I cancelled the print early on so that I could inspect the sides. The surface looked a bit melty, where the filament had shrunk. We decided this was fine and to try to print it again. The second time I printed this object at about half way through the print it fell over and we found it covered in a stringy mess of filament. 

Taking this failure and the Screen Shot 2015-07-15 at 2.44.20 PMmelty-ness of the ellipsoid, we decided to create a new ellipsoid that was a little rounder. I followed the same process as for the first ellipsoid using the equation \(\frac{x^2}{4}+\frac{y^2}{6}+\frac{z^2}{3}=1\)                                          

ellipse1-4This time when I printed it I decided to put the equations on the top of the ellipse and use a raft. It printed perfectly. 

 

ellipse1-2 copyAfter my success with my second ellipsoid I decided to try to print my first ellipsoid again and this time with a raft. The object never fell over and printed perfectly. These ellipsoids can be found on Thingiverse here and here.

Approximating a Volume by Rectangular Prisms

French-Fries

Next, I modeled the volume under the curve \(z = 16 – x^2 – 2y^2\), using a double Riemann sum approximation. Here, in the \(xy\)-plane, each approximation contains \(m\) squares along the \(x\)-axis and \(n\) squares along the \(y\)-axisScreen Shot 2015-07-01 at 10.02.27 AMIn this case, I used \(m = n = 4\) and \(m = n = 8\).  In order to print the solids, I modeled them on Cinema 4D.  They were extremely thin (the height was much greater than the width and length) (see Cinema 4D pictures), so I divided the height of each approximation by 4.  I then printed them simultaneously, which took 8 hours and 45 minutes.  

 

 

 

The models turned out well, except in the \(m = n = 8\) case the printer did not print one of the rectangular prisms because I accidentally placed two rectangular prisms in the same place.   I then printed a c
orrected version as well as a model of the original solid (height divided by 4 once again).  On the original solid, I imprinted the equation onto the bottom, which does not look great because it should be imprinted deeper into the solid.  We considered using Magic Merge because the first print of the \(m = n = 8\) approximation printed some vertical lines, but when we fixed the model in Cinema 4D, the MakerBot printed smooth faces on each side.

The three objects can be found on Thingiverse  here, here, and here.

Three Intersecting Cylinders

Screen Shot 2015-07-10 at 10.36.08 AMMy latest project was to create three intersecting cylinders and the area of their intersection. I created these objects similarly to the two intersecting cylinders and the Steinmetz solid. For the volume common to all three cylinders I used a Mathematica code and imported the object into Cinema 4D.

Screen Shot 2015-07-10 at 10.43.19 AMFor the three cylinders I created them from scratch in Cinema 4D using the ‘Tube’ object. Creating the three cylinders was very straightforward. After my fail from the two cylinder object I also wanted to create the three intersecting cylinders cut in half, so the inside was visible. This proved to be a little more complicated. I used a ‘Cube’ and ‘Boole’ with each tube in order to get half cylinders. Then I was able to merge them together using a very similar process to putting equations on solids in Cinema 4D.

IMG_4560

I have yet to print the half cylinder object, but I did print the inside intersection. The first time I printed it I ran into a problem that also occurred with the Steinmetz object. Both solids seemed to have ‘melty’ sides. The angle of the object was such that no supports were needed and yet gravity seemed to affect the plastic and cause some issues. We think that the plastic filament cooled and shrunk during printing causing the deformations.

IMG_4562 IMG_4563

In order to fix this I decided to reprint the inside intersection with a different orientation. this required more supports but we had much less melting on the sides. I plan to try reprinting the Steinmetz object with another orientation to see if I can eliminate the deformed sides.

The original orientation is on the left and the new orientation is on the right. The objects can be found on Thingiverse here and here.

IMG_4564IMG_4565