Пример #1
0
def run_compute(self):

    parseRR_Inputs(self)

    inputsValid = rr_testAssertions(self)

    if not inputsValid:
        return

    self.statusbar.showMessage("Computing...")

    try:
        compute_rr(self, self.rr1_low, self.rr1_high, self.rr2_low,
                   self.rr2_high, self.stepDensity, self.data)

    except Exception:
        displayMessage(
            self, "Error",
            "An error occured during the simulation. Please adjust the program inputs.    "
        )
        return

    if self.abort_rr:
        self.statusbar.showMessage("Aborted.", 5000)
    else:
        self.statusbar.showMessage("Done.", 5000)
Пример #2
0
def save_state(self):
	parseUI_Inputs(self)
	state = {}
	state['Polymer System'] = self.numMonomers
	state['Model'] = self.model 
	state['Hold Composition'] = self.holdComposition
	state['Average DP'] = self.averageDP
	state['Percent Conversion'] = self.percentConversion
	state['Monomer Pool Size'] = self.poolSize
	state['Monomer Ratios'] = self.monomerRatios
	state['Reactivity Ratios'] = self.rrLoadList
	state['Graph Type'] = self.graphType
	state['Run Length Monomer'] = self.runLengthMonomer
	state['Rows to Show'] = self.numRows
	state['Animation'] = self.animate
	state['Legend'] = self.show_legend
	file = str(QFileDialog.getSaveFileName(self, "Select Directory")[0])
	if file:
		try:
			pickle_out = open(file, 'wb')
			pickle.dump(state, pickle_out)
			pickle_out.close()

		except Exception as e:
			text = "The filename you selected is invalid.	"
			displayMessage(self, "Error", text)
Пример #3
0
def load_state(self):
	file = str(QFileDialog.getOpenFileName(self, "Select Directory")[0])
	if file:
		try:
			pickle_in = open(file, 'rb')
			state = pickle.load(pickle_in)
		except Exception as e:
			text = "Invalid load file.		"
			displayMessage(self, "Error", text)	
			return
	else:
		return

	self.modelComboBox.setProperty('currentText', state['Model'])
	self.systemComboBox.setProperty('currentIndex', getSystemIndex(state['Polymer System']))
	self.holdCheckBox.setProperty('checked', state['Hold Composition'])
	self.dpSpinBox.setProperty('value', state['Average DP'])
	self.conversionDoubleSpinBox.setProperty('value', state['Percent Conversion'])
	self.poolSpinBox.setProperty('value', state['Monomer Pool Size'])
	self.graphComboBox.setProperty('currentText', state['Graph Type'])
	self.runLengthSpinBox.setProperty('value', state['Run Length Monomer'])
	self.rowsSpinBox.setProperty('value', state['Rows to Show'])
	self.animateComboBox.setProperty('currentText', getState(state['Animation']))
	self.legendComboBox.setProperty('currentText', getState(state['Legend']))
	setMonomerCompositions(self, state)
	setReactivities(self, state)
	filename = os.path.basename(file)
	self.setWindowTitle("Compositional Drift v{} - {}".format(self.version, filename))
Пример #4
0
def load_data_sets(self):
	file = str(QFileDialog.getOpenFileName(self, "Select Directory")[0])
	dataSets = []
	if file:
		try:
			with open(file) as csv_file:
				csv_reader = csv.reader(csv_file, delimiter=',')
				for row in csv_reader:
					dataSets.append([float(row[0]), float(row[1]), float(row[2])])

				copy_data(self, dataSets)

		except Exception as e:
			text = "Invalid load file.		"	
			displayMessage(self, "Error", text)	
			return
	else:
		return
Пример #5
0
def rr_testAssertions(self):
    inputsValid = True

    for data in self.data:
        conversion = data[0]
        fraction = data[1]
        init_fraction = data[2]

        if conversion <= 0.0001:
            displayMessage(self, "Error", "Conversion too close to zero!	")
            inputsValid = False
            break

        elif init_fraction == 0:
            displayMessage(self, "Error",
                           "Initial Monomer Fraction cannot be zero!	")
            inputsValid = False
            break

    if self.rr1_low >= self.rr1_high or self.rr2_low >= self.rr1_high:
        displayMessage(self, "Error",
                       "Lower bound must be less than upper bound!	")
        inputsValid = False

    return inputsValid
Пример #6
0
def testAssertions(self):
	inputsValid = True	

	if self.poolSize < self.averageDP*self.percentConversion/100:
		displayMessage(self, "Error", "Monomer Pool Size is too small!	")
		inputsValid = False

	elif self.numPolymers < 1:
		displayMessage(self, "Error", "DP or Monomer Pool Size is too small!	")
		inputsValid = False

	elif int(self.averageDP * self.percentConversion / 100) <= 0:
		displayMessage(self, "Error", "DP or Conversion cannot be zero!		")
		inputsValid = False

	elif min(self.monomerRatios) == 0:
		displayMessage(self, "Error", "Monomer Ratios cannot be zero!	")
		inputsValid = False

	return inputsValid