.op solution to .dll

Hello, I have created a .dll device which takes some inputs and returns a value which is going to be a value of a resistor in one part of the circuit. I use a behavioral resistor like R=V(node_dll) where node_dll in the output of the .dll device. This simulation works perfectly standalone, but when I transfer it to my whole circuit and I put the behavioral resistor, .op does not work and gmin and source stepping fail. I was wondering if there is a way to help .op to converge for this .dll block. Extra note: If I use the same behavioral resistance where its value is set to be R=V(node_voltage), a random voltage source, it works perfectly. Appreciate any help. Thanks

Any chance your behavioral resistor has 0 ohms in .op and is causing such convergence issues? Or is a positive feedback loop being formed? One has to be very careful when using a behavioral resistor.

I have experience in attempting to use a behavioral resistor for a constant power load, but eventually, I had to use a smooth transition voltage-controlled switch to act as a variable resistor for that task. When feedback is involved, a behavioral resistor may give you trouble. But just from my experience.

If I ignore the behavioral resistance and run the simulation, the .dll’s output is not 0, it is like 10milliohms. Can you please explain how you implemented a controlled resistance without using a behavioral resistance. I can try that approach as well. Thanks
To fully explain what I am doing: I am simulating a DC/DC converter with no controller/feedback. Based on the current waveforms, I am doing some harmonics analysis within the .dll and calculating the right ESR for my inductor. Then I have a behavioral resistance in series with my inductor whose value is controlled by the output of the .dll device. When I try to control the resistance with a voltage source, everything is fine, but when I try to control it with the .dll, it does not converge .tran.

This is my constant DC power load for a buck converter. Initially I use a behavioral resistance but also with convergence issue. That why I changed to a smooth transition switch (negative Vh).

eLoad-DC (Complete Schematic).qsch (16.5 KB)

@a.farakhor Well, I retried implementing this e-load with behavioral resistance, and now everything seems to be working. I have uploaded this schematic for your reference. Possibly my skill is not good enough, and I may have done something incorrectly before.

Behavioral resistance allows for a linear relationship between control voltage and resistance, whereas a smooth transition switch does not.

eLoad-DC (Complete Schematic) Behavorial-R.qsch (17.9 KB)

Thanks for taking time and checking this. I will be working on my simulation again and see what goes wrong with it.

Try using the limit() function to restrict the maximum and minimum resistance of the behavioral resistance.

If you look at the picture I shares at first, we can see that the behavioral resistance works fine if it is controlled by any voltage source. The problem arises when we want to control it with a .dll block!!! This is something that I do not understand.

I ran a test with a DLL block to control it, but did not encounter any issues. According to your post, it seems that a DLL with a behavioral resistor can work in your simulation when it is standalone but only returns an error in the entire schematic. Without your schematic and .cpp file, it is difficult to review. You can upload your schematic and DLL file. If your original circuit is very complex, consider breaking it down. This is also the way I normally troubleshoot problems in simulations.