Borrar filtros
Borrar filtros

Eulerian Position and Velocity Updates - Compressible Fluid Dynamics

4 visualizaciones (últimos 30 días)
Hello Everyone,
It is my first time writing in this forum, so please be patient with me :)
I am writing a code following Smoothed Particle Computation (SPC) method for solving a Compressible Fluid Dynamics Problem.
In my code I got to a point where I need to do the following:
Basically, say at time = 0, I have a certain velocity u, a position x and acceleration a.
Now, I want to update u and x for an amount of time steps, using the following fomulae:
u (t+1) = u(t) + acceleration*dt
x(t+1) = x(t) + u(t+1)*dt
t = original time/time index
t+1 = new time
dt = 1 (for example), acceleration = same for every time step. In my case I would like to have 10 time steps.
How do I do it?
Thanks, Fed
Here is my code so far, just for fashion :
clc, clear
N=61; sigma = 5; m = 1; a=1;
j = 1:61;
x_j = j - 1 + 0.5*sign((N+1)/2 - j).*(1-exp(-0.2.*( j-(N+1)./2).^2) )
for x_i = [1:61]
ro = m/(sqrt(pi)*sigma).*exp((-(x_i-x_j).^2)./sigma^2)
del_ro = (2*m)/(sqrt(pi)*sigma^3).*(x_i-x_j).^2.*exp((-(x_i-x_j).^2)./sigma^2)
u_j = (-(a^2.*log(ro)))./2
acc = (- a^2./ro).*del_ro
end
for k = 1:10
u_j_new(k+1) = u_j(k) +acc(k)
x_j_new(k+1) = [x_j(k).*u_j_new(k)]
ro_new(k+1) = m/(sqrt(pi)*sigma).*exp((-(x_i-x_j_new).^2)./sigma^2)
end

Respuesta aceptada

dwight nwaigwe
dwight nwaigwe el 19 de Abr. de 2011
Are u_j x_j acc vectors corresponding to 61 different points? Do you want to treat each point individually? In other words, do you want to find the new position,velocity, and ro of each index?
In that case you would do
for k = 1:10
u_j = u_j +acc
x_j = x_j(k)+u_j_new
ro = m/(sqrt(pi)*sigma).*exp((-(x_i-x_j).^2)./sigma^2)
end

Más respuestas (3)

dwight nwaigwe
dwight nwaigwe el 20 de Abr. de 2011
whoops, the second line should be
x_j = x_j+u_j_new

Federico
Federico el 21 de Abr. de 2011
Thank you very much. I think what you wrote is right. I just cannot put it together with other loops.
I'll keep this posted as I go further with my code.
Anyway, in this code I will be using the Smoothed Particle Hydrodynamics method, so yes I am treating the flow into 61 finite smoothed particle.
Are you into this field (CFD etc etc? Because I feel like I will need some more help and am completely doing this by myself.
cheers

dwight nwaigwe
dwight nwaigwe el 26 de Abr. de 2011
Hi Federico, Well, the loop over k is responsible for the evolution of your points in time. Is your first loop for initialization? Where does del_ro come into play?
I'm not into CFD but I am familiar with fluid mechanics and numerical methods (although I may be rusty).
Are you new to programming? If so, don't be afraid because it's not that hard. You just have to learn the "rules" of programming.

Categorías

Más información sobre Fluid Mechanics en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by