I want to build a Virtual World in Unreal Engine, with the purpose of educating Fluid Dynamics. Still a lot of work has to be done.
Update October 2017. After a long time following courses on how to build in Unreal Engine, I finally have started with building blueprints. Busy building a watersystem
Update may 2017. I have reactivated the project. Was too busy with ordinary work :-). I am following a course on Udemy (Unreal Engine 4: How to Develop Your First Two Games) to get my skills on a higher level.
The dynamic water system on land is programmed as a blueprint. BP_Watersystem contains both the logic and the assets of the water system. The backbone of the BP_Watersystem is a spline with points. The points represent a change in the water system, for example: input discharge, different structure (pipe, channel, weir..), different dimension. So each point (=Node) is connected with the database WaterSystemData. So in between 2 points (=branch) of the backbone spline, everything is the same, based on the information of the downstream point.. Spline and point represent the bedlevel of the structure.
Index 0 spline is downstream
With a weir the distance between 2 points is the length of the weir!
With a manhole the distance between 2 points is length and width of the manhole.
When type is outflow Velocity : Velocity upstreams (u2) InputDischarge : Velocity at point
A BP_Watersystem is one line with no branches and has a fixed direction of flow.
A dendritic system is possible, because the 3D world may contain different BP_Watersystems which are connected at points. When calculation a dendritic system the sequence of making calculations is important.
Strategy for calculating the water-system.We assume a stationary flow. So new calculations are only made when changes are made to the water-system. In the future calculations will be made per time-step and change in storage will also be taken into account.
Nodes : points of the spline. Same numbers as in spline
Change : type, direction, discharge, dimensions
Calculation Points: Only to get more accurate calculations.
Interpolation between 2 Nodes.
Used when drawing yline and Hline. Not used for drawing other objects.
Array WaterSystemData_Total contains information on the Nodes and the calculation points. Calculating the H and y is based on this database.
Points 0 and 1 can’t have InputDischarge.
Input of discharge is assumed just upstream of the node, so is already flowing at the node. So the Inputdischarge is included when calculating the velocityhead
Draw BP_Watersystem , start from downstream. Point 0 (= downstream point) is the locatie where the watersystem connects to another system. This could be a lake or sea where the velocity becoms 0 or almost 0. So the default parameters for each BP_Watersystem are
– Name (text)
– ConstructionVis (boolean)
– YlevelDownstreams (float)
– VelocityDownstreams (float)
– Rotationtext (float)
(BP_Watersytem) Function FillWaterSystemDataBasic puts the coordinates, direction and length in array WaterSystemData –Number Node -Coordinates World – Coordinates Local – Length
(UI_WaterSystemMainMenu) Enters the Data input from the panel for the selected point in the WaterDataStruct :
–StructureType (Trapezium, Rectangel, Weir, Pipe, Pump, Culvert, Manhole, outflow)
–InputDischarge (pump: pump capacity, outflow: velocity downstreams) -Connector (Names of BP_Watersystems, which are connected at this point) -Width (pipe: diamter, channel:bed-width, weir: width)
-Surface Level World –Crest Level World
–Coefficient (channel:Manning, pipe:Chezy, weir: Coefficient) -Divide Length (Max length between calculation points -zDelta (for example when bedlevel pipe is different bedlevel channel, pump: switch on level)
(BP_Watersytem) Function TotalDischarge will calculate the the TotalDischarge for each point, based on the upstream discharge and Inputdischarge. So this function starts upstreams en calculates towards the downstream points. NOTE If the water-system has branches (separate BP_Watersystem), first the TotalDischarge of these branches need the be calculates. The downstream discharge of these branches is input for the main BP_Watersystem. Check with pump of there is big difference in Discharge channel en Capacity pump
(BP_Watersystem) Function CreateCalculationPoint. Adds calculation points in each branch based on the Divide Length. The calculation points are also directly drawn. Reference to the calculations objects (white small sphere) are stored in array ObjectsCalc (Node number and Reference).
(BP_Watersytem) Function HlinePoint calculates for each point the following members in a WaterDataStruct -H level World -Y LevelWorld -Wetted Area -Wetted Perimeter -Hydraulic Radius -Velocity -H Slope -dH -H2 Level World -y 2 Level World -Time -Reynolds -Froude (net implemented yet) Input is a Datastruct , H level and Y level
Output is a Datastruct, yLevelUpstreams and HLevelUpstreams
(BP_Watersytem) Function Hline starts downstreams, asks for point 0 the waterlevel, then runs HlinePoint for each point and loads the information in the WatersystemData. Strategy:
– calculates H2 which is the H level upstreams. H2 = H1 + dH
– calculates y2 which is the y level upstreams. y2 = H2 – u2/2g . u = velocity downstreams, so this is a small error. So Length should be short and dH < 10 cm
Function SaveWatersystemData stores WatersystemData in an external file
Make backupfiles? Save different versions. Probably there will be several BP_Watersystem in the world. Each has its own name.
So when the file is stored, the name will be WatersystemData_Name and WaterSystemData_Total_Name
Function LoadWatersystemData loads external file to WatersystemData and WaterSystemData_Total_Name
(BP_WaterSystem) Function TotalCalculation which exits of the following functions:
– Hline (sub = HlinePoint)
– DrawWaterSystem (based on array WaterSystemData_Total)
(BP_WaterSystem) Function DrawWatersystem. Builts watersystem based on datafile.
(BP_WaterSystem) Function DrawWatersystemPoint redraws the selected point and the section before and after the selected point