The 2nd attempt was to make sure that the temperature shape was decreasing at log tau > -2.5. I did this by checking whether the function is monotonically decreasing or not in that area. If this is not the case, a new random temperature curve is created.
This helped to eliminate the cases where the temperature curve led to emission lines instead of absorption lines.
The problem with this is, firstly, that it requires more computing time since I need to redo the randomisation of the temperature.
Another problem is to find enough nodes that the temperature curve looks similar to known models but also not to have too many nodes, otherwise the randomisation may be not so random after all.
Another problem is, that I want to include the correlation between the temperature and the magnetic field to a specific degree. I did not want to restrict it too much, but the magnetic field strength should have an influence. The chosen approach to implement this correlation was not that trivial, as it highly depends on my maximum magnetic field strength. I did it in such a way that the temperature nodes are smaller the higher the magnetic field is. As I have changing maximum magnetic field strengths (depending on what I want to simulate) the temperature range for the nodes needed to be adapted depending on the maximum field strength. I implemented it the following way: I have 5 nodes and each node has a temperature range. The maximum value in the ranges depends on the magnetic field value at log tau 1 (the first value in the model). I simply factorised this value and subtracted it from the maximum reachable temperature number. These factorising numbers depend highly on the maximum magnetic field and need to be adapted depending on the magnetic field. This makes it not suitable but with a better implementation, this influence could have been neglected.
I encountered problems that when I have a high magnetic field, the temperature curves were flat ⇒ The factorising numbers were too big but needed for lower magnetic fields (otherwise the magnetic field would play no role in smaller magnetic field strengths)