How to connect nested while function to calculate particle movement?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a 3-d matrix of u-comp velocity uuuu(x,y,t) and v-comp velocity vvvv(x,y,t) with 260x350x10. x is horizontal grid (grid x), y is vertical grid (grid y), t is time. I would like to calculate particle movement from the data uu and vv by using the formula lagrangian, defined as X(i)=X0+U*dt . X(i) is the particle movement toward times, X0 is initial particle position or previous position, U is velocity at the distance a from grid (U=u1+(u2-u1*a/dx)), dx is the distace for every grid (1000 m), and dt is the time step of the model. I set initial time (t=1) and t-end (tt=192). I also set every grid size into 1000 scale, since the grid from model is 1 km -> m.
1) I make the meshgrid to set the initial condition of X0,Y0 as the reference position of the particle. I choose the X0,Y0 at the distance 165000 m (at x direction) and 153000 m (at y-direction).
2) I would like to calculate the distance X(i) and Y(i) for the next time step untill the end. However, in every changing of X(i) and Y(i) that make the position of particle is in another grid location, I would like the U value is calculated from the u,v value in this grid. So that, I use nested while function here to apply two condition of the calculation. First condition, I would like to run while t<=tt, it will calculate the position of initial X0,Y0 and indexing the u2 and u1 at grid X0,Y0. Second condition, when the position X0,Y0 is changing postion into position X(i),Y(i), I would like to calculate the U by indexing the u2 and u1 at grid X(i),Y(i).
But, I found the second while function here is not connect to the first while function. So that, is there any another solution should I apply? I would appreciate if there any expertist to solve my problem. Thank you
Remark for attachement:
1) mesh grid data, assuming the whole grid data of uu and vv as x,y grid
2) 1-grid data, assuming the one component grid data contain u,v
3 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Spectral Measurements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!