def show_viscosity_results(self): """ lauch when clicked on result Compute, store the computation and lauch a popup""" #save data store = get_store() try: store.put('Capillary', value=float(self.ids.Capillary.text), unit=self.ids.CapillaryUnit.text) store.put('Towindow', value=float(self.ids.Towindow.text), unit=self.ids.TowindowUnit.text) store.put('Idiameter', value=float(self.ids.Idiameter.text), unit=self.ids.IdiameterUnit.text) store.put('Pressure', value=float(self.ids.Pressure.text), unit=self.ids.PressureUnit.text) store.put('Detectiontime', value=float(self.ids.Detectiontime.text), unit=self.ids.DetectiontimeUnit.text) except ValueError: data = {} data["errcode"] = 1 data["errtext"] = "Empty field not allowed" self._popup = ErrorPopup() self._popup.show_popup(data) return #get and use error codes computation = Capillary() errcode, errtext = computation.save_vicosity_result() data = {} data["errcode"] = errcode data["errtext"] = errtext if data["errcode"] == 1: self._popup = ErrorPopup() else: self._popup = ViscosityPopup() self._popup.show_popup(data)
def show_flow_results(self): """ lauch when clicked on result Compute, store the computation and lauch a popup""" store = get_store() try: store.put('Capillary', value=float(self.ids.Capillary.text), unit=self.ids.CapillaryUnit.text) store.put('Towindow', value=float(self.ids.Towindow.text), unit=self.ids.TowindowUnit.text) store.put('Idiameter', value=float(self.ids.Idiameter.text), unit=self.ids.IdiameterUnit.text) store.put('Voltage', value=float(self.ids.Voltage.text), unit=self.ids.VoltageUnit.text) store.put('Electroosmosis', value=float(self.ids.Electroosmosis.text), unit=self.ids.ElectroosmosisUnit.text) except ValueError: data = {} data["errcode"] = 1 data["errtext"] = "Empty field not allowed" self._popup = ErrorPopup() self._popup.show_popup(data) return #get and save errors and value computation = Capillary() errcode, errtext = computation.save_flow_result() data = {} data["errcode"] = errcode data["errtext"] = errtext if data["errcode"] == 1: self._popup = ErrorPopup() else: self._popup = FlowPopup() self._popup.show_popup(data)
def save_mobility_result(self): '''Compute and save the result for the mobility result ''' store = get_store() if self.electro_osmosis_time == 0: self.electro_osmosis_time = 1000000 self.capillary = Capillary(self.total_length, self.to_window_length, self.diameter, self.pressure, self.duration, self.viscosity, self.molweight, self.concentration, self.voltage, self.electric_current, self.detection_time, self.electro_osmosis_time) self.electro_osmosis_time = 0.0 try : microeof = self.micro_eof() except ZeroDivisionError: if self.voltage == 0: return 1, "The voltage cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" #saving store.put("MicroEOF", value=microeof, unit="cm²/V/s") for i in range(1, store.get('Nbtimecompound')["value"]+1): keystore = "Timecompound"+str(i) time = TimeUnits.convert_unit(float(store.get(keystore)["value"]), store.get(keystore)["unit"], u"s") if time == 0: return 1, "The time for compound " + str(i) + " cannot be null" microep = self.micro_ep(time) store.put("MicroEP"+str(i), value=microep, unit="cm²/V/s") return 0, ""
def show_injection_results(self): """ lauch when clicked on result. Compute, store the computation and lauch a popup""" #save data store = get_store() try: store.put('Capillary', value=float(self.ids.Capillary.text), unit=self.ids.CapillaryUnit.text) store.put('Towindow', value=float(self.ids.Towindow.text), unit=self.ids.TowindowUnit.text) store.put('Idiameter', value=float(self.ids.Idiameter.text), unit=self.ids.IdiameterUnit.text) store.put('Pressure', value=float(self.ids.Pressure.text), unit=self.ids.PressureUnit.text) store.put('Time', value=float(self.ids.Time.text), unit=self.ids.TimeUnit.text) store.put('Viscosity', value=float(self.ids.Viscosity.text), unit=self.ids.ViscosityUnit.text) store.put('Concentration', value=float(self.ids.Concentration.text), unit=self.ids.ConcentrationUnit.text) store.put('Molweight', value=float(self.ids.Molweight.text), unit=self.ids.MolweightUnit.text) store.put('Voltage', value=float(self.ids.Voltage.text), unit=self.ids.VoltageUnit.text) except ValueError: data = {} data["errcode"] = 1 data["errtext"] = "Empty field not allowed" self._popup = ErrorPopup() self._popup.show_popup(data) return #add data computation = Capillary() errcode, errtext = computation.save_injection_result() data = {} data["errcode"] = errcode data["errtext"] = errtext if data["errcode"] == 1: self._popup = ErrorPopup() else: self._popup = InjectionPopup() self._popup.show_popup(data)
def show_mobility_results(self): """ lauch when clicked on result Compute, store the computation and lauch a popup""" store = get_store() try: store.put('Capillary', value=float(self.ids.Capillary.text), unit=self.ids.CapillaryUnit.text) store.put('Towindow', value=float(self.ids.Towindow.text), unit=self.ids.TowindowUnit.text) store.put('Voltage', value=float(self.ids.Voltage.text), unit=self.ids.VoltageUnit.text) store.put('Electroosmosis', value=float(self.ids.Electroosmosis.text), unit=self.ids.ElectroosmosisUnit.text) store.put('Timecompound1', value=float(self.ids.Timecompound1.text), unit=self.ids.Timecompound1Unit.text) except ValueError: data = {} data["errcode"] = 1 data["errtext"] = "Empty field not allowed" self._popup = ErrorPopup() self._popup.show_popup(data) return #save all the timecompound for sublist in self.timecompoundlist: store.put(sublist[1].id, value=float(sublist[1].text), unit=sublist[2].text) #get and save error and values computation = Capillary() errcode, errtext = computation.save_mobility_result() data = {} data["errcode"] = errcode data["errtext"] = errtext if data["errcode"] == 1: self._popup = ErrorPopup() else: self._popup = MobilityPopup() self._popup.show_popup(data)
def setUp(self): self.capillary = Capillary() self.capillary.total_length = 100.0 self.capillary.to_window_length = 90.0 self.capillary.diameter = 30.0 self.capillary.pressure = 30.0 self.capillary.duration = 21.0 self.capillary.viscosity = 1.0 self.capillary.molweight = 150000 self.capillary.concentration = 21.0 self.capillary.electric_current = 4.0 self.capillary.voltage = 30000.0 self.capillary.detection_time = 3600.0 self.capillary.electro_osmosis_time = 330.0
def __make(self): # Create base_pcb self.base_pcb = BasePCB() base_x, base_y, base_z = self.params.base_pcb['size'] # Create capillaries cap_temp = Capillary() cap_numb = self.params.base_pcb['capillary_number'] cap_spac = self.params.base_pcb['capillary_spacing'] cap_diam = self.params.capillary['diameter'] self.capillary_list = [] for i, pos_x in enumerate(self.base_pcb.cap_x_pos): z_pos = 0.5 * cap_diam + 0.5 * base_z cap = Translate(cap_temp.part, v=[pos_x, 0, z_pos]) self.capillary_list.append(cap) # Create spacers spacer_temp = SpacerPCB() spacer_x, spacer_y, spacer_z = self.params.spacer_pcb['size'] self.spacer_list = [] print 'spacer x-positions' print '-' * 60 for x_pos in self.base_pcb.spacer_x_pos: print 5.5 + x_pos * MM2INCH z_pos = 0.5 * spacer_z + 0.5 * base_z spacer = Translate(spacer_temp, v=[x_pos, 0, z_pos]) self.spacer_list.append(spacer) print # Create top pcbs top_temp = TopPCB() top_x, top_y, top_z = self.params.top_pcb['size'] self.top_list = [] print 'capacitence pads x-posistion' print '-' * 60 for x_pos in self.base_pcb.cap_x_pos: print 5.5 + x_pos * MM2INCH z_pos = 0.5 * top_z + 0.5 * base_z + spacer_z top = Translate(top_temp, v=[x_pos, 0, z_pos]) self.top_list.append(top) print # Create back plate self.back_plate = BackPlate() plate_thickness = self.params.back_plate['thickness'] x_pos = 0.5 * (self.base_pcb.cap_x_pos[0] + self.base_pcb.cap_x_pos[-1]) z_pos = -0.5 * plate_thickness - 0.5 * base_z self.back_plate = Translate(self.back_plate, v=[x_pos, 0, z_pos]) # Create standoffs standoff_height = self.params.standoff['height'] standoff_temp = Standoff() self.standoff_list = [] z_pos = -0.5 * standoff_height - 0.5 * base_z for x_pos, y_pos in self.base_pcb.mount_hole_xy: standoff = Translate(standoff_temp, v=(x_pos, y_pos, z_pos)) self.standoff_list.append(standoff) # Create screws self.screw_list = [] screw_temp = FourForty() z_pos = 0.5 * base_z print 'mount hole x,y-positions' print '-' * 60 for x_pos, y_pos in self.base_pcb.mount_hole_xy: print 5.5 + x_pos * MM2INCH, 2.625 - y_pos * MM2INCH screw = Translate(screw_temp, v=(x_pos, y_pos, z_pos)) self.screw_list.append(screw) print
def __init__(self): '''Get all needed values from the store ''' store = get_store() # The length of the capillary (centimeter) self.total_length = LengthUnits.convert_unit(float(store.get('Capillary')["value"]), store.get('Capillary')["unit"], u"cm") # The window length (centimeter) self.to_window_length = LengthUnits.convert_unit(float(store.get('Towindow')["value"]), store.get('Towindow')["unit"], u"cm") # The capillary inside diameter (micrometer) #PROBLEM WITH UNICODE NON ASCII self.diameter = LengthUnits.convert_unit(float(store.get('Idiameter')["value"]), store.get('Idiameter')["unit"], u"µm") # The pressure drop across the capillary (mbar) self.pressure = PressureUnits.convert_unit(float(store.get('Pressure')["value"]), store.get('Pressure')["unit"], u"mbar") # The time the pressure is applied (second) self.duration = TimeUnits.convert_unit(float(store.get('Time')["value"]), store.get('Time')["unit"], u"s") # The buffer viscosity (cp) self.viscosity = float(store.get('Viscosity')["value"]) # The molecular weight (g/mol) self.molweight = float(store.get("Molweight")["value"]) # Analyte concentration (g/L) if store.get('Concentration')["unit"] == u"mmol/L": concentration = MolConcentrationUnits.convert_unit(float(store.get('Concentration')["value"]), store.get('Concentration')["unit"], u"mol/L") self.concentration = self.molweight * concentration else: self.concentration = float(store.get('Concentration')["value"]) # The voltage applied to the capillary (volt) self.voltage = VoltUnits.convert_unit(float(store.get('Voltage')["value"]), store.get('Voltage')["unit"], u"V") # The current applied to the capillary (microampere) self.electric_current = float(store.get('Electriccurrent')["value"]) # The detection time (s) self.detection_time = TimeUnits.convert_unit(float(store.get('Detectiontime')["value"]), store.get('Detectiontime')["unit"], u"s") # The electro-osmosis time (s) self.electro_osmosis_time = TimeUnits.convert_unit(float(store.get('Electroosmosis')["value"]), store.get('Electroosmosis')["unit"], u"s") self.capillary = Capillary(self.total_length, self.to_window_length, self.diameter, self.pressure, self.duration, self.viscosity, self.molweight, self.concentration, self.voltage, self.electric_current, self.detection_time, self.electro_osmosis_time)
class CapillaryManager: '''CapillaryManager class ''' def __init__(self): '''Get all needed values from the store ''' store = get_store() # The length of the capillary (centimeter) self.total_length = LengthUnits.convert_unit(float(store.get('Capillary')["value"]), store.get('Capillary')["unit"], u"cm") # The window length (centimeter) self.to_window_length = LengthUnits.convert_unit(float(store.get('Towindow')["value"]), store.get('Towindow')["unit"], u"cm") # The capillary inside diameter (micrometer) #PROBLEM WITH UNICODE NON ASCII self.diameter = LengthUnits.convert_unit(float(store.get('Idiameter')["value"]), store.get('Idiameter')["unit"], u"µm") # The pressure drop across the capillary (mbar) self.pressure = PressureUnits.convert_unit(float(store.get('Pressure')["value"]), store.get('Pressure')["unit"], u"mbar") # The time the pressure is applied (second) self.duration = TimeUnits.convert_unit(float(store.get('Time')["value"]), store.get('Time')["unit"], u"s") # The buffer viscosity (cp) self.viscosity = float(store.get('Viscosity')["value"]) # The molecular weight (g/mol) self.molweight = float(store.get("Molweight")["value"]) # Analyte concentration (g/L) if store.get('Concentration')["unit"] == u"mmol/L": concentration = MolConcentrationUnits.convert_unit(float(store.get('Concentration')["value"]), store.get('Concentration')["unit"], u"mol/L") self.concentration = self.molweight * concentration else: self.concentration = float(store.get('Concentration')["value"]) # The voltage applied to the capillary (volt) self.voltage = VoltUnits.convert_unit(float(store.get('Voltage')["value"]), store.get('Voltage')["unit"], u"V") # The current applied to the capillary (microampere) self.electric_current = float(store.get('Electriccurrent')["value"]) # The detection time (s) self.detection_time = TimeUnits.convert_unit(float(store.get('Detectiontime')["value"]), store.get('Detectiontime')["unit"], u"s") # The electro-osmosis time (s) self.electro_osmosis_time = TimeUnits.convert_unit(float(store.get('Electroosmosis')["value"]), store.get('Electroosmosis')["unit"], u"s") self.capillary = Capillary(self.total_length, self.to_window_length, self.diameter, self.pressure, self.duration, self.viscosity, self.molweight, self.concentration, self.voltage, self.electric_current, self.detection_time, self.electro_osmosis_time) def delivered_volume(self): '''Return the volume delivered during the injection ''' return self.capillary.delivered_volume() def capillary_volume(self): '''Return the volume of the capillary ''' return self.capillary.capillary_volume() def to_window_volume(self): '''Return the volume to window ''' return self.capillary.to_window_volume() def injection_plug_length(self): '''Return the plug_length used in the injection ''' return self.capillary.injection_plug_length() def time_to_replace_volume(self): '''Return the time required to replace the volume ''' return self.capillary.time_to_replace_volume() def compute_viscosity(self): '''Return an assessment of the viscosity ''' return self.capillary.compute_viscosity() def compute_conductivity(self): '''Return the conductivity ''' return self.capillary.compute_conductivity() def field_strength(self): '''Return the field strength ''' return self.capillary.field_strength() def micro_eof(self): '''Return the Micro EOF ''' return self.capillary.micro_eof() def length_per_minute(self): '''Return the length per minute ''' return self.capillary.length_per_minute() def flow_rate_inj(self): '''Return the flow rate for the flow rate screen ''' flow_rate_inj_per_second = self.capillary.flow_rate_inj() return flow_rate_inj_per_second / TimeUnits.convert_unit(1, u"s", u"min") def flow_rate_flow(self): '''Return the flow rate per minute for the flow screen ''' return self.capillary.flow_rate_flow() def injection_pressure(self): '''Return the injection pressure in psi per second ''' inj_pressure = self.capillary.injection_pressure() return inj_pressure * PressureUnits.convert_unit(1, u"mbar", u"psi") def analyte_injected_ng(self): '''Return the analyte injected in ng ''' return self.capillary.analyte_injected_ng() def analyte_injected_pmol(self): '''Return the analyte injected in pmol ''' return self.capillary.analyte_injected_pmol() def micro_app(self, time): '''Return the micro_app time in second ''' return self.capillary.micro_app(time) def micro_ep(self, time): '''Return the micro_ep time in second ''' return self.capillary.micro_ep(time) def save_vicosity_result(self): '''Compute and save the results for the vicosity screen ''' store = get_store() try: viscosity = self.compute_viscosity() except ZeroDivisionError: if self.total_length == 0: return 1, "The capillary length cannot be null" else: return 1, "The window length cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" #saving store.put('Viscosity', value=viscosity, unit="cp") return 0, "" def save_conductivy_result(self): '''Compute and save the result for the conductivy screen ''' store = get_store() try: conductivity = self.compute_conductivity() except ZeroDivisionError: if self.voltage == 0: return 1, "The voltage cannot be null" else: return 1, "The diameter cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" store.put('Conductivity', value=conductivity, unit="S/m") return 0, "" def save_flow_result(self): '''Compute and save the result for the flow screen ''' store = get_store() try: strengh = self.field_strength() microeof = self.micro_eof() lpermin = self.length_per_minute() flowrate = self.flow_rate_flow() except ZeroDivisionError: if self.total_length == 0: return 1, "The capillary length cannot be null" elif self.electro_osmosis_time: return 1, "The EOF Time cannot be null" else: return 1, "The voltage cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" #saving store.put("Fieldstrength", value=strengh, unit="V/cm") store.put("MicroEOF", value=microeof, unit="cm²/V/s") store.put("Lengthpermin", value=LengthUnits.convert_unit(lpermin, u'm', u'cm'), unit="cm") store.put("Flowrate", value=flowrate, unit="nL/min") return 0, "" def save_injection_result(self): '''Compute and save the result for the injection screen ''' store = get_store() try: hydroinj = self.delivered_volume() capilaryvol = self.capillary_volume() capilaryvoltowin = self.to_window_volume() pluglen = self.injection_plug_length() plugpertotallen = ((pluglen/10)/self.total_length)*100 plugpertowinlen = ((pluglen/10)/self.to_window_length)*100 timetoonevols = self.time_to_replace_volume() timetoonevolm = TimeUnits.convert_unit(timetoonevols, u's', u'min') analyteinjng = self.analyte_injected_ng() analyteinjpmol = self.analyte_injected_pmol() injpressure = self.injection_pressure() strengh = self.field_strength() flowrate = self.flow_rate_inj() except ZeroDivisionError: if self.viscosity == 0: return 1, "The viscosity cannot be null" elif self.total_length == 0: return 1, "The capillary length cannot be null" elif self.to_window_length == 0: return 1, "The length to window cannot be null" elif self.diameter == 0: return 1, "The diameter cannot be null" elif self.pressure == 0: return 1, "The pressure cannot be null" elif self.duration == 0: return 1, "The time cannot be null" else : return 1, "The molecular weight cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" #special warning if plugpertowinlen > 100.: ret = (2, "The capillary is full") else: ret = (0, "") #floor for values if hydroinj > capilaryvol: hydroinj = capilaryvol if plugpertotallen > 100.: plugpertotallen = 100. if plugpertowinlen > 100.: plugpertowinlen = 100. #saving store.put("Hydrodynamicinjection", value=hydroinj, unit="nL") store.put("Capillaryvolume", value=capilaryvol, unit="nL") store.put("Capillaryvolumetowin", value=capilaryvoltowin, unit="nL") store.put("Injectionpluglen", value=pluglen, unit="mm") store.put("Pluglenpertotallen", value=plugpertotallen, unit="%") store.put("Pluglenperlentowin", value=plugpertowinlen, unit="%") #store.put("Timetoreplaces", value=timetoonevols, unit="s") #store.put("Timetoreplacem", value=timetoonevolm, unit="min") store.put("Injectedanalyteng", value=analyteinjng, unit="ng") store.put("Injectedanalytepmol", value=analyteinjpmol, unit="pmol") store.put("Injectionpressure", value=injpressure, unit="psi/s") store.put("Fieldstrength", value=strengh, unit="V/cm") store.put("Flowrate", value=flowrate, unit="nL/min") return ret def save_mobility_result(self): '''Compute and save the result for the mobility result ''' store = get_store() if self.electro_osmosis_time == 0: self.electro_osmosis_time = 1000000 self.capillary = Capillary(self.total_length, self.to_window_length, self.diameter, self.pressure, self.duration, self.viscosity, self.molweight, self.concentration, self.voltage, self.electric_current, self.detection_time, self.electro_osmosis_time) self.electro_osmosis_time = 0.0 try : microeof = self.micro_eof() except ZeroDivisionError: if self.voltage == 0: return 1, "The voltage cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" #saving store.put("MicroEOF", value=microeof, unit="cm²/V/s") for i in range(1, store.get('Nbtimecompound')["value"]+1): keystore = "Timecompound"+str(i) time = TimeUnits.convert_unit(float(store.get(keystore)["value"]), store.get(keystore)["unit"], u"s") if time == 0: return 1, "The time for compound " + str(i) + " cannot be null" microep = self.micro_ep(time) store.put("MicroEP"+str(i), value=microep, unit="cm²/V/s") return 0, ""
class TestCapillary(unittest.TestCase): def setUp(self): self.capillary = Capillary() self.capillary.total_length = 100.0 self.capillary.to_window_length = 90.0 self.capillary.diameter = 30.0 self.capillary.pressure = 30.0 self.capillary.duration = 21.0 self.capillary.viscosity = 1.0 self.capillary.molweight = 150000 self.capillary.concentration = 21.0 self.capillary.electric_current = 4.0 self.capillary.voltage = 30000.0 self.capillary.detection_time = 3600.0 self.capillary.electro_osmosis_time = 330.0 def test_delivered_volume(self): value = self.capillary.delivered_volume() self.assertAlmostEqual(value, 1.25, places=2) def test_capillary_volume(self): value = self.capillary.capillary_volume() self.assertAlmostEqual(value, 706.86, places=2) def test_to_window_volume(self): value = self.capillary.to_window_volume() self.assertAlmostEqual(value, 636.17, places=2) def test_injection_plug_length(self): value = self.capillary.injection_plug_length() self.assertAlmostEqual(value, 1.77, places=2) def test_time_to_replace_volume(self): value = self.capillary.time_to_replace_volume() self.assertAlmostEqual(value, 11851.85, places=2) def test_compute_viscosity(self): value = self.capillary.compute_viscosity() self.assertAlmostEqual(value, 0.34, places=2) def test_compute_conductivity(self): value = self.capillary.compute_conductivity() self.assertAlmostEqual(value, 0.188, places=2) def test_field_strength(self): value = self.capillary.field_strength() self.assertAlmostEqual(value, 300) def test_micro_eof(self): value = self.capillary.micro_eof() self.assertAlmostEqual(value, 0.000909, places=6) def test_length_per_minute(self): value = self.capillary.length_per_minute() self.assertAlmostEqual(value, 0.1636, places=4) def test_flow_rate_inj(self): value = self.capillary.flow_rate_inj() self.assertAlmostEqual(value, 0.0596, places=4) def test_flow_rate_flow(self): value = self.capillary.flow_rate_flow() self.assertAlmostEqual(value, 115.67, places=2) def test_injection_pressure(self): value = self.capillary.injection_pressure() self.assertAlmostEqual(value, 630.0, places=1) def test_analyte_injected_ng(self): value = self.capillary.analyte_injected_ng() self.assertAlmostEqual(value, 26.3, places=1) def test_analyte_injected_pmol(self): value = self.capillary.analyte_injected_pmol() self.assertAlmostEqual(value, 0.18, places=2) def test_micro_app(self): value = self.capillary.micro_app(330) self.assertAlmostEqual(value, 0.00091, places=5) def test_micro_ep(self): value = self.capillary.micro_ep(60) self.assertAlmostEqual(value, 0.00409, places=5)