The global temperature may also be stepped to cover a temperature range. For example:

.STEP temp -40 20 5
​

steps the global temperature from -40 °C to +20 °C in steps of 5 °.

The local temperature can be set by attaching the temperature to the device's value, see figure 1:

Figure 1: 100kOhm, tc=50ppm, Temp=100 °C

In this example the resistor is 100kOhm at 27 °C (the default temperature for LTSPICE). The resistor is assigned a temperature coefficient of tc=0.00005=50ppm. The temperature of the resistor is set to 100 °C. In the same way the temperature can be set for other components, provided the component or the component's parameters support temperature dependency, e.g. transistors.

Another way of setting local temperature is using parametric values (“What if”), see figure 2:

Figure 2: BC817 with parametric temperature value

BC817-40 temp={T1}
.PARAM T1=100 or
.STEP PARAM T1 -20 100 20
​

Where T1 is the parametric value and is either set to 100 °C (.PARAM directive) or is stepped from -20 °C to +100 °C (.STEP directive). Note that .PARAM and .STEP are mutually exclusive.

Global temperature setting and local temperature settings can be combined to simulate e.g. local heating due to power dissipation of power components.

SPICE help topics to look at: .TEMP, .STEP

Simulating an RTD sensor (e.g. PT100)
An RTD sensor (e.g. PT100) is characterized by a rather strong temperature dependency (as opposed to "standard" resistors where temperature dependency usually is an unwanted effect which manufacturers try to minimize). As such, an RTD sensor can be described by the same equation as a standard resistor, albeit with much larger temperature coefficients.

Due to the additional term of 4th order for temperature below 0 °C, LTSPICEs built-in temperature dependency for resistors („Simulating temperature dependency“) cannot be used. Instead a combination of parameters using SPICE directives needs to be called for help (see also „Using parametric values in LTSPICE“):

Figure 3 sample PT100 circuit using parameters.

In figure 3 the following set of parameters is used to describe R1 as PT100 sensor:

Note: LTSPICE uses "**" for exponentiation, thus a**b is a to the power of b or ab.

The temperature is stepped from -100 °C to +100 °C in steps of 10 °
The temperature coefficients tc1...tc3 are defined as parameters to improve readability of the final formula only. I could have put them directly into the equation. The same goes for the base resistance R0 = 100 Ohm at 0 °C.
The specialty shows in the expression 1-u(Temp) in the last line. The LTSPICE function u(x) is a step function with u(x)=1 for x > 0 and u(x)=0 else. By computing 1-u(Temp) the temperature coefficient tc3 is effective only if Temp < 0 °C.