====== Float example ====== In this tutorial we will create a floating cube falling into a body of water. It uses most of the simple DesignSPHysics tools and gives a glance at the float property. The result should be something like this: {{ :float1.png?500 |}} This simulation consists in a roofless fishtank that contains a resting body of water, partially filling it, and a heavy cube that will fall into the water. These are the steps to get to that. ==== Step 1 - Creating a new case ==== First of all, lets run FreeCAD and run this software. Make sure DesignSPHysics is installed. For that, you can check the [[installation|installation page]]. Once in DesignSPHysics, use the New Case button to create a new case. If you have opened FreeCAD files, DesignSPHysics will prompt you to close them automatically. Once created you should see something like this: {{ ::case-limits.png?300 |}} This red lines represent the Case Limits, in which elements that are part of the simulation will be contained. Make sure your plugin is configured correctly, pressing "Setup Plugin" and establishing the proper executables in the configuration window that appears. ==== Step 2 - Setting the Inter-particle distance ==== Change the Inter-particle distance text input box to **0.025**. It will look something like this: {{ ::dp-set.png |}} This will set the case to generate a particle every **0.025** meters. For this case is an appropiate value for quick-simulation. ==== Step 3 - Adjusting the case limits and creating the boundaries ==== The next step is to adjust the case limits, so let's do that. First of all select Case_Limits from FreeCAD's combo view. You will see the FreeCAD objects properties in the properties table. There, edit the Length, Width and Height to match **1,2 meters, 0.6 meters and 1 meter** respectively. It should look like this: {{ ::float2.png?300 |}} Once done that, we will create the boundaries. To create a wall (or a floor), just create a box and fill it with the appropiate parameters in the FreeCAD properties table. Create 5 boxes with this properties **LongWall1**: * Length: 1m * Width: 10mm * Height: 0,5m * Position (x, y, z): 0 mm, 0 mm, 0 mm **LongWall2**: * Length: 1m * Width: 10mm * Height: 0,5m * Position (x, y, z): 0 mm, 0,5 m, 0 mm **ShortWall1**: * Length: 10 mm * Width: 0,51 m * Height: 0,5 m * Position (x, y, z): -10 mm, 0 mm, 0 mm **ShortWall2**: * Length: 10 mm * Width: 0,51 m * Height: 0,5 m * Position (x, y, z): 1 m, 0 mm, 0 mm **Floor**: * Length: 1 m * Width: 0,49 m * Height: 10 mm * Position (x, y, z): 0 mm, 10 mm, 0 mm Now select all of them in the Combo view (Control + Click each one) and press "Add all possible to DSPH Simulation" In the DSPH Object Properties. Now, for each one of them, press in it and **change the property MKBound to 0**, as we want all the boundaries to be part of the same object (a external case). You should see that the type of object is bound by default. Also, we want to see what's inside the fishtank, so we will make it look like glass in FreeCAD. For that, select all of the created walls and the floor in the Combo View. Then, press in one of them with the mouse right click, and select __Appearance__. In the window that appears, and __without deselecting anything__, set the Shape color to complete white and the Transparency value to something around **80**. That will make it look like glass. You should see something like this. {{ ::float3.png?500 |}} ==== Step 4 - Creating the fluid ==== We're going to create a new cube and rename it to "Water". For that, press in the cube icon on the top of the screen, select the generated cube, and press F2 (or right click -> rename) to rename it. We need to resize this body, so press in it and in FreeCAD's property table input, as before, this values: **Water**: * Length: 1 m * Width: 0,49 m * Height: 0,2 m * Position (x, y, z): 0 mm, 10mm, 0 mm We need to mark this object as part of the simulation. Press the __Add to DSPH Simulation__ button in the __DSPH Object Properties__ Now we will set this body to be fluid. For that, select it and in the DualSPHysics property table set the Type of Object to: Fluid. Also, if is not set yet, put the MKFluid value to 0 You will see that the body turns blue, representing water. You should have something like this on your screen: {{ ::float4.png?500 |}} ==== Step 5 - Creating the floating cube ==== To create a cube, press in the cube icon at the top of the screen. Select it and input the following properties: **Cube**: * Length: 0,1 m * Width: 0,1 m * Height: 0,1 m * Position (x, y, z): 0,5 m, 0,2 m, 0,5 m Add the object to the DualSPHysics simulation. To do that press the __Add to DSPH Simulation__ button in the __DSPH Object Properties__ We don't want this cube to be part of the fishtank, so we have to change its __MKBound__ value. **Set it to 1**, if it is not yet set correctly. We want to enable the float state for this object and give it properties. To do that, press the __Configure__ button in the __Float state__ DSPH property. Select **True** in the __Set floating__ field, and set the __Mass/Density__ to **massbody** and **10** kilograms. You should be seeing something like this: {{ ::float5.png?500 |}} ==== Final Step: Simulating and exporting ==== You can now save your project. This will generate a GenCase export and tell you how many particles you have to simulate. Your case should be something like this: {{ ::float6.png?500 |}} From there you can just select your preferred processor in the simulation group (CPU or GPU[Nvidia only]) and press "Simulate Case". Once finished you can export the data to VTK with the button "Export data to VTK". To see the resulting animation you can open all the data generated with a visualization software, like Paraview. Your simulation data is in the folder you saved the project, under [project name]_Out/