For the calculation of density and temperature from pressure and specific entropy, there is always a fairly good starting guess available form the adjacent CV, so e.g. the values in the downstream connector are very good guesses. Giving these as starting values for the iteration should always converge quickly. (Possible exception: when on the other side of a phase boundary)
function dtofpsOnePhase extends Modelica.Icons.Function; input Modelica.Units.SI.Pressure p "pressure"; input Modelica.Units.SI.SpecificEntropy s "specific entropy"; input Modelica.Units.SI.Pressure delp "iteration accuracy"; input Modelica.Units.SI.SpecificEntropy dels "iteration accuracy"; output Modelica.Units.SI.Density d "density"; output Modelica.Units.SI.Temperature T "temperature (K)"; output Integer error "error flag: trouble if different from 0"; output Integer i; end dtofpsOnePhase;