def __init__(self, name="", parent_app=None): """**Constructor**""" super().__init__(name, parent_app) self.parameters["xmin"] = Parameter( name="xmin", value=-np.Infinity, description="Minimum x", type=ParameterType.real, ) self.parameters["xmax"] = Parameter( name="xmax", value=np.Infinity, description="Maximum x", type=ParameterType.real, ) self.parameters["ymin"] = Parameter( name="ymin", value=-np.Infinity, description="Minimum y", type=ParameterType.real, ) self.parameters["ymax"] = Parameter( name="ymax", value=np.Infinity, description="Maximum y", type=ParameterType.real, )
def __init__(self, name="", parent_app=None): """**Constructor**""" super().__init__(name, parent_app) # self.function = self.findpeaks # main Tool function self.parameters["threshold"] = Parameter( name="threshold", value=0.3, description="threshold for peak detection", type=ParameterType.real, ) self.parameters["minimum_distance"] = Parameter( name="minimum_distance", value=5, description="minimum distance (in datapoints) between peaks", type=ParameterType.integer, ) self.parameters["minpeaks"] = Parameter( name="minpeaks", value=False, description="Find minimum peaks", type=ParameterType.boolean, display_flag=False, ) self.parameters["parabola"] = Parameter( name="parabola", value=False, description="Fit Parabola to peak", type=ParameterType.boolean, display_flag=False, ) self.seriesarray = [] self.axarray = []
def __init__(self, name="", parent_dataset=None, axarr=None): """**Constructor**""" super().__init__(name, parent_dataset, axarr) self.function = self.calculate # main theory function self.has_modes = False # True if the theory has modes self.parameters["G0"] = Parameter( "G0", 1e6, "Modulus c*kB*T/N", ParameterType.real, opt_type=OptType.opt, min_value=0, ) self.parameters["tau0"] = Parameter( "tau0", 1e-3, "segment relaxation time", ParameterType.real, opt_type=OptType.opt, min_value=0, ) self.parameters["M0"] = Parameter( "M0", 0.2, "segment molar mass", ParameterType.real, opt_type=OptType.opt, min_value=0.01, )
def __init__(self, name="", parent_dataset=None, ax=None): """**Constructor** Keyword Arguments: - name {str} -- Name of the theory (default: {""}) - parent_dataset {DataSet} -- DataSet that contains this theory (default: {None}) - ax {Axes array} -- Matplotlib axes where the theory will plot the data (default: {None}) """ super().__init__(name, parent_dataset, ax) self.MAX_DEGREE = 10 self.function = self.polynomial self.parameters["n"] = Parameter( name="n", value=1, description="Degree of Polynomial", type=ParameterType.integer, opt_type=OptType.const, display_flag=False) for i in range(self.parameters["n"].value + 1): self.parameters["A%d" % i] = Parameter( "A%d" % i, 1.0, "Coefficient order %d" % i, ParameterType.real, opt_type=OptType.opt) self.Qprint("%s: A0 + A1*x + A2*x^2 + ..." % self.thname)
def __init__(self, name="", parent_dataset=None, ax=None): """**Constructor**""" super().__init__(name, parent_dataset, ax) self.function = self.TheoryTTSShiftAutomatic self.parameters["T"] = Parameter( name="T", value=25, description="Temperature to shift to, in °C", type=ParameterType.real, opt_type=OptType.const, display_flag=False, ) self.parameters["vert"] = Parameter( name="vert", value=True, description="Shift vertically", type=ParameterType.boolean, opt_type=OptType.const, display_flag=False, ) self.Mwset, self.Mw, self.Tdict = self.get_cases() self.current_master_curve = None self.current_table = None self.current_file_min = None self.shiftParameters = {} self.aT_vs_T = {} for k in self.tables.keys(): self.shiftParameters[k] = (0.0, 0.0) # log10 of horizontal, then vertical
def __init__(self, name="", parent_dataset=None, ax=None): """**Constructor**""" super().__init__(name, parent_dataset, ax) self.MAX_DEGREE = 10 self.function = self.algebraicexpression self.parameters["n"] = Parameter( name="n", value=2, description="Number of Parameters", type=ParameterType.integer, opt_type=OptType.const, display_flag=False) self.parameters["expression"] = Parameter( name="expression", value="A0+A1*x", description="Algebraic Expression", type=ParameterType.string, opt_type=OptType.const, display_flag=False) for i in range(self.parameters["n"].value): self.parameters["A%d" % i] = Parameter( "A%d" % i, 1.0, "Parameter %d" % i, ParameterType.real, opt_type=OptType.opt) safe_list = ['sin', 'cos', 'tan', 'arccos', 'arcsin', 'arctan', 'arctan2', 'deg2rad', 'rad2deg', 'sinh', 'cosh', 'tanh', 'arcsinh', 'arccosh', 'arctanh', 'around', 'round_', 'rint', 'floor', 'ceil','trunc', 'exp', 'log', 'log10', 'fabs', 'mod', 'e', 'pi', 'power', 'sqrt'] self.safe_dict = {} for k in safe_list: self.safe_dict[k] = globals().get(k, None)
def __init__(self, name="", parent_dataset=None, axarr=None): """**Constructor**""" super().__init__(name, parent_dataset, axarr) self.function = self.GEX # main theory function self.has_modes = False # True if the theory has modes self.parameters["logW0"] = Parameter( name="logW0", value=5, description="Log Normalization constant", type=ParameterType.real, opt_type=OptType.opt, ) self.parameters["logM0"] = Parameter( name="logM0", value=5, description="Log molecular weight", type=ParameterType.real, opt_type=OptType.opt, ) self.parameters["a"] = Parameter( name="a", value=1, description="Exponent parameter", type=ParameterType.real, opt_type=OptType.opt, min_value=0, ) self.parameters["b"] = Parameter( name="b", value=0.5, description="Exponent parameter", type=ParameterType.real, opt_type=OptType.opt, min_value=0, )
def set_param_value(self, name, value): """Set the value of a theory parameter""" if name == "nmodes": oldn = self.parameters["nmodes"].value message, success = super().set_param_value(name, value) if not success: return message, success if name == "nmodes": for i in range(self.parameters["nmodes"].value): self.parameters["phi%02d" % i] = Parameter( name="phi%02d" % i, value=0.0, description="Volume fraction of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0, ) self.parameters["tauD%02d" % i] = Parameter( name="tauD%02d" % i, value=100.0, description="Terminal time of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0, ) if oldn > self.parameters["nmodes"].value: for i in range(self.parameters["nmodes"].value, oldn): del self.parameters["phi%02d" % i] del self.parameters["tauD%02d" % i] return "", True
def __init__(self, name="", parent_dataset=None, ax=None): """**Constructor**""" super().__init__(name, parent_dataset, ax) self.function = self.MaxwellModesFrequency self.has_modes = True self.MAX_MODES = 40 self.view_modes = True wmin = self.parent_dataset.minpositivecol(0) wmax = self.parent_dataset.maxcol(0) nmodes = int(np.round(np.log10(wmax / wmin))) self.parameters["logwmin"] = Parameter( "logwmin", np.log10(wmin), "Log of frequency range minimum", ParameterType.real, opt_type=OptType.opt, min_value=-10, max_value=10) self.parameters["logwmax"] = Parameter( "logwmax", np.log10(wmax), "Log of frequency range maximum", ParameterType.real, opt_type=OptType.opt, min_value=-10, max_value=10) self.parameters["nmodes"] = Parameter( name="nmodes", value=nmodes, description="Number of Maxwell modes", type=ParameterType.integer, opt_type=OptType.const, display_flag=False, min_value=1, max_value=self.MAX_MODES) # Interpolate modes from data if nmodes > 1: w = np.logspace(np.log10(wmin), np.log10(wmax), nmodes) else: w = np.logspace(np.log10(wmin), np.log10(wmin), nmodes) self.parameters["logwmax"].opt_type = OptType.const G = np.abs( np.interp(w, self.parent_dataset.files[0].data_table.data[:, 0], self.parent_dataset.files[0].data_table.data[:, 1])) for i in range(self.parameters["nmodes"].value): self.parameters["logG%02d" % i] = Parameter( "logG%02d" % i, np.log10(G[i]), "Log of Mode %d amplitude" % i, ParameterType.real, opt_type=OptType.opt, min_value=-10, max_value=10) # GRAPHIC MODES self.graphicmodes = [] self.artistmodes = [] self.setup_graphic_modes()
def __init__(self, name="", parent_dataset=None, ax=None): """**Constructor**""" super().__init__(name, parent_dataset, ax) self.function = self.powerlaw self.parameters["a"] = Parameter( "a", 1.0, "Prefactor", ParameterType.real, opt_type=OptType.opt) self.parameters["b"] = Parameter( "b", 1.0, "Exponent", ParameterType.real, opt_type=OptType.opt) self.Qprint("%s: a*x^b" % self.thname)
def __init__(self, name="", parent_dataset=None, axarr=None): """**Constructor**""" super().__init__(name, parent_dataset, axarr) self.function = self.calculate_PomPom self.has_modes = True self.parameters["nmodes"] = Parameter( name="nmodes", value=2, description="Number of modes", type=ParameterType.integer, opt_type=OptType.const, display_flag=False, ) for i in range(self.parameters["nmodes"].value): self.parameters["G%02d" % i] = Parameter( name="G%02d" % i, value=1000.0, description="Modulus of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0, ) self.parameters["tauB%02d" % i] = Parameter( name="tauB%02d" % i, value=10.0, description="Backbone relaxation time of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0, ) self.parameters["q%02d" % i] = Parameter( name="q%02d" % i, value=1, description="Number of dangling arms of mode %02d" % i, type=ParameterType.integer, opt_type=OptType.opt, min_value=1, max_value=100, ) self.parameters["ratio%02d" % i] = Parameter( name="ratio%02d" % i, value=2, description= "Ratio of orientation to stretch relaxation times of mode %02d" % i, type=ParameterType.real, opt_type=OptType.const, min_value=1, max_value=5, ) self.MAX_MODES = 40 self.init_flow_mode()
def set_param_value(self, name, value): """Set the value of theory parameters""" if name == "nmodes": oldn = self.parameters["nmodes"].value message, success = super(BaseTheoryPomPom, self).set_param_value(name, value) if not success: return message, success if name == "nmodes": for i in range(self.parameters["nmodes"].value): self.parameters["G%02d" % i] = Parameter( name="G%02d" % i, value=1000.0, description="Modulus of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0, ) self.parameters["tauB%02d" % i] = Parameter( name="tauB%02d" % i, value=10.0, description="Backbone relaxation time of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0, ) self.parameters["q%02d" % i] = Parameter( name="q%02d" % i, value=1, description="Number of dangling arms of mode %02d" % i, type=ParameterType.integer, opt_type=OptType.opt, min_value=1, max_value=100, ) self.parameters["ratio%02d" % i] = Parameter( name="ratio%02d" % i, value=2, description= "Ratio of orientation to stretch relaxation times of mode %02d" % i, type=ParameterType.real, opt_type=OptType.const, min_value=1, max_value=5, ) if oldn > self.parameters["nmodes"].value: for i in range(self.parameters["nmodes"].value, oldn): del self.parameters["G%02d" % i] del self.parameters["tauB%02d" % i] del self.parameters["ratio%02d" % i] del self.parameters["q%02d" % i] return "", True
def __init__(self, name="", parent_dataset=None, axarr=None): """**Constructor**""" super().__init__(name, parent_dataset, axarr) self.reactname = "MultiMetCSTR %d" % ( rch.MMCSTR_global.mulmetCSTRnumber) rch.MMCSTR_global.mulmetCSTRnumber += 1 self.function = self.Calc self.simexists = False self.dist_exists = False self.ndist = 0 self.has_modes = False # True if the theory has modes self.autocalculate = False self.do_priority_seniority = False self.parameters["num_to_make"] = Parameter( name="num_to_make", value=1000, description="Number of molecules made in the simulation", type=ParameterType.real, opt_type=OptType.const, ) self.parameters["mon_mass"] = Parameter( name="mon_mass", value=28, description= "Mass, in a.m.u., of a monomer (usually set to 28 for PE)", type=ParameterType.real, opt_type=OptType.const, ) self.parameters["Me"] = Parameter( name="Me", value=1000, description="Entanglement molecular weight", type=ParameterType.real, opt_type=OptType.const, ) self.parameters["nbin"] = Parameter( name="nbin", value=50, description="Number of molecular weight bins", type=ParameterType.real, opt_type=OptType.const, ) self.NUMCAT_MAX = 30 # default parameters value self.init_param_values() self.signal_request_dist.connect(rgt.request_more_dist) self.signal_request_polymer.connect(rgt.request_more_polymer) self.signal_request_arm.connect(rgt.request_more_arm) self.signal_mulmet_dialog.connect(rgt.launch_mulmet_dialog) self.do_xrange("", visible=self.xrange.get_visible())
def __init__(self, name="", parent_dataset=None, ax=None): """**Constructor**""" super().__init__(name, parent_dataset, ax) self.function = self.exponential self.parameters["a"] = Parameter( "a", 1.0, "Prefactor", ParameterType.real, opt_type=OptType.opt) self.parameters["T"] = Parameter( "T", 1.0, "Exponential time constant", ParameterType.real, opt_type=OptType.opt) self.Qprint("%s: a*exp(-x/T)" % self.thname)
def __init__(self, name="", parent_app=None): """**Constructor**""" super().__init__(name, parent_app) self.parameters["x"] = Parameter( name="x", value="x", description="Expression for abscissa", type=ParameterType.string, ) self.parameters["y"] = Parameter( name="y", value="y", description="Expression for ordinate", type=ParameterType.string, ) safe_list = [ "sin", "cos", "tan", "arccos", "arcsin", "arctan", "arctan2", "deg2rad", "rad2deg", "sinh", "cosh", "tanh", "arcsinh", "arccosh", "arctanh", "around", "round_", "rint", "floor", "ceil", "trunc", "exp", "log", "log10", "fabs", "mod", "e", "pi", "power", "sqrt", ] self.safe_dict = {} for k in safe_list: self.safe_dict[k] = globals().get(k, None)
def __init__(self, name="", parent_dataset=None, axarr=None): """**Constructor**""" super().__init__(name, parent_dataset, axarr) self.function = self.calculate # main theory function self.has_modes = False # True if the theory has modes self.autocalculate = False self.parameters["Ge"] = Parameter( name="Ge", value=10605.97, description="Entanglement modulus", type=ParameterType.real, opt_type=OptType.opt, min_value=1, max_value=1e8, ) self.parameters["tau_s"] = Parameter( name="tau_s", value=0.01435800, description="sticker time", type=ParameterType.real, opt_type=OptType.opt, min_value=1e-5, max_value=1e2, ) self.parameters["Zs"] = Parameter( name="Zs", value=4.022881, description="Number of stickers per chain", type=ParameterType.real, opt_type=OptType.opt, min_value=0, max_value=100, ) self.parameters["Ze"] = Parameter( name="Ze", value=10.49686, description="Number of entanglements", type=ParameterType.real, opt_type=OptType.opt, min_value=0, max_value=100, ) self.parameters["alpha"] = Parameter( name="alpha", value=10, description="CLF parameter", type=ParameterType.real, opt_type=OptType.const, )
def set_param_value(self, name, value): """Change a parameter value, in particular *n* """ if name == 'n': nold = self.parameters["n"].value Aold = np.zeros(nold) for i in range(nold): Aold[i] = self.parameters["A%d" % i].value del self.parameters["A%d" % i] nnew = value message, success = super().set_param_value("n", nnew) for i in range(nnew): if i < nold: Aval = Aold[i] else: Aval = 1.0 self.parameters["A%d" % i] = Parameter( "A%d" % i, Aval, "Parameter %d" % i, ParameterType.real, opt_type=OptType.opt) else: message, success = super().set_param_value(name, value) if self.autocalculate: self.parent_dataset.handle_actionCalculate_Theory() self.update_parameter_table() return message, success
def set_equally_spaced_bins(self): """Find the first active file in the dataset and setup the bins""" for f in self.theory_files(): ft = f.data_table.data m_arr = ft[:, 0] w_arr = ft[:, 1] try: mmin = min(m_arr[np.nonzero(w_arr)]) mmax = max(m_arr[np.nonzero(w_arr)]) except: mmin = m_arr[0] mmax = m_arr[-1] self.parameters["logmmin"].value = np.log10(mmin) self.parameters["logmmax"].value = np.log10(mmax) nbin = self.parameters["nbin"].value bins_edges = np.logspace(np.log10(mmin), np.log10(mmax), nbin + 1) for i in range(nbin + 1): self.parameters["logM%02d" % i] = Parameter( "logM%02d" % i, np.log10(bins_edges[i]), "Log of molecular mass", ParameterType.real, opt_type=OptType.const, display_flag=False, ) self.current_file = f
def __init__(self, name="", parent_dataset=None, axarr=None): """**Constructor**""" super().__init__(name, parent_dataset, axarr) self.function = self.Calc self.simexists = False self.calc_exists = False self.has_modes = False # True if the theory has modes self.parameters["nbin"] = Parameter( name="nbin", value=100, description="Number of molecular weight bins", type=ParameterType.real, opt_type=OptType.const, ) self.reactname = "ReactMix" self.dists = [] # index of the react_dist array used in mix self.weights = [] # weight of the dist self.n_inmix = 0 # number of theories in mix self.theory_names = [] # names of theories in mix self.theory_simnumber = [ ] # 'react_dist[].simnumber' of theories in mix self.calcexists = False self.do_priority_seniority = False self.signal_mix_dialog.connect(rgt.launch_mix_dialog) self.ratios = [] # list of ratios in dialog self.include = [] # list of (0 or 1) include in dialog
def handle_spinboxValueChanged(self, value): """Handle a change of the parameter 'nmode'""" nmodesold = self.parameters["nmodes"].value wminold = self.parameters["logwmin"].value wmaxold = self.parameters["logwmax"].value wold = np.logspace(wminold, wmaxold, nmodesold) Gold = np.zeros(nmodesold) for i in range(nmodesold): Gold[i] = self.parameters["logDe%02d" % i].value del self.parameters["logDe%02d" % i] nmodesnew = value self.set_param_value("nmodes", nmodesnew) wnew = np.logspace(wminold, wmaxold, nmodesnew) Gnew = np.interp(wnew, wold, Gold) for i in range(nmodesnew): self.parameters["logDe%02d" % i] = Parameter( "logDe%02d" % i, Gnew[i], "Log of Mode %d amplitude" % i, ParameterType.real, opt_type=OptType.opt, ) if self.autocalculate: self.parent_dataset.handle_actionCalculate_Theory() self.update_parameter_table()
def __init__(self, name="", parent_dataset=None, axarr=None): """**Constructor**""" super().__init__(name, parent_dataset, axarr) self.reactname = "CreatePolyconf" self.function = self.calculate # main theory function self.has_modes = False # True if the theory has modes self.signal_param_dialog.connect(self.launch_param_dialog) self.parameters["nbin"] = Parameter( name="nbin", value=50, description="Number of molecular weight bins", type=ParameterType.integer, opt_type=OptType.const, min_value=1, ) self.polyconf_file_out = None # full path of target polyconf file self.autocalculate = False self.bch = BobCtypesHelper(self) self.do_priority_seniority = False self.inp_counter = 0 # counter for the 'virtual' input file for BoB self.virtual_input_file = [] # 'virtual' input file for BoB self.proto_counter = 0 # counter for the 'virtual' proto file for BoB self.virtual_proto_file = [] # 'virtual' proto file for BoB self.from_file_filename = [] # file names of the "from file" type self.from_file_filename_counter = 0 # counter self.protoname = [] # list of proto/polycode names
def __init__(self, name="", parent_dataset=None, axarr=None): """**Constructor**""" super().__init__(name, parent_dataset, axarr) self.function = self.calculate_giesekus self.has_modes = True self.parameters["nmodes"] = Parameter(name="nmodes", value=2, description="Number of modes", type=ParameterType.integer, opt_type=OptType.const, display_flag=False) self.parameters["nstretch"] = Parameter( name="nstretch", value=2, description="Number of strecthing modes", type=ParameterType.integer, opt_type=OptType.const, display_flag=False) for i in range(self.parameters["nmodes"].value): self.parameters["G%02d" % i] = Parameter( name="G%02d" % i, value=1000.0, description="Modulus of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0) self.parameters["tauD%02d" % i] = Parameter( name="tauD%02d" % i, value=10.0, description="Terminal time of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0) self.parameters["alpha%02d" % i] = Parameter( name="alpha%02d" % i, value=0.5, description="Dimensionless mobility factor of mode %02d" % i, type=ParameterType.real, opt_type=OptType.opt, min_value=0, max_value=1) self.MAX_MODES = 40 self.init_flow_mode()
def __init__(self, name="", parent_app=None): """**Constructor**""" super().__init__(name, parent_app) self.parameters["window"] = Parameter( name="window", value=11, description= "Length of filter window. Positive odd integer, smaller than the size of y and larger than order", type=ParameterType.integer, ) self.parameters["order"] = Parameter( name="order", value=3, description= "Order of smoothing polynomial (must be smaller than window)", type=ParameterType.integer, )
def set_param_value(self, name, value): """Set the value of a theory parameter""" if name == "nmodes": oldn = self.parameters["nmodes"].value if CmdBase.mode == CmdMode.GUI: self.spinbox.setMaximum(int(value)) message, success = super(BaseTheoryRoliePoly, self).set_param_value(name, value) if not success: return message, success if name == "nmodes": for i in range(self.parameters["nmodes"].value): self.parameters["G%02d" % i] = Parameter( name="G%02d" % i, value=1000.0, description="Modulus of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0, ) self.parameters["tauD%02d" % i] = Parameter( name="tauD%02d" % i, value=10.0, description="Terminal time of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0, ) self.parameters["tauR%02d" % i] = Parameter( name="tauR%02d" % i, value=0.5, description="Rouse time of mode %02d" % i, type=ParameterType.real, opt_type=OptType.opt, display_flag=True, min_value=0, ) if oldn > self.parameters["nmodes"].value: for i in range(self.parameters["nmodes"].value, oldn): del self.parameters["G%02d" % i] del self.parameters["tauD%02d" % i] del self.parameters["tauR%02d" % i] return "", True
def __init__(self, name="", parent_app=None): """**Constructor**""" super().__init__(name, parent_app) self.parameters["n"] = Parameter( name="n", value=1, description="Power law exponent", type=ParameterType.real, opt_type=OptType.const, )
def set_param_value(self, name, value): """Set value of a theory parameter""" if (name == "nmodes"): oldn = self.parameters["nmodes"].value if CmdBase.mode == CmdMode.GUI: self.spinbox.setMaximum(int(value)) message, success = super(BaseTheoryGiesekus, self).set_param_value(name, value) if not success: return message, success if (name == "nmodes"): for i in range(self.parameters["nmodes"].value): self.parameters["G%02d" % i] = Parameter( name="G%02d" % i, value=1000.0, description="Modulus of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0) self.parameters["tauD%02d" % i] = Parameter( name="tauD%02d" % i, value=10.0, description="Terminal time of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0) self.parameters["alpha%02d" % i] = Parameter( name="alpha%02d" % i, value=0.5, description="Constant of proportionality of mode %02d" % i, type=ParameterType.real, opt_type=OptType.opt, display_flag=True, min_value=0, max_value=1) if (oldn > self.parameters["nmodes"].value): for i in range(self.parameters["nmodes"].value, oldn): del self.parameters["G%02d" % i] del self.parameters["tauD%02d" % i] del self.parameters["alpha%02d" % i] return '', True
def __init__(self, name="", parent_dataset=None, axarr=None): """**Constructor**""" super().__init__(name, parent_dataset, axarr) self.function = self.calculate self.has_modes = False # self.parameters["logwmin"] = Parameter( # "logwmin", # -5, # "Log of frequency range minimum", # ParameterType.real, # opt_type=OptType.nopt) # self.parameters["logwmax"] = Parameter( # "logwmax", # 4, # "Log of frequency range maximum", # ParameterType.real, # opt_type=OptType.nopt) self.parameters["G0"] = Parameter( "G0", 1e6, "Modulus c*kB*T/N", ParameterType.real, opt_type=OptType.opt, min_value=0, ) self.parameters["tau0"] = Parameter( "tau0", 1e-3, "Segment relaxation time", ParameterType.real, opt_type=OptType.opt, min_value=0, ) self.parameters["M0"] = Parameter( "M0", 0.2, "Segment molar mass", ParameterType.real, opt_type=OptType.opt, min_value=0, )
def __init__(self, name="", parent_dataset=None, ax=None): """**Constructor**""" super().__init__(name, parent_dataset, ax) self.function = self.two_exponentials self.parameters["a1"] = Parameter( "a1", 0.9, "Prefactor 1", ParameterType.real, opt_type=OptType.opt) self.parameters["T1"] = Parameter( "T1", 1.0, "Exponential time constant 1", ParameterType.real, opt_type=OptType.opt) self.parameters["a2"] = Parameter( "a2", 0.1, "Prefactor 2", ParameterType.real, opt_type=OptType.opt) self.parameters["T2"] = Parameter( "T2", 10.0, "Exponential time constant 2", ParameterType.real, opt_type=OptType.opt) self.Qprint("%s: a1*exp(-x/T1) + a2*exp(-x/T2)" % self.thname)
def __init__(self, name="", parent_dataset=None, axarr=None): """**Constructor**""" super().__init__(name, parent_dataset, axarr) self.function = self.calculate_UCM self.has_modes = True self.parameters["nmodes"] = Parameter( name="nmodes", value=2, description="Number of modes", type=ParameterType.integer, opt_type=OptType.const, display_flag=False, ) for i in range(self.parameters["nmodes"].value): self.parameters["G%02d" % i] = Parameter( name="G%02d" % i, value=1000.0, description="Modulus of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0, ) self.parameters["tauD%02d" % i] = Parameter( name="tauD%02d" % i, value=10.0, description="Terminal time of mode %02d" % i, type=ParameterType.real, opt_type=OptType.nopt, display_flag=False, min_value=0, ) self.MAX_MODES = 40 self.init_flow_mode()
def set_param_value(self, name, value): """Change other parameters when nmodes is changed, else call parent function""" if name == 'nmodes': nmodesold = self.parameters["nmodes"].value wminold = self.parameters["logwmin"].value wmaxold = self.parameters["logwmax"].value wold = np.logspace(wminold, wmaxold, nmodesold) Gold = np.zeros(nmodesold) for i in range(nmodesold): Gold[i] = self.parameters["logG%02d" % i].value del self.parameters["logG%02d" % i] nmodesnew = int(value) message, success = super().set_param_value("nmodes", nmodesnew) if nmodesnew > 1 and nmodesold == 1: if wminold > wmaxold: wminold, wmaxold = wmaxold, wminold self.parameters["logwmax"].opt_type = OptType.opt if nmodesnew > 1: wnew = np.logspace(wminold, wmaxold, nmodesnew) Gnew = np.interp(wnew, wold, Gold) else: wnew = np.logspace(wminold, wminold, nmodesnew) Gnew = np.array([Gold[0]]) self.parameters["logwmax"].opt_type = OptType.const for i in range(nmodesnew): self.parameters["logG%02d" % i] = Parameter( "logG%02d" % i, Gnew[i], "Log of Mode %d amplitude" % i, ParameterType.real, opt_type=OptType.opt, min_value=-10, max_value=10) if CmdBase.mode == CmdMode.GUI: self.spinbox.blockSignals(True) self.spinbox.setValue(nmodesnew) self.spinbox.blockSignals(False) else: message, success = super().set_param_value(name, value) return message, success