Beispiel #1
0
func (lhc *LHComponent) Sample(v wunit.Volume) Liquid {
	// need to jig around with units a bit here
	// Should probably just make Vunit, Cunit etc. wunits anyway
	meas := wunit.ConcreteMeasurement{lhc.Vol, wunit.ParsePrefixedUnit(lhc.Vunit)}

	// we need some logic potentially

	if v.SIValue() > meas.SIValue() {
		wutil.Error(errors.New(fmt.Sprintf("LHComponent ID: %s Not enough volume for sample", lhc.ID)))
	} else if v.SIValue() == meas.SIValue() {
		return lhc
	}
	smp := CopyLHComponent(lhc)
	// need a convention here

	smp.Vol = v.RawValue()
	smp.Vunit = v.Unit().PrefixedSymbol()
	meas.Subtract(&v.ConcreteMeasurement)
	lhc.Vol = meas.RawValue()
	return smp
}
Beispiel #2
0
// this is pretty dodgy... we will have to be quite careful here
// the core problem is how to maintain a list of components and volumes
// but respect the physical fact that we can't actually unmix things
func (w *LHWell) Remove(v wunit.Volume) Physical {
	defer w.updateVolume()
	ret := w.WContents[0]

	if ret.Vol > v.SIValue() {
		ret.Vol = v.SIValue()
		w.WContents[0].Vol -= v.SIValue()
	} else {
		w.WContents = w.WContents[1:len(w.WContents)]
	}
	return ret
}