/** * Compound needed to reach a target concentration for an element. * * In case no element is specified the default proxy element for the * compound is used. * * @param Concentration $target Target concentration. * @param CompoundInterface $compound Compound to be added. * @param string|null $element Element used for target. * * @throws ImpossibleCalculation When the target concentration is impossible. * * @return float Times the compound should be added to reach the target. */ public function targetElement(Concentration $target, CompoundInterface $compound, $element = null) { if ($target->toUnit() * $compound->getVolume()->toUnit() >= $compound->element($element)->toUnit()) { throw new ImpossibleCalculation(); } return $target->toUnit() * $this->volume->toUnit() / ($compound->element($element)->toUnit() - $target->toUnit() * $compound->getVolume()->toUnit()); }
public function testToString() { $concentration = new Concentration(3.0E-6); $this->assertEquals('3ppm', $concentration->__toString()); }