¿ªÔÆÌåÓý

LTspice 24.1.4 - Limit function


 

If I run a schematic with limit function in 24.0.12:
?
b:u1:g_abmii22 u1:32b 0 i=v(u1:32)*(limit(((v(u1:31vdd1)-v(u1:vde))/(v(u1:31vdd1)-v(u1:31vdd2))), 0, 1))
?
If I run the same schematic with limit function in 24.1.4:
?
u1:BG_ABMII22 u1:32B 0 I=v(u1:32)*if(((v(u1:31vdd1)-v(u1:vde))/(v(u1:31vdd1)-v(u1:31vdd2)))<0,0,if(((v(u1:31vdd1)-v(u1:vde))/(v(u1:31vdd1)-v(u1:31vdd2)))>1,1,(v(u1:31vdd1)-v(u1:vde))/(v(u1:31vdd1)-v(u1:31vdd2))))
?
Both simulations were run with expanded netlist turned on.
?
I guess the expanded netlist format changed.
But did the "Limit" function change too?
?


 

One of the exciting new features of LTspice 24.1 (which is the best thing since the invention of sliced bread :-) is that it compiles the math expressions of behavioral sources into highly optimized machine code matching the host machine. In this process, the limit() function is decomposed into more primitive operations to allow the optimizer to "see through it". It's the result of this decomposition that you see in the expanded netlist.
Performance measurements have shown that this new approach consistently cuts the time spent for behavioral source down to 50% (!)
?
Best Regards,
Mathias
?
On Sun, Mar 2, 2025 at 06:27 PM, eetech00 wrote:

If I run a schematic with limit function in 24.0.12:
?
b:u1:g_abmii22 u1:32b 0 i=v(u1:32)*(limit(((v(u1:31vdd1)-v(u1:vde))/(v(u1:31vdd1)-v(u1:31vdd2))), 0, 1))
?
If I run the same schematic with limit function in 24.1.4:
?
u1:BG_ABMII22 u1:32B 0 I=v(u1:32)*if(((v(u1:31vdd1)-v(u1:vde))/(v(u1:31vdd1)-v(u1:31vdd2)))<0,0,if(((v(u1:31vdd1)-v(u1:vde))/(v(u1:31vdd1)-v(u1:31vdd2)))>1,1,(v(u1:31vdd1)-v(u1:vde))/(v(u1:31vdd1)-v(u1:31vdd2))))
?
Both simulations were run with expanded netlist turned on.
?
I guess the expanded netlist format changed.
But did the "Limit" function change too?
?


 

Yes this is really a exciting feature for transient analysis of examples with behavioral sources. :-)
But there is? a problem if i made only a .op simulation of a circuit with a huge amount of behavioral sources.
The optimization overhead is here in the relation to the simulation time much to long.?
Therefore i suggest to let the user set or unset this feature by a .options parameter in the simulation file

Best regards?
Friedrich?





Am Mo., M?rz 3, 2025 at 8:44 schrieb Mathias Born via groups.io
<mathias.born@...>:
One of the exciting new features of LTspice 24.1 (which is the best thing since the invention of sliced bread :-) is that it compiles the math expressions of behavioral sources into highly optimized machine code matching the host machine. In this process, the limit() function is decomposed into more primitive operations to allow the optimizer to "see through it". It's the result of this decomposition that you see in the expanded netlist.
Performance measurements have shown that this new approach consistently cuts the time spent for behavioral source down to 50% (!)
?
Best Regards,
Mathias
?
On Sun, Mar 2, 2025 at 06:27 PM, eetech00 wrote:
If I run a schematic with limit function in 24.0.12:
?
b:u1:g_abmii22 u1:32b 0 i=v(u1:32)*(limit(((v(u1:31vdd1)-v(u1:vde))/(v(u1:31vdd1)-v(u1:31vdd2))), 0, 1))
?
If I run the same schematic with limit function in 24.1.4:
?
u1:BG_ABMII22 u1:32B 0 I=v(u1:32)*if(((v(u1:31vdd1)-v(u1:vde))/(v(u1:31vdd1)-v(u1:31vdd2)))<0,0,if(((v(u1:31vdd1)-v(u1:vde))/(v(u1:31vdd1)-v(u1:31vdd2)))>1,1,(v(u1:31vdd1)-v(u1:vde))/(v(u1:31vdd1)-v(u1:31vdd2))))
?
Both simulations were run with expanded netlist turned on.
?
I guess the expanded netlist format changed.
But did the "Limit" function change too?
?


 

On Sun, Mar 2, 2025 at 11:44 PM, Mathias Born wrote:
One of the exciting new features of LTspice 24.1 (which is the best thing since the invention of sliced bread :-) is that it compiles the math expressions of behavioral sources into highly optimized machine code matching the host machine. In this process, the limit() function is decomposed into more primitive operations to allow the optimizer to "see through it". It's the result of this decomposition that you see in the expanded netlist.
Performance measurements have shown that this new approach consistently cuts the time spent for behavioral source down to 50% (!)
?
Best Regards,
Mathias
?
Hi Mathias
?
In the past, I always tried to avoid if() statements to prevent convergence issues, and often used LIMIT to wrap if() statements.
So I was concerned on how this re-write would affect convergence.
?


 

Since limit() always has been implemented this way with if() functions, convergence isn't affected because there is no change.
Unfortunately it also means your efforts were in vain.
?
Best Regards,
Mathias
?
On Mon, Mar 3, 2025 at 10:36 PM, eetech00 wrote:

Hi Mathias
?
In the past, I always tried to avoid if() statements to prevent convergence issues, and often used LIMIT to wrap if() statements.
So I was concerned on how this re-write would affect convergence.
?