Open-Systems-Pharmacology / OSPSuite-R

R package for the OSPSuite
https://www.open-systems-pharmacology.org/OSPSuite-R/
Other
29 stars 12 forks source link

Molar to mass conversions #1492

Open pchelle opened 1 month ago

pchelle commented 1 month ago

For Concentration, AUC and Amount/Mass conversion works as expected. But nor for other dimensions that could use molar weight.

library(ospsuite)
#> Loading required package: rSharp

toUnit(
  quantityOrDimension = "Amount",
  values = 1,
  targetUnit = "mg",
  sourceUnit = "mmol",
  molWeight = 1
)
#> [1] 1e+09

toUnit(
  quantityOrDimension = "Amount per time",
  values = 1,
  targetUnit = "mg/s",
  sourceUnit = "mmol/s",
  molWeight = 1
)
#> Error in do.call(".External", c(list("r_call_method", self$pointer, methodName), : Type:    OSPSuite.Utility.Exceptions.OSPSuiteException
#> Message: Unit 'mg/s' is not defined in dimension 'Amount per time'.
#> Method:  Double[] convertToUnit(OSPSuite.Core.Domain.UnitSystem.IDimension, System.String, System.Nullable`1[System.Double], Double[])
#> Stack trace:
#>    at OSPSuite.R.Services.DimensionTask.convertToUnit(IDimension dimension, String targetUnit, Nullable`1 molWeight, Double[] valuesInBaseUnit)
#>    at OSPSuite.R.Services.DimensionTask.ConvertToUnit(String dimensionName, String targetUnit, Double valueInBaseUnit, Double molWeight)
#>    at InvokeStub_DimensionTask.ConvertToUnit(Object, Span`1)
#>    at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

Created on 2024-10-24 with reprex v2.1.0