JoeyDelp / JoSIM

Superconductor Circuit Simulator
MIT License
73 stars 33 forks source link

Can not apply two harmonic signals simultaneously #52

Closed Skedaddler closed 2 years ago

Skedaddler commented 2 years ago

Dear Joey,

I am using JoSIM for JTWPA simulations, and for these purposes I need to apply two harmonic signals simultaneously. I am trying to do it the next way:

PSIG 0 1 sin (0 10 14G)
PPUM 0 1 sin (0 0.01 6.9G)

Here I tried to apply phase harmonic signals with different amplitudes with no biasing and frequencies at 14 and 6.9 GHz.

But unfortunately I am getting the next error:

Matrix is singular. Matrix will have no solution.
Please check the components in the netlist.
The program will abort.

I do not quite understand why it should cause a matrix with no solution, basically I just want to apply a sum of two harmonic signals. Can this problem be solved in the last version?

Also I would like to mention that it is not possible to do any math operation with outputs as far as I know. For example, if I want to look at the sum of currents through the dc SQUID, I can not just write

.print i(B01)+i(B02)

but I have to make the next output

.print i(B01)
.print i(B02)

and then sum it in OriginPro. It is not critical but causes light inconviniences.

Best regards, Daniil

JoeyDelp commented 2 years ago

Hi Daniil,

Apologies for the late reply. A matrix singular error is caused by the solver not finding a solution to the problem and is most often a result of an incorrect netlist.

Now let's look at what you are trying to achieve. You wish to have two harmonic signals affect the same node in a circuit, and you are attempting to do this with phase sources.

A phase source is simply a scaled time integral of a voltage source: equation This means it operates in the exact same way a voltage source would in the circuit netlist.

As with a voltage source, connecting it to a singular node defines the value for that node. By attempting to connect another voltage or phase source to the same node you are creating a problem that cannot be solved since you are trying to tell the simulator that the node has a fixed value but this fixed value is both source values which are different. This causes a problem that the solver cannot find a solution to and thus generates a singular matrix error.

If you wish to have the sum of both signals affect the components connected to the node I would suggest putting the sources in series.

As for the math operations in the output vectors, I am aware that this is still not implemented. I have not prioritized this much since it can be done with most plotting tools. It is, however, on the todo list of features to be implemented and will be available in the near future.

Hope this helps, Joey

Skedaddler commented 2 years ago

Hi Joey,

thanks a lot for your response and for keeping JoSIM updated. After your detailed explanation the origin of the error became clear.

Following your advice, I applied two harmonic signals with different frequencies to a resistor by connecting two generators in series through the node 4 that is not used anywhere in the circuit:

V1 0 4 sin (0 0.5u 5G)
V2 4 2 sin (0 1u 7G)

Then I looked at the spectrum of the signal through the resistor via OriginPro. Since it is a linear element, there should be no interaction between the signals, so the spectrum should contain only two frequencies (5 GHz with the amplitude 0.5 mV and 7 GHz with the amplitude 1 mV).

image

So as it can be seen from the graph, connecting two signals sources in series equals to the sum of the signals indeed.

Thanks again for JoSIM and your support.

Very grateful, Daniil