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

Possibility to export the differential equations #8

Open
albertomercurio opened this issue Sep 12, 2024 · 2 comments
Open

Possibility to export the differential equations #8

albertomercurio opened this issue Sep 12, 2024 · 2 comments

Comments

@albertomercurio
Copy link

Hello,

Is it possible to, given a circuit topology, export the set of differential equations? I think it could be done using ModelingToolkit.jl. This would be useful to solve the system in the time domain or just for having more control over solving the system.

Moreover, looking rapidly at the code, it seems that hbsolve generates some matrices, and not a system of differential equations. Is there a reference for that?

@kpobrien
Copy link
Owner

kpobrien commented Sep 12, 2024

Thanks for your question. Given a circuit topology and component values (either numeric or symbolic), the code computes the sparse capacitance, conductance, inductance, inverse inductance, and incidence matrices and the vector of Josephson inductances. A reference in the code is https://github.com/kpobrien/JosephsonCircuits.jl/blob/main/src/capindmat.jl and an article reference is https://arxiv.org/abs/2010.14929 .

For example, we can look at the matrices for the fluxed pumped JPA example

using JosephsonCircuits
@variables R Cc Cj Lj Cr Lr Ll Ldc K Lg
circuit = [
    ("P1","1","0",1),
    ("R1","1","0",R),
    # a very large inductor so the DC node flux of this node isn't floating
    ("L0","1","0",Lg), 
    ("C1","1","2",Cc),
    ("L1","2","3",Lr),
    ("C2","2","0",Cr),
    ("Lj1","3","0",Lj),
    ("Cj1","3","0",Cj),
    ("L2","3","4",Ll),
    ("Lj2","4","0",Lj),
    ("Cj2","4","0",Cj),
    ("L3","5","0",Ldc), 
    ("K1","L2","L3",K),
    # a port with a very large resistor so we can apply the bias across the port
    ("P2","5","0",2),
    ("R2","5","0",1000.0),
] 

circuitdefs = Dict(
    Lj =>219.63e-12,
    Lr =>0.4264e-9,
    Lg =>100.0e-9,
    Cc => 16.0e-15,
    Cj => 10.0e-15, 
    Cr => 0.4e-12,
    R => 50.0, 
    Ll => 34e-12, 
    K => 0.999, # the inverse inductance matrix for K=1.0 diverges, so set K<1.0
    Ldc => 0.74e-12,
)
nm = numericmatrices(circuit,circuitdefs)

Looking at the matrices

julia> nm.Cnm
5×5 SparseArrays.SparseMatrixCSC{Float64, Int64} with 6 stored entries:
  1.6e-14  -1.6e-14                     
 -1.6e-14   4.16e-13                    
                    1.0e-14            
                            1.0e-14    
                                      

julia> nm.Gnm
5×5 SparseArrays.SparseMatrixCSC{Float64, Int64} with 2 stored entries:
 0.02                
                    
                    
                    
                  0.001

julia> nm.invLnm
5×5 SparseArrays.SparseMatrixCSC{Float64, Int64} with 13 stored entries:
 1.0e7                                        
        2.34522e9  -2.34522e9                  
       -2.34522e9   1.47156e13  -1.47132e13   9.96317e13
                  -1.47132e13   1.47132e13  -9.96317e13
                   9.96317e13  -9.96317e13   6.76014e14

julia> nm.Rbnm
6×5 SparseArrays.SparseMatrixCSC{Int64, Int64} with 8 stored entries:
 1          
       1    
         1  
           1
   -1   1    
      -1  1  

julia> nm.Ljb
6-element SparseArrays.SparseVector{Float64, Int64} with 2 stored entries:
  [2]  =  2.1963e-10
  [3]  =  2.1963e-10

We use those matrices to generate the function and Jacobian and solve the nonlinear system of equations. The code evaluates the Josephson nonlinearity in the time domain in the branch flux basis and solves the linearized system in the frequency domain in the node flux basis.

Using those matrices to solve for the time domain dynamics using something like DifferentialEquations.jl or ModelingToolkit.jl should work although I have not tried it. Is that something you are interested in trying? How large of a system do you have in mind? Does it involve Josephson junctions or just linear circuit elements?

@albertomercurio
Copy link
Author

Hi @kpobrien,

Thank you for clarifying that. The possible application of ModelingToolkit would be to directly integrate this system with DifferentialEquations.jl for example. But there are many other applications, like, e.g., symbolic calculation.

Finally, in my systems I take into account also Josephson junctions. They might be of simple topology or more complex ones as well.

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

No branches or pull requests

2 participants