Thread Subject: Fortran to MATLAB, PROGRAMMING

Subject: Fortran to MATLAB, PROGRAMMING

From: Chris

Date: 25 Nov, 2009 01:09:03

Message: 1 of 2

Recently i have started a research project at my university, it involves using MATLAB and then hopefully converting the code to FORTRAN. It basically involves simulating particles moving randomly about and calculating the forces exerted by each one on each other over a set period of time in a given environment with boundary conditions. i am quite lost as am not very familiar with matlab.

However to cut down the run time of the program i am trying to write a code that involves neighbour lists, where the particles that are in close proximity are the ones used to evaluate the forces not with every particle, the neighbour lists are updated constantly.

A piece of code i have found is written in Fortran that i am not familiar with, if you have any help or advice for me on which toolbox in MATLAB to use for the program or can interpret the code below, please contact me, any sort of direction or help would be appreciated. Cheers

DO 100 ICELL=1,NCELL

HEAD(ICELL)=0

100 CONTINUE
CELLI=REAL(M)
DO 200 I=1,N

ICELL= 1+INT((RX(I) + 0.5)*CELLI) + INT((RY(I) +0.5)*CELLI)*M + INT((RZ(I)+0.5)*M*M

LIST(I)=HEAD(ICELL)
HEAD(ICELL)=I

200 CONTINUE

Subject: Fortran to MATLAB, PROGRAMMING

From: Darren Rowland

Date: 25 Nov, 2009 01:56:19

Message: 2 of 2

Chris,

The second loop creates a chained hash table.

If (RX,RY,RZ) hold the positions of the particles, then this code finds the index of the spatial region that the particle is in, denoted by ICELL. (This is used as the hash key).

After the loop over all particles the LIST and HEAD arrays form a linked list, where each element of HEAD is the last particle encountered in each spatial region (HEAD(ICELL)==0 if no particles in that region), and each element of list contains the number of the particle which was previously encountered in each region.

So to determine which particles are close to a given location you would compute the hash key ICELL, look in HEAD(ICELL) for the 'first' particle number NN, then look in LIST(NN) to get the next particle number and continue this process until LIST(NN) == 0.

Hth,
Darren.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com