# Behavioral Sources : How to apply a power function & how to measure its power?

For the Behavioral Sources ‘B components’ (Behavioral Voltage, Behavioral Current, Behavioral Resistor), I’ve noticed that there is no way to apply a power function (Only V, I, or R are allowed). The ability to express a power function is available in LTSpice and I would use it often when applying dynamic / function defined power loads.

The current workaround for this is to use use the behavioral sources with Power defined as a V, I, or R term…
i.e. P = VI,
therefore I = {Voltage at Bx pin 1} / {Function describing intended load, in Watts}

QUESTION 1:
Is there a plan for behavioral sources to be defined by a Power Function?
Is there any other workaround from what I’ve described above?

I’ve also noticed that when I try to measure the power of my behavioral source load, I’m unable to – this is evan after adding the .options savepowers=1 directive. Ctrl+left click on the Behavioral Source component does not show a power measurement.

Question 2:
Will there be support for power measurements of Behavioral Sources, the same as there currenlty is for the other ‘H’, ‘I’, and ‘V’ power sources?

May be a bit off topic, but I also wonder how a behavioral source with P should behave. If I assume P is instantaneous power (to sink from a source), here are two examples that in LTspice to think of

Example #1 : Source V1 is a 0.5V sine wave offset to 1V, and B1 sink 100W.
In this example, instantaneous power not always at 100W

Example #2 : Source V1 is a 0.5V sine wave, and B1 sink 100W
In this example, not a single instantaneous power can reach 100W

P acts quite weird in LTspice, it seems defining behavioral current source can make thing more clear if to sink user defined instantaneous power
I = {instantaneous power} / {voltage at Bx pin -}

Example of a power source in LTspice:

@Engelhardt

Hi Mike,

Do you have support for the behavioral sources to provide power functions on the roadmap?

Right now, I run into issues (Timestep too small) if I try to define a behavioral source (R, V, or I) – with the R/V/I value defined based on a power waveform (i.e. R = V(vsys)**2/V(Px), where ‘vsys’ is the net on one of the behavioral resistor terminals (the other to GND/0) and V(Px) is an arbitrary Power waveform defined by the voltage output of a configured Voltage Source.

Having these non-convergance issues and the lack of Vprxover are preventing me from moving over to QSpice from LTSpice.

@adl Probably a better idea is to use a behavioral resistor instead of a B source, and that gives you what you need. Since you “legally” committed, now you have to switch to QSPICE

The same technique to avoid using a constant current source as an output load (VERY bad idea): you can use a behavioral resistor instead of a constant source.

You could get theoretically PURE CONSTANT power (and not limited) if you replace the expression I={power}/{Vcc} with I={power}/abs(V(Vcc)), unfortunately that gives you infinity current when the voltage is zero, highly unrealistic. But, if for some reason you need that PURE CONSTANT power and you do not have zero input voltage, go for it! Although, better use something like I={power}/(abs(V(Vcc))+1m) to avoid divide by zero.

1 Like