Human eye has three types of color receptors which respond differently to different parts of the spectrum. See this chart.
One way to tackle your challenge is to basically simulate what the eye does: you take the spectrum as input, calculate how much it would excite each of the three color receptors based on their sensitivity to different parts of the spectrum and then use the three resulting numbers as RGB corresponding to the spectrum.
In order to compute the excitation level, you can integrate the product of the sensitivity SC(λ) of each of the three color receptors with your spectral power distribution P(λ) to obtain the three RGB numbers:
\begin{equation}
R = \int_{0}^{+\infty} S_R(\lambda) P(\lambda) d\lambda
\end{equation}
\begin{equation}
G = \int_{0}^{+\infty} S_G(\lambda) P(\lambda) d\lambda
\end{equation}
\begin{equation}
B = \int_{0}^{+\infty} S_B(\lambda) P(\lambda) d\lambda
\end{equation}
For prototyping you can probably just assume the sensitivity SC(λ) functions to be appropriately scaled and translated Gaussian functions of the wavelength. As you refine your model you should seek better sensitivity functions for each of the three types of color receptors.
Temperature, colour and energy all mean different things.
A single 'photon' has an associated energy, but it's misleading to think of this as a colour.
Three things that are (for most intents and purposes) equivalent, are energy $E$, wavelength $\lambda$ and frequency $f$, which are related by
$$ E = hf = hc/\lambda$$
where $c$ is the speed of light and $h$ is Planck's constant. Note that as the wavelength gets smaller, $E$ gets bigger.
Humans have three kinds of cone (colour sensing) cells - red, green and blue, but these do not "only" see red green and blue respectively - they are excited to varying degrees by the other wavelengths as well.
To a human, a combination of 500nm and 660nm light appears yellow, but this is physically a different situation to e.g. a yellow sodium lamp, which emits primarily ≈580nm photons.
Light from something like the sun or an incandescent lamp is even more complicated - these are near-perfect blackbodies, meaning that they emit at all wavelengths to some extent:
This excites all three of our cones equally, which our brain processes as "white". The crucial point is that there is no such thing as a "white" photon, but there is such thing as a "blue" photon.
The changing colour of a blackbody as it gets hotter is due to the movement of the "peak" wavelength, i.e. the wavelength at which most light is emitted, which for the Sun is about 500nm. If the sun were to get hotter, the peak would shift to the left, exciting more blue cones and fewer red cones. Likewise, if it got colder, the peak would shift to the right (lower energy), making the Sun look redder.
The Bottom Line
All wavelengths of photons carry energy, "white" light is a mixture of many wavelengths, and filtering this mixture to only get e.g. red light will make the filter heat up / reflect the energy elsewhere.
Best Answer
Color temperature describes how a particular light source produces light (in the visible range) that "looks like" light from a black body radiator at a particular temperature.
Because it is only intended to help with understanding the apparent color, it will not (in general) help you with figuring out the amount of light in the UV, unless you are actually talking about an incandescent emitter, and the enclosure of the emitter (light bulb) has excellent transmission properties across the range of wavelengths of interest.
In general the spectrum of a black body radiator is given by the Planck Equation. This earlier answer may be helpful to give you some background and plots.