Unsteady flow code - Problem with space loop
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. |
hm, I'm not clear what you are trying to do....which equation are you trying to solve? hyperbolic? parabolic? That would give you the type and number of boundary conditions you need... once you know that, you can apply the correct bc at your inflow / outflow.
cheers |
I have a set of first order ODE's of the form:
dy/dt = f(y,t). Thanks! |
Quote:
OK, you got me confused now....are you solving ODEs or PDEs? Because from your first post, I got the impression you where also dealing with a spatial derivative?? |
hmmm... Sorry ... well, that's the general form of the equation.....although the variables are evaluated at nodes which are at different locations... i.e. they change with space. So the 'i' is really a node number of a certain element. I hope this is more clear ...
Can I email you a simplified form of the equations, as my explanation is still probably unclear ... ? Thanks! :) |
Quote:
So are you saying that you start with a PDE (in x and t) and then semi-discretize it (by evaluating things like d/dx at the nodes) and now you end up with an ODE in time? Then I got you :) |
yes! you're right. Thanks!
So is there a specific type of boundary conditions or a mixture of some that needs to be used with this type of equation? Thanks again. |
Yes, in fact, there is. The problem you are solving is hyperbolic, so you have to find out your inflow and your outflow regions. You only specify your inflow for all times t, and extrapolate the outflow from inside the domain.
I'm trying to make it a little bit clearer by this example: say you want to solve the following standard hyperbolic problem (scalar): du/dt + a du/dx = 0, with u=u(x,t), a >0 Thats the equation of a hyperbolic wave transport, i.e. everything will be transported (NOT damped) with speed a to the right (since a >0). That means that the flow enters your domain from the left and exits on the right. So what you do is the following: you set your BCs ONLY at the left side, say thats at x=0: u(x=0,t)=something at the right side (outflow), you extrapolate your solution, i.e. u(x=right border,t) = u(x=rightborder-1,t). Hope this helps! |
Many thanks. That helped alot. :)
|
glad i could help :)
|
All times are GMT -4. The time now is 02:50. |