# Unsteady flow code - Problem with space loop

1. Aug 8, 2011

### hoomanya

Hi all,
I have discretized my equations in a way that for example the velocity depends on the velocity of the previous neighboring element so:

h = number of elements
t = 0: 0.5 : 10
for j= 1 : length(t)
for i = 2: h
v(i,j) = v(i-1,j) + b
p(i,j) = p(i,j) +b
end
end

This is not my actual formulations(codes) but the idea is that I need the value of the variable at the previous element so I start my loop from 2 to avoid getting i=0. But then this means that I don't have any values when I have i = 1 in the code. Is the only way to deal with this using boundary conditions. For example setting the value of the variable at i = 1 to be equal to that at i =2 ?

I hope I am clear enough.

Thanks.

2. Aug 8, 2011

### RandomGuy88

You should have a boundary condition that defines your variable at i=1.

3. Aug 9, 2011

### hoomanya

Looking at my equations again, I think a possibility would be to make the values at i-1 equal to the values at the walls of the elements/ cells when possible. Is that a sensible thing to do?

4. Aug 9, 2011

### hoomanya

No I don't think that's doable. .......hmmm .. .still stuck!
my equations are a set of ODEs of the form:

dy/dt = f(y,t)

5. Aug 9, 2011

You need an initial condition at whatever your start time is.

6. Aug 9, 2011

### hoomanya

my problem is with space loop . I have initial conditions. I think I need boundary conditions...

7. Aug 9, 2011

Well it is a fluid problem, so you obviously need both. You will need boundary conditions to get the physical nature of the flow as far as what happens when it approaches surfaces, or infinity and you will need initial conditions to get a time history.

8. Aug 9, 2011

### hoomanya

I know that. Like I said I have my initial conditions sorted. I need to know how to deal with this space loop...

9. Aug 9, 2011