Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Permutation of indices in fortran

  1. Jan 31, 2017 #1
    Hi there. I am working with a numerical quadrature in some scheme to solve a set of equations. At this point I am working in two dimensions. The thing is that I have some function ##\psi_m(x,y,\Omega_m)## with ##\Omega_m=(\Omega_{x,i},\Omega_{y,j})## with ##\displaystyle m=1,2,...,N,N+1,...,M=\frac{N(N+2)}{2}## where I am using a quadrature for the angular variables ##\Omega##, and the index N denotes the number of discrete directions cosines in each direction, N for x, and N for y.

    Now, I have to give a determined weight to each set of the ##\Omega_m## (the weights comes from the angular quadrature of an integral), such that, for example ##\Omega_1=(\Omega_{x,1},\Omega_{y,1})## has assigned the weight ##w_1##, then for ##\Omega_2=(\Omega_{x,2},\Omega_{y,2})## we have ##w_2##,..., and for ##\Omega_N=(\Omega_{x,N},\Omega_{y,N})## we have ##w_N##. But the story continues, when I have ##\Omega_{N+1}=(\Omega_{x,1},\Omega_{y,2})##, this will have the weight ##w_{N+1}##, ##\Omega_{N+2}=(\Omega_{x,1},\Omega_{y,3})## this will have the weight t ##w_{N+2}##, and so on. But then, when I get, for example the direction ##\Omega_{2N+1}=(\Omega_{x,2},\Omega_{y,1})##, this weight must be equal to the one with the permuted indices, id est: ##w(\Omega_{x,2},\Omega_{y,1})=w(\Omega_{x,1},\Omega_{y,2})=w_{N+1}## and, in general ##w(\Omega_{x,i},\Omega_{y,j})=w(\Omega_{x,j},\Omega_{y,i})##.

    This whole thing comes into a program I have written, which is automatized to solve the equation for an arbitrary set of directions M. I don't really know how to do this assignment of weights, specially the part of permuting the indices.

    I thought perhaps somebody here could give me some idea.

    Thanks in advance.
     
    Last edited: Jan 31, 2017
  2. jcsd
  3. Jan 31, 2017 #2

    andrewkirk

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    I'm afraid I can't make sense of the problem as it's described. In the first para it says ##\Omega_m=(\Omega_{x,m},\Omega_{y,m})## for ##1\leq m\leq N(N+1)/2##. But then in the second para it says ##\Omega_{N+1}=(\Omega_{x,1},\Omega_{y,2})##, which contradicts that, since ##1\neq 2##.

    What is needed is a clear, comprehensive specification of the function ##\Omega##.
     
  4. Jan 31, 2017 #3
    Yes, I know, my notation was just stupid. I should use different letters ##\Omega_m=(\Omega_{x,i},\Omega_{x,j})## with ##i,j=1,2,3...,N## and ##m=1,2,...,M=\frac{N(N+2)}{2}##
     
    Last edited: Jan 31, 2017
  5. Jan 31, 2017 #4

    andrewkirk

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    It looks like ##i## and ##j## are supposed to be functions of ##m##. What are those functions?
    So far you have specified that:
    • for ##1\leq m\leq N##: ##i=j=m##
    • for ##N+1\leq m\leq 2N-1##: ##i=1## and ##j=m-N+1##
    Are you sure that's the relation you want? It looks very unintuitive to me. Also, what is the relation for ##m\geq 2N##? It has to change there, otherwise ##j## will exceed ##N##.
     
  6. Jan 31, 2017 #5
    I am willing to use a Gauss-Legendre quadrature set in two dimensions, by discretizing the directions, I obtain a set of discrete directions cosines in both directions. You are right, the correct expression would be a function of the direction cosines ##\hat \Omega_m=\hat \Omega_m(\hat \Omega_{x,m}, \hat \Omega_{y,m})## that's how it is written in the book). I might have misunderstood something in the discretization scheme. I have an integral of this type:

    ##\int_0^{2\pi} \Psi (x,y,\Omega_x,\Omega_y) d\phi## which I am willing to evaluate numerically by discretization of the angular variables.

    The equation I am solving is: ##\displaystyle \Omega_x \frac{\partial \Psi}{\partial x} + \Omega_y \frac{\partial \Psi}{\partial y}+\sigma_t \Psi=\sigma_s \int_0^{2\pi} \Psi (x,y,\Omega_x,\Omega_y) d\phi+q(x,y,\Omega_x,\Omega_y)##
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Permutation of indices in fortran
  1. Multiset Permutations (Replies: 3)

  2. Permutations with BFS (Replies: 4)

  3. What is IERR (FORTRAN) (Replies: 9)

  4. Parallel Fortran (Replies: 15)

  5. Fortran Maccormack (Replies: 4)

Loading...