Adding Photodiode to LTspice
The easiest way to get a photodiode, and to control it, is to use one of the built-in optocouplers.
The base/collector junction of a phototransistor is a photodiode (just ignore the emitter):



Or use the 4N2x.sub/CNY17.sub as a model to build your own subcircuit.