Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix product #30

Closed
photoniker opened this issue Jan 16, 2023 · 5 comments
Closed

Matrix product #30

photoniker opened this issue Jan 16, 2023 · 5 comments
Assignees
Labels

Comments

@photoniker
Copy link
Collaborator

Hi,

when calculating the forward/ backward matrix of some elemente, I see a not expected behaviour:
For the same elements I would expect the inverse matrix:
image

That is not the case for the sign of the values as you can see here:
image

@photoniker
Copy link
Collaborator Author

ah I found that this is all fine when calculating the matrix. When you calculate the propagation forward and than backwards you have to inverse the matrix.

@photoniker
Copy link
Collaborator Author

Another question pop out for the definition of forward and backward.
image

In the ABCD formalism you calculate the forward propagation matrix by starting the matrix multiplications from the last element. That is in rezonator the other way round. What's the reason?

@Chunosov
Copy link
Collaborator

That is in rezonator the other way round. What's the reason?

'Forward' in 'backward' are not about 'beam propagation' in these commands. They just say 'multiply from the first to last selected' (forward), and 'multiply from the last to first selected' (backward). That's all, sorry for the confusion. I think it's worth renaming them to something more clean. They are rather debug command used to compare multiplication result with what the test Python code gives.

I found that this is all fine when calculating the matrix

Yes, rezonator doesn't do analytical inversion, it just multiplies matrices one-by-one following the light path. The below test code shows that the multiplication is correct. We can see that back propagation matrix is not exactly an inverted forward one:

import numpy as np
from numpy.linalg import inv

M_L1_t = np.matrix([[1, 0.1], [0, 1]])
M_M1_t = np.matrix([[1, 0], [-20, 1]])
M_L2_t = np.matrix([[1, 0.05], [0, 1]])
M_M2_t = np.matrix([[1, 0], [-13.33333333333333, 1]])

M0_t = M_L1_t * M_M1_t * M_L2_t * M_M2_t
M0_t_1 = M_M2_t * M_L2_t * M_M1_t * M_L1_t
M0_t_inv = inv(M0_t)
print('M0_t\n', M0_t, '\n')
print('M0_t_1\n', M0_t_1, '\n')
print('M0_t_inv\n', M0_t_inv, '\n')    
M0_t
 [[ -1.66666667   0.05      ]
 [-20.           0.        ]] 

M0_t_1
 [[  0.           0.05      ]
 [-20.          -1.66666667]] 

M0_t_inv
 [[ 0.         -0.05      ]
 [20.         -1.66666667]] 

@photoniker
Copy link
Collaborator Author

Yes, it renaming would help to make it clear ;-)

@orion-project
Copy link
Owner

v2.0.12-beta8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants