LTSpice: How to vary resistances in a simulation depending on the value of a voltage?
I haven't spent much time considering a method for this. But it sounds as though you may have an arbitrary function that computes \$R\$ based upon an applied voltage \$V\$.



You might use LTSpice's .FUNC to do something like this:

.FUNC MYFUNC(A) {3*A}


(That's just a random function to illustrate the idea.)

Then you could just drop down a resistor, which will default to a value of "R". Now, right-click on the "R" there and get a prompt to allow you to change it. The dialog box should be titled "Enter a new value for Rx". Enter "R={MYFUNC(V(N005,N006))}" or something like that (if you know the node names, use those.) That should allow you to make up an arbitrary function based upon some formula you concoct.

You don't have to use .FUNC, by the way. You can just enter the formula directly into the "R={...}" expression there.



However, the above method has at least one problem. The node names will have to be hard-coded. So this can be a problem as you move forward in a circuit and want the "resistor" to have its value depend solely on a complex function of the impressed voltage on it, regardless of the global circuit node names. For that, I'd go with a .SUBCKT approach.

Here, you'd just drop down an new R like you always do. Then ctrl-right-click the R symbol. Edit the "Prefix" to "X", modify "InstName" to specify "X1" or "X2" or something like that, get rid of the "Value" entry (edit it and delete it), and modify the "SpiceLine" entry to specify a subcircuit name of your choice. Now you have a nice subcircuit symbol that looks like a resistor, but LTSpice now thinks it is a subcircuit.

Now just add a subcircuit. Hit "S" and get the Spice directive dialog box to pop up. Now enter something like this (I'm using the subcircuit name of "XYZ" here):

.SUBCKT XYZ 1 2
GRES 1 2 VALUE={1.0/(10k*V(1,2))}
.ENDS


What I've done above is just use a "G" device. This device can now look at its own terminals, get the voltage from them, and then compute some current based on that. In the above formula, I decided I wanted to mimic a resistor whose resistance magnitude is, ignoring dimensional analysis for now, \$R=V^2\cdot 10\:\textrm{k}\Omega\$. (I squared the voltage to make sure the result is always positive or zero. Allowing zero probably isn't the greatest idea. So just be aware.) Given that, you can work out that the current should be \$\frac{V}{V^2\cdot 10\:\textrm{k}\Omega}=\frac{1}{V\cdot 10\:\textrm{k}\Omega}\$. So that's how I got the equation to use there.



You can do combinations. You can create separate .FUNC functions and use those inside of your subcircuit. You can make the subcircuit as complicated as you want, too.