public static IDimension FractionDimensionForSpecs() { if (_fractionDimension == null) { _fractionDimension = new Dimension(new BaseDimensionRepresentation(), Constants.Dimension.FRACTION, ""); _fractionDimension.AddUnit(new Unit("%", 1e-2, 0)); } return(_fractionDimension); }
public static IDimension MassConcentrationDimensionForSpecs() { if (_massConcentrationDimension == null) { _massConcentrationDimension = new Dimension(new BaseDimensionRepresentation { MassExponent = 3, LengthExponent = -1 }, Constants.Dimension.MASS_CONCENTRATION, "µg/l"); _massConcentrationDimension.AddUnit(new Unit("g/l", 1E6, 0)); } return(_massConcentrationDimension); }
public static IDimension ConcentrationDimensionForSpecs() { if (_concentrationDimension == null) { _concentrationDimension = new Dimension(new BaseDimensionRepresentation { AmountExponent = 3, LengthExponent = -1 }, Constants.Dimension.MOLAR_CONCENTRATION, "µmol/l"); _concentrationDimension.AddUnit(new Unit("mol/l", 1E6, 0)); } return(_concentrationDimension); }
public static IDimension TimeDimensionForSpecs() { if (_timeDimension == null) { _timeDimension = new Dimension(new BaseDimensionRepresentation { TimeExponent = 1 }, Constants.Dimension.TIME, "min"); _timeDimension.AddUnit(new Unit("h", 60, 0)); } return(_timeDimension); }
private static IDimensionFactory generateFactory() { var factory = new DimensionFactory(); var amountDimension = new Dimension(new BaseDimensionRepresentation(), Constants.Dimension.AMOUNT, "Molar Volume"); amountDimension.AddUnit(new Unit("mol", 1, 0)); var massDimension = new Dimension(new BaseDimensionRepresentation(), DimensionNames.Mass, "g"); massDimension.AddUnit(new Unit("kg", 1000, 0)); massDimension.AddUnit(new Unit("mg", 0.001, 0)); var concentrationDimension = new Dimension(new BaseDimensionRepresentation(), DimensionNames.Concentration, "mol"); factory.AddDimension(massDimension); factory.AddDimension(concentrationDimension); factory.AddDimension(amountDimension); factory.AddDimension(new Dimension(new BaseDimensionRepresentation(), Constants.Dimension.AMOUNT_PER_TIME, "mol/min")); factory.AddDimension(new Dimension(new BaseDimensionRepresentation(), Constants.Dimension.VOLUME, "l")); factory.AddDimension(Constants.Dimension.NO_DIMENSION); var timeDimension = new Dimension(new BaseDimensionRepresentation(), Constants.Dimension.TIME, Constants.Dimension.Units.Minutes); timeDimension.AddUnit(new Unit(Constants.Dimension.Units.Days, 60 * 24, 0)); timeDimension.AddUnit(new Unit(Constants.Dimension.Units.Hours, 60, 0)); timeDimension.AddUnit(new Unit(Constants.Dimension.Units.Months, 60 * 24 * 30, 0)); timeDimension.AddUnit(new Unit(Constants.Dimension.Units.Seconds, 1.0 / 60, 0)); timeDimension.AddUnit(new Unit(Constants.Dimension.Units.Weeks, 60 * 24 * 7, 0)); timeDimension.AddUnit(new Unit(Constants.Dimension.Units.Years, 60 * 24 * 365, 0)); factory.AddDimension(timeDimension); return(factory); }
/// <summary> /// Converts a SBML UnitDefinition into a MoBi Unit. /// </summary> public IDimension ConvertUnit(UnitDefinition unitDefinition) { var sbmlUnit = unitDefinition.getId(); var dimension = _moBiDimensionFactory.TryGetDimensionCaseInsensitive(sbmlUnit); if (dimension != Constants.Dimension.NO_DIMENSION) { _sbmlInformation.MobiDimension[sbmlUnit] = dimension; return dimension; } var newFactor = 1.0; var unitsList = new List<Unit>(); var brList = new List<BaseDimensionRepresentation>(); for (long i = 0; i < unitDefinition.getNumUnits(); i++) { var mobiUnit = SBMLBaseUnitToMoBi(unitDefinition.getUnit(i)); if (mobiUnit == null) continue; var unitDimension = _moBiDimensionFactory.DimensionForUnit(mobiUnit.Name); var unitBr = unitDimension.BaseRepresentation; unitBr = SetExponents(unitDefinition, unitBr, i); brList.Add(unitBr); if (Math.Abs(newFactor) < 0.0001) { newFactor = unitDefinition.getUnit(i).getMultiplier() * Math.Pow(10, unitDefinition.getUnit(i).getScale()) * Math.Pow(mobiUnit.Factor, unitDefinition.getUnit(i).getExponent()); } else { newFactor = newFactor * unitDefinition.getUnit(i).getMultiplier() * Math.Pow(10, unitDefinition.getUnit(i).getScale()) * Math.Pow(mobiUnit.Factor, unitDefinition.getUnit(i).getExponent()); } unitsList.Add(mobiUnit); } var baseDimensionRepresentation = CreateBaseDimRepresentationExponents(brList); IDimension newDim = new Dimension(baseDimensionRepresentation, String.Format("SBML_{0}",unitDefinition.getId()), String.Format("SBML_{0}_BaseUnit",unitDefinition.getId())); var newBaseUnit = newDim.BaseUnit; newBaseUnit.Visible = false; var newUnit = new Unit(unitDefinition.getId(), newFactor, 0); newDim.AddUnit(newUnit); newDim.DefaultUnit = newUnit; _sbmlInformation.MobiDimension[sbmlUnit] = newDim; if (_moBiDimensionFactory.Dimensions.All(dim => dim.Name != newDim.Name)) _moBiDimensionFactory.AddDimension(newDim); return newDim; }
protected override void Context() { base.Context(); _similarDimension = new Dimension(new BaseDimensionRepresentation(), "XXX", "1/mol"); _similarDimension.AddUnit("mol", 10, 0); _tables = new DataTableProvider(numberOfRowsToImport: 1).ImportTables(); _startValuesBuildingBlock.Add(new ParameterStartValue { ContainerPath = ContainerPathFromDataTableRow(_tables, 0), Name = "ParameterName", Dimension = _similarDimension, DisplayUnit = _similarDimension.DefaultUnit }); }
private void addDummyDimension(KeyValuePair <string, string> dimensions) { var newDimension = _dimensionFactory.Dimension(dimensions.Value); var dummyDimension = new Dimension(new BaseDimensionRepresentation(), dimensions.Key, newDimension.BaseUnit.Name); foreach (var unit in newDimension.Units) { if (unit == newDimension.BaseUnit) { continue; } dummyDimension.AddUnit(unit.Name, unit.Factor, unit.Offset); } _dummyDimensionsForConversion.Add(dummyDimension); }
protected override void Context() { base.Context(); var dimension = new Dimension(new BaseDimensionRepresentation { TimeExponent = 1 }, "Time", "min"); dimension.AddUnit("h", 60, 0); sut.StartTimeParameter = new ParameterDTO(DomainHelperForSpecs.ConstantParameterWithValue(20).WithDimension(dimension)); sut.StartTimeParameter.Parameter.DisplayUnit = dimension.Unit("min"); sut.EndTimeParameter = new ParameterDTO(DomainHelperForSpecs.ConstantParameterWithValue(120).WithDimension(dimension)); sut.EndTimeParameter.Parameter.DisplayUnit = dimension.Unit("h"); }
protected override void Context() { base.Context(); _dataRepository = new DataRepository(); _timeDimension = new Dimension(new BaseDimensionRepresentation { TimeExponent = 1 }, "Time", "min"); _hourUnit = _timeDimension.AddUnit("h", 60, 0); _concentrationDimension = new Dimension(new BaseDimensionRepresentation { MassExponent = 1 }, "Conc", "mg/l"); _gramPerLiterUnit = _concentrationDimension.AddUnit("g/l", 1000, 0); _time = new BaseGrid("Time", _timeDimension); _conc = new DataColumn("Conc", _concentrationDimension, _time); _dataRepository.Add(_conc); A.CallTo(() => _displayUnitRetriever.PreferredUnitFor(_conc)).Returns(_gramPerLiterUnit); A.CallTo(() => _displayUnitRetriever.PreferredUnitFor(_time)).Returns(_hourUnit); }
protected override void Context() { base.Context(); var dimension = new Dimension(new BaseDimensionRepresentation(), "none", "l/f"); _newUnit = new Unit("kl/f", 1000, 0); dimension.AddUnit(_newUnit); _pkSimParameter = new PKSimParameter { Dimension = dimension }; _allPKanalysis.First().PKAnalysis.Add(_pkSimParameter); _settings = new DefaultPresentationSettings(); A.CallTo(() => _presenterSettingsTask.PresentationSettingsFor <DefaultPresentationSettings>(A <IPresenterWithSettings> ._, A <IWithId> ._)).Returns(_settings); _settings.SetSetting(_pkSimParameter.Name, "kl/f"); A.CallTo(() => _populationDataCollector.Name).Returns("TOTO"); sut.LoadSettingsForSubject(A.Fake <IWithId>()); }