def objective(x1, x2, x3, x4): return (-20 * exp(-0.02 * sqrt(1.0 / 4.0 * (x1**2 + x2**2 + x3**2 + x4**2))) - exp(1.0 / 4.0 * (cos(2 * math.pi * x1) + cos(2 * math.pi * x2) + cos(2 * math.pi * x3) + cos(2 * math.pi * x4))) + math.e + 20)
def test_functions_with_expression(self): self.assertEqual(str(abs(e_x)), "abs(x)") self.assertEqual(str(exp(e_x)), "exp(x)") self.assertEqual(str(sqrt(e_x)), "sqrt(x)") self.assertEqual(str(pow(e_x, e_y)), "pow(x, y)") self.assertEqual(str(sin(e_x)), "sin(x)") self.assertEqual(str(cos(e_x)), "cos(x)") self.assertEqual(str(tan(e_x)), "tan(x)") self.assertEqual(str(asin(e_x)), "asin(x)") self.assertEqual(str(acos(e_x)), "acos(x)") self.assertEqual(str(atan(e_x)), "atan(x)") self.assertEqual(str(atan2(e_x, e_y)), "atan2(x, y)") self.assertEqual(str(sinh(e_x)), "sinh(x)") self.assertEqual(str(cosh(e_x)), "cosh(x)") self.assertEqual(str(tanh(e_x)), "tanh(x)") self.assertEqual(str(min(e_x, e_y)), "min(x, y)") self.assertEqual(str(max(e_x, e_y)), "max(x, y)") self.assertEqual(str(if_then_else(e_x > e_y, e_x, e_y)), "(if (x > y) then x else y)")
def test_functions_with_variable(self): self.assertEqual(str(abs(x)), "abs(x)") self.assertEqual(str(exp(x)), "exp(x)") self.assertEqual(str(sqrt(x)), "sqrt(x)") self.assertEqual(str(pow(x, y)), "pow(x, y)") self.assertEqual(str(sin(x)), "sin(x)") self.assertEqual(str(cos(x)), "cos(x)") self.assertEqual(str(tan(x)), "tan(x)") self.assertEqual(str(asin(x)), "asin(x)") self.assertEqual(str(acos(x)), "acos(x)") self.assertEqual(str(atan(x)), "atan(x)") self.assertEqual(str(atan2(x, y)), "atan2(x, y)") self.assertEqual(str(sinh(x)), "sinh(x)") self.assertEqual(str(cosh(x)), "cosh(x)") self.assertEqual(str(tanh(x)), "tanh(x)") self.assertEqual(str(min(x, y)), "min(x, y)") self.assertEqual(str(max(x, y)), "max(x, y)") self.assertEqual(str(if_then_else(x > y, x, y)), "(if (x > y) then x else y)")
def test_functions_with_float(self): v_x = 1.0 v_y = 1.0 self.assertEqual(abs(v_x), math.fabs(v_x)) self.assertEqual(exp(v_x), math.exp(v_x)) self.assertEqual(sqrt(v_x), math.sqrt(v_x)) self.assertEqual(pow(v_x, v_y), v_x**v_y) self.assertEqual(sin(v_x), math.sin(v_x)) self.assertEqual(cos(v_x), math.cos(v_x)) self.assertEqual(tan(v_x), math.tan(v_x)) self.assertEqual(asin(v_x), math.asin(v_x)) self.assertEqual(acos(v_x), math.acos(v_x)) self.assertEqual(atan(v_x), math.atan(v_x)) self.assertEqual(atan2(v_x, v_y), math.atan2(v_x, v_y)) self.assertEqual(sinh(v_x), math.sinh(v_x)) self.assertEqual(cosh(v_x), math.cosh(v_x)) self.assertEqual(tanh(v_x), math.tanh(v_x)) self.assertEqual(min(v_x, v_y), min(v_x, v_y)) self.assertEqual(max(v_x, v_y), max(v_x, v_y)) self.assertEqual( if_then_else(Expression(v_x) > Expression(v_y), v_x, v_y), v_x if v_x > v_y else v_y)
def mvs_id(fetType, Vs, Vg, Vd, I, shape): params = model_params(fetType) version = params['version'] mType = params['mType'] W = params['W'] Lgdr = params['Lgdr'] dLg = params['dLg'] Cg = params['Cg'] etov = params['etov'] delta = params['delta'] n0 = params['n0'] Rs0 = params['Rs0'] Rd0 = params['Rd0'] Cif = params['Cif'] Cof = params['Cof'] vxo = params['vxo'] * 1e7 mu = params['mu'] beta = params['beta'] Tjun = params['Tjun'] phib = params['phib'] gamma = params['gamma'] Vt0 = params['Vt0'] alpha = params['alpha'] mc = params['mc'] CTM_select = params['CTM_select'] CC = params['CC'] nd = params['nd'] zeta = params['zeta'] # SMALL_VALUE SMALL_VALUE = 1e-10 # LARGE_VALUE LARGE_VALUE = 40 if mType == 1.0: Vb = 0.0 Vdsi = Variable("Vdsin") Vgsi = Variable("Vgsin") Vbsi = Variable("Vbsin") n = Variable("nn") nphit = Variable("nphitn") phibVbs = Variable("phibVbsn") Vtpcorr = Variable("Vtpcorrn") eVgpre = Variable("eVgpren") FFpre = Variable("FFpren") ab = Variable("abn") Vcorr = Variable("Vcorrn") Vgscorr = Variable("Vgscorrn") Vbscorr = Variable("Vbscorrn") phibVbscorr = Variable("phibVbscorrn") Vt0bs = Variable("Vt0bsn") phibVbsi = Variable("phibVbsin") Vt0bs0 = Variable("Vt0bs0n") Vtp = Variable("Vtpn") Vtp0 = Variable("Vtp0n") eVg = Variable("eVgn") FF = Variable("FFn") eVg0 = Variable("eVg0n") FF0 = Variable("FF0n") Qref = Variable("Qrefn") eta = Variable("etan") Qinv_corr = Variable("Qinv_corrn") Vdsat = Variable("Vdsatn") VdsiVdsat = Variable("VdsiVdsatn") powVal = Variable("powValn") Fsat = Variable("Fsatn") else: Vb = 1.8 Vdsi = Variable("Vdsip") Vgsi = Variable("Vgsip") Vbsi = Variable("Vbsip") n = Variable("np") nphit = Variable("nphitp") phibVbs = Variable("phibVbsp") Vtpcorr = Variable("Vtpcorrp") eVgpre = Variable("eVgprep") FFpre = Variable("FFprep") ab = Variable("abp") Vcorr = Variable("Vcorrp") Vgscorr = Variable("Vgscorrp") Vbscorr = Variable("Vbscorrp") phibVbscorr = Variable("phibVbscorrp") Vt0bs = Variable("Vt0bsp") phibVbsi = Variable("phibVbsip") Vt0bs0 = Variable("Vt0bs0p") Vtp = Variable("Vtpp") Vtp0 = Variable("Vtp0p") eVg = Variable("eVgp") FF = Variable("FFp") eVg0 = Variable("eVg0p") FF0 = Variable("FF0p") Qref = Variable("Qrefp") eta = Variable("etap") Qinv_corr = Variable("Qinv_corrp") Vdsat = Variable("Vdsatp") VdsiVdsat = Variable("VdsiVdsatp") powVal = Variable("powValp") Fsat = Variable("Fsatp") constraints = [] if mType == 1: constraints.append( logical_or(logical_and(Vs <= Vd, Vdsi == mType * (Vd - Vs)), logical_and(Vs > Vd, Vdsi == mType * (Vs - Vd)))) constraints.append( logical_or(logical_and(Vs <= Vd, Vgsi == mType * (Vg - Vs)), logical_and(Vs > Vd, Vgsi == mType * (Vg - Vd)))) constraints.append( logical_or(logical_and(Vs <= Vd, Vbsi == mType * (Vb - Vs)), logical_and(Vs > Vd, Vbsi == mType * (Vb - Vd)))) else: constraints.append( logical_or(logical_and(Vd <= Vs, Vdsi == mType * (Vd - Vs)), logical_and(Vd > Vs, Vdsi == mType * (Vs - Vd)))) constraints.append( logical_or(logical_and(Vd <= Vs, Vgsi == mType * (Vg - Vs)), logical_and(Vd > Vs, Vgsi == mType * (Vg - Vd)))) constraints.append( logical_or(logical_and(Vd <= Vs, Vbsi == mType * (Vb - Vs)), logical_and(Vd > Vs, Vbsi == mType * (Vb - Vd)))) Cofs = 0 * (0.345e-12 / etov) * dLg / 2.0 + Cof # s-terminal outer fringing cap [F/cm] Cofd = 0 * (0.345e-12 / etov) * dLg / 2.0 + Cof # d-terminal outer fringing cap [F/cm] Leff = Lgdr - dLg # Effective channel length [cm]. After subtracting overlap lengths on s and d side kB = 8.617e-5 # Boltzmann constant [eV/K] phit = kB * Tjun # Thermal voltage, kT/q [V] me = (9.1e-31) * mc # Carrier mass [Kg] constraints.append(n == n0 + nd * Vdsi) constraints.append(nphit == n * phit) aphit = alpha * phit constraints.append(phibVbs == dabs(phib - Vbsi)) constraints.append(Vtpcorr == Vt0 + gamma * (sqrt(phibVbs) - sqrt(phib)) - Vdsi * delta) constraints.append(eVgpre == exp((Vgsi - Vtpcorr) / (aphit * 1.5))) constraints.append(FFpre == 1.0 / (1.0 + eVgpre)) constraints.append(ab == 2 * (1 - 0.99 * FFpre) * phit) constraints.append(Vcorr == (1.0 + 2.0 * delta) * (ab / 2.0) * (exp(-Vdsi / ab))) constraints.append(Vgscorr == Vgsi + Vcorr) constraints.append(Vbscorr == Vbsi + Vcorr) constraints.append(phibVbscorr == dabs(phib - Vbscorr)) constraints.append(Vt0bs == Vt0 + gamma * (sqrt(phibVbscorr) - sqrt(phib))) constraints.append(phibVbsi == dabs(phib - Vbsi)) constraints.append(Vt0bs0 == Vt0 + gamma * (sqrt(phibVbsi) - sqrt(phib))) constraints.append(Vtp == Vt0bs - Vdsi * delta - 0.5 * aphit) constraints.append(Vtp0 == Vt0bs0 - Vdsi * delta - 0.5 * aphit) constraints.append(eVg == exp((Vgscorr - Vtp) / (aphit))) constraints.append(FF == 1.0 / (1.0 + eVg)) constraints.append(eVg0 == exp((Vgsi - Vtp0) / (aphit))) constraints.append(Qref == Cg * nphit) constraints.append(eta == (Vgscorr - (Vt0bs - Vdsi * delta - FF * aphit)) / (nphit)) constraints.append(Qinv_corr == Qref * log(1.0 + exp(eta))) vx0 = vxo Vdsats = vx0 * Leff / mu constraints.append(Vdsat == Vdsats * (1.0 - FF) + phit * FF) constraints.append(VdsiVdsat == Vdsi / Vdsat) constraints.append(powVal == pow(VdsiVdsat, beta)) constraints.append(Fsat == VdsiVdsat / (pow((1 + powVal), (1.0 / beta)))) if mType == 1: constraints.append( logical_or( logical_and(Vs <= Vd, I == Qinv_corr * vx0 * Fsat * W * mType * shape), logical_and( Vs > Vd, I == Qinv_corr * vx0 * Fsat * W * mType * -1.0 * shape))) else: constraints.append( logical_or( logical_and(Vd <= Vs, I == Qinv_corr * vx0 * Fsat * W * mType * shape), logical_and( Vd > Vs, I == Qinv_corr * vx0 * Fsat * W * mType * -1.0 * shape))) return constraints
def objective(x, y): return (-20 * exp(-0.02 * sqrt(0.5 * (x**2 + y**2))) - exp(0.5 * (cos(2 * math.pi * x) + cos(2 * math.pi * y))) + math.e + 20)
def objective(x, y): return -abs( sin(x) * cos(y) * exp(abs(1 - sqrt(x**2 + y**2) / math.pi)))
def objective(x1, x2): return -(x2 + 47) * sin(sqrt(abs(x2 + x1 / 2.0 + 47))) - x1 * sin( sqrt(abs(x1 - (x2 + 47))))
def objective(x, y): return -0.0001 * (abs( sin(x) * sin(y) * exp(abs(100 - sqrt(x**2 + y**2) / math.pi))) + 1)**0.1
def objective(x, y): return 100 * sqrt(abs(y - 0.01 * x**2)) + 0.01 * abs(x + 10)