Open-Systems-Pharmacology / PK-Sim

PK-Sim® is a comprehensive software tool for whole-body physiologically based pharmacokinetic modeling
Other
103 stars 50 forks source link

Snapshot/Compound: Differences in Solubility #723

Closed Yuri05 closed 6 years ago

Yuri05 commented 6 years ago

Steps to reproduce described in #720

Not sure, if it's really an issue here, but just to be complete: there are also some differences in solubility parameters shown.

In the compound there are 3 solubility alternatives: unbenannt

Comparison between original compound and compound reimported from snapshot shows following differences for the solubility:

unbenannt

For the alternative Sol3 (which is defined as table) RefPhand GainPerCharge do not matter anyway. Another difference in RefPhand GainPerCharge (where empty Top Container is shown in comparison): no idea where it comes from. In the UI those values for the 2 other solubility alternatives are identical.

msevestre commented 6 years ago

I cannot reproduce the problem with a new compound. For some reason, the default value in compound for Ref ph and Solubility per gain are not default values (7 vs 14 and 998 vs 1000). So when one create a NEW value for sol, those values are different

This project is just too complicated to step through (there is LIKE EVERYTHING changed in the compound)

Can you please recreate a simple project with only solubility so that I can reproduce the issue?

msevestre commented 6 years ago

ok I could reproduce with a smaller project. It has nothing to do with template I believe

msevestre commented 6 years ago

ah ah this is because of this code here


         var refSolubility = solubilityAlternative.Parameter(CoreConstants.Parameters.SOLUBILITY_AT_REFERENCE_PH);
         var refPh = solubilityAlternative.Parameter(CoreConstants.Parameters.REFERENCE_PH);
         var gainPerCharge = solubilityAlternative.Parameter(CoreConstants.Parameters.SOLUBILITY_GAIN_PER_CHARGE);
         var refSolubilityValue = refSolubility.Value;

         var formula = initializeSolubiltyTableFormula(_formulaFactory.CreateTableFormula(), refPh.Dimension, refSolubility.Dimension);
         compound.Parameter(CoreConstants.Parameters.REFERENCE_PH).Value = refPh.Value;
         compound.Parameter(CoreConstants.Parameters.SOLUBILITY_GAIN_PER_CHARGE).Value = gainPerCharge.Value;

         double solFactorRefpH = compound.Parameter(CoreConstants.Parameters.SOLUBILITY_P_KA__P_H_FACTOR).Value;
         var allPh = new List<double>();
         int ph = 0;
         while (ph <= 13)
         {
            allPh.AddRange(new[] {ph, ph + 0.5});
            ph++;
         }

         allPh.Add(14);
         foreach (var pH in allPh)
         {
            compound.Parameter(CoreConstants.Parameters.REFERENCE_PH).Value = pH;
            double solFactorAtpH = compound.Parameter(CoreConstants.Parameters.SOLUBILITY_P_KA__P_H_FACTOR).Value;
            formula.AddPoint(pH, refSolubilityValue * solFactorRefpH / solFactorAtpH);
         }

         return formula;
msevestre commented 6 years ago

We vary ph to be able to calculate the table according to formula That;s why it's 14 and the value of GAIN is set to teh one of the displayed atlernative!

msevestre commented 6 years ago

it's been there forever