victorpreuss / YalRF

Yet-Another (Lazy) RF Circuit Simulator
MIT License
7 stars 5 forks source link

Question regarding a delayed voltage #4

Open beta68 opened 2 years ago

beta68 commented 2 years ago

Hello Victor,

Could you please let me know, how I can delay a voltage by a certain time. I am looking for something similar to the ADS function get_delay_v(userInst, node1, node2, delay, delayed_voltage). Let's assume I have a current source which is controlled by two voltages, Vgs and Vds. I would like to delay the voltage Vgs by tau. In AC analysis this is very simple. I can multiply the transconductance dI/dVgs by exp(-jomegatau) which is cos(omegatau) - j sin(omegatau). However, I do not know how to do this in your MultiToneHarmonicBalance.py. The easiest way would be to multiply the voltage phasor for the requested voltage by exp(-j omega tau). But this does not work... Any ideas are highly appreciated.

Thank you for having a look.

Kind regards, Rudi

victorpreuss commented 1 year ago

Hey there, my sincere apologies, I've been really busy this last month and forgot about my emails

I think you can accomplish the behavior you want using the phase parameter of the ac source, no? Just convert the amount of time delay you want to a phase shift using the desired frequency. Please let me know if this answer your question, thanks

beta68 commented 1 year ago

Hello Victor,

There is no need to apologize.

Unfortunately, I cannot use an AC source with a phase (=delay), because I need the delayed and non-delayed voltage at the same time.

I can use an LC ladder in order to delay a voltage. However, this influences convergence behavior in a bad way.

Kind regards, Rudi

Am 08.11.2022 um 23:45 schrieb Victor Preuss @.***>:

Hey there, my sincere apologies, I've been really busy this last month and forgot about my emails

I think you can accomplish the behavior you want using the phase parameter of the ac source, no? Just convert the amount of time delay you want to a phase shift using the desired frequency. Please let me know if this answer your question, thanks

— Reply to this email directly, view it on GitHub https://github.com/victorpreuss/YalRF/issues/4#issuecomment-1307939192, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXB6CNKBY3BCZYOM4GRYMYDWHLJX5ANCNFSM6AAAAAAQ6U7FLQ. You are receiving this because you authored the thread.

victorpreuss commented 1 year ago

Hey Rudi,

Not sure if I understood the issue. Could you give me an example? I'd like to test and check if there is something I can do.

I intend to play around with this code in the next few weeks (some refactor and improvements) as I'd like it to be more 'stable'. As you could probably see going through the code, it is very messy. And as you've also seen, some examples broke during development.

For harmonic balance convergence, one thing that often helped me is to increase the DC resistance in series with the inductor. This is currently "hidden" (yikes), as I included it directly in the harmonic balance inductor model (see Inductor.py). In the pic below, for the DC frequency I include a very large conductance (y = 1e6) in series with the inductor. Decreasing this conductance often helps with convergence. I usually went for y = 1e3, not sure why is 1e6 now :-)

image

Regards

beta68 commented 1 year ago

Hi Victor,

It is rather a feature request than an issue. I will try to explain in more detail:

I am currently implementing a non-linear transistor model with a voltage controlled current source (Id(Vgs, Vds)), which is drain current in dependence of gate-source and drain-source voltage. Some transistors require a voltage delay for the Vgs voltage, which is part of Id(Vgs(!), Vds) control. However, if I used an AC voltage source with a phase shift (=delay) at transistor gate in test bench, all transistor elements (such as my controlled capacitances, e.g. Cgs(Vgs, Vds)) will use the delayed voltage. But I only want to delay the drain current source such as Id(Vgs_delayed, Vds). In AC analysis this is very easy. I just can multiply the voltage to be delayed by exp(jomegatau), which will give a real part (cos(omega tau)) and an imaginary part (-j sin(omega tau)). I guess there are different options for this task in HB. I used an LC ladder which is working (at reduced convergence). Maybe one can also multiply the FFT bins or provide some kind of shift?

Thank you for giving me more insides into HB code. I will try to add some mOhms in series with the inductors.

I would also like to thank you once again for having a look into this.

Rudi

Am 09.11.2022 um 15:17 schrieb Victor Preuss @.***>:

Hey Rudi,

Not sure if I understood the issue. Could you give me an example? I'd like to test and check if there is something I can do.

I intend to play around with this code in the next few weeks (some refactor and improvements) as I'd like it to be more 'stable'. As you could probably see going through the code, it is very messy. And as you've also seen, some examples broke during development.

For harmonic balance convergence, one thing that often helped me is to increase the DC resistance in series with the inductor. This is currently "hidden" (yikes), as I included it directly in the harmonic balance inductor model (see Inductor.py). In the pic below, for the DC frequency I include a very large conductance (y = 1e6) in series with the inductor. Decreasing this conductance often helps with convergence. I usually went for y = 1e3, not sure why is 1e6 now :-)

https://user-images.githubusercontent.com/7533493/200851658-2f32eafa-78d8-435b-b797-ad35abd48fab.png Regards

— Reply to this email directly, view it on GitHub https://github.com/victorpreuss/YalRF/issues/4#issuecomment-1308833087, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXB6CNMTDA4XBUNZEQRB3YLWHOW77ANCNFSM6AAAAAAQ6U7FLQ. You are receiving this because you authored the thread.