ClementeSerrano / euler-vs-analytical_diff-eqs-methods

Comparison between the analytical and numerical resolution of a particular ordinary differential equation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • 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).

Installing

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.

About the math model

Below I show the equations that the scripts model and also their respective results.

The Euler Method

Interpreting the differential equation

alt text

as an vector field in the plane alt text and the condition alt text as a point alt text of that plane, you can approximate the solution function alt text by means of the tangent line to the same one that passes through that point:

alt text,

where the slope of that tangent is: alt text and, consequently, alt text.

This is how the approximate value of the solution is calculated. Then, evaluating the point of the x-axis alt text must be applied:

alt text.

With this point already calculated, you can repeat the method to obtain the other approximate point alt text. This is done in the following way:

alt text.

It is usual in this method to calculate the approximate solution in points of the form: alt text, where alt text is the step size of the method. Using the above, the formulas that determine the approximate solution are obtained in the following way:

(1) alt text.

(2) alt text.

The Analytical Method

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 alt text is our instantaneous volume, alt text is time, alt text is the volumetric flow of input and alt text the volumetric flow of output. With this information we can say that the variation of the volume in time is

alt text

We solve this simple ODE in the following way:

alt text (we separate variables),

alt text (we integrate the differentials),

alt text,

where alt text 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 alt text to the amount of solute, which we will measure in units of mass alt text. Being alt text 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 alt text and that the concentration alt text is mass amount per unit volume alt text, then the product alt text would give us the units of measure we need: alt text.

With this information we can say that the differential variation of the amount of solute in time will be given by

alt text.

It is possible to notice that the amount alt text 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 alt text of the rate of change alt text. 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...

Authors

About

Comparison between the analytical and numerical resolution of a particular ordinary differential equation


Languages

Language:MATLAB 100.0%