The issue you are seeing is addressed in the "Tip" on the documentation for UnitConversion.
The problem is that you are have written your function calculateSolubilityCD to assume that the input arguments have specific units, but SimBiology does not pass the input arguments in with those units. I would address the issue using the advice from the Tip (ensure input arguments are passed in as dimensionless) as follows:
First, I would create parameters with value 1 and the units of your input and output arguments:
- Parameter mg_per_mL with value 1 and units "milligram/milliliter"
- Parameter g_per_mol with value 1 and units "gram/mole"
Then, I would change
Finally, you can remove the factors of 1000 from calculateSolubilityCD.