Comparing the Euler method with the analitic method in terms of accuracy in the study of fluid dynamics in a brine tank
In this repository I present some scripts written in Matlab which allow to study from a differential point of view the variations of the salt quantities in the brine mixture as time passes. The algorithms allow us to calculate the rate of accumulation of the brine solution by solving the ordinary differential equations from two points of view: numerically through the Euler method and analytically by traditional methods.
A .pdf
report with the details of the case study is attached to this repository. In it you can see the analysis and conclusions of the case.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Matlab software.
- Basic knowledge about ordinary differential equations and numeric methods, especially Euler's method.
In addition to being able to run the scripts, the idea is to have knowledge of what is done (read the paper for that).
Clone the repo in your local machine $ git clone https://github.com/ClementeSerrano/euler_vs_analytical_diffEqsMethods.git
and open it in the Matlab IDLE. Then just run the script you want.
Below I show the equations that the scripts model and also their respective results.
Interpreting the differential equation
as an vector field in the plane and the condition as a point of that plane, you can approximate the solution function by means of the tangent line to the same one that passes through that point:
where the slope of that tangent is: and, consequently, .
This is how the approximate value of the solution is calculated. Then, evaluating the point of the x-axis must be applied:
With this point already calculated, you can repeat the method to obtain the other approximate point . This is done in the following way:
It is usual in this method to calculate the approximate solution in points of the form: , where is the step size of the method. Using the above, the formulas that determine the approximate solution are obtained in the following way:
Next we will explain the step by step of the analytical resolution of the differential equation generated by the model that is analyzed. The methodology that is followed is the one that performs the function of Matlab dsolve()
.
The problem proposes that a mixture in the form of fluid circulates through a storage chamber with values such as initial volume, volumetric flow (or flow) of input and volumetric flow of known and constant output, however, instantaneous volume, instantaneous concentration and quantity of solute output variables over time.
How to find an expression for these variable quantities? We could start by describing how the volume change behaves infinitesimally as the process proceeds. For the above, consider that is our instantaneous volume, is time, is the volumetric flow of input and the volumetric flow of output. With this information we can say that the variation of the volume in time is
We solve this simple ODE in the following way:
(we integrate the differentials),
where is the integration constant and for this case, the initial volume of the mixture in the camera.
This same concept of accumulation rate to define a ratio of change occurs with the concentration of solute: the accumulated is equal to the difference of what goes with what comes out.
We will call to the amount of solute, which we will measure in units of mass . Being time, we can think the following: what information do we have of what enters and leaves the dynamic system that allows us to obtain quantities in units of mass over time? The answer lies in the volumetric flow and in the concentration.
Remembering that the volumetric flow is an amount of volume per unit of time, that is, a cubic length over time and that the concentration is mass amount per unit volume , then the product would give us the units of measure we need: .
With this information we can say that the differential variation of the amount of solute in time will be given by
It is possible to notice that the amount depends on the time. This is logical since in the output, the mixture does not maintain a constant concentration, a quantity that changes according to time.
We are steps away from obtaining the differential equation that we are looking for. Before we will need to break down the concentration of the rate of change . For this we will simply continue with the definition of concentration as a quantity of mass on unit of volume, only this time both variables with time. This mass $ m $ will be the amount of solute that we are looking for, in such a way that PENDING TO CONTINUE...
- Clemente Serrano - ClementeSerrano