Here is how I would do it. For the simulation, I didn't have a separate model for an emitter and detector, so I just varied the resistance on the input LED on the opto-coupler to simulate modulating the light coupled across the gap in your opto-interupter. The opto-coupler is a reasonable proxy for the opto-interupter.
In your application, just use the 270Ω, or increase it if you can get by with less sensitivity. I set it up so the relay is pulled-in when the beam is broken. Currents and voltages are plotted as a function of the resistance of R2.