Fortran Permutation of indices in fortran

AI Thread Summary
The discussion revolves around the assignment of weights to a set of angular variables in a numerical quadrature scheme for solving equations in two dimensions. The user is attempting to define weights for combinations of directional cosines, denoted as ##\Omega_m=(\Omega_{x,i},\Omega_{y,j})##, and faces challenges with the permutation of indices for these weights. There is confusion regarding the correct relationships between indices and the notation used, leading to questions about how to properly specify the function ##\Omega## and the corresponding weights. Additionally, the user seeks clarification on the discretization of angular variables for numerical integration. The conversation highlights the need for a clear definition of the relationships between the indices to ensure accurate weight assignments.
Telemachus
Messages
820
Reaction score
30
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:
Technology news on Phys.org
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##.
 
  • Like
Likes Telemachus
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:
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##.
 
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)##
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top