Code Monkey home page Code Monkey logo

Comments (5)

photoniker avatar photoniker commented on September 21, 2024

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.

from rezonator2.

photoniker avatar photoniker commented on September 21, 2024

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?

from rezonator2.

Chunosov avatar Chunosov commented on September 21, 2024

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]] 

from rezonator2.

photoniker avatar photoniker commented on September 21, 2024

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

from rezonator2.

orion-project avatar orion-project commented on September 21, 2024

v2.0.12-beta8

from rezonator2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.