def manyboth(): import sys try: del sys.modules['scripts.run.temp_sim'] except KeyError: pass from scripts.run.temp_sim import TempSim from random import uniform Decimal = D rnd_2_const = Decimal('-1e-5') repr_quant = Decimal("1.00000000000") tcs = [] kps = [] cs = [] hd1 = Decimal(6.8) hd2 = Decimal(0) try: while True: rnd = uniform(4, 7.5) cconst = Decimal(rnd) * rnd_2_const sim = TempSim(D('37.114'), 19, hd1, cconst) sim.quietiter(250000) temp1 = sim.current_temp tstart = sim.seconds sim.heat_duty = hd2 bump_steps = sim.iterate(250000) temp2 = sim.current_temp dt = temp2 - temp1 t63 = temp1 + dt * Decimal('0.63') if dt > 0: cmp = t63.__lt__ else: cmp = t63.__gt__ tend = next(i for i, t in bump_steps if cmp(t)) dPV = temp2 - temp1 dCO = hd2 - hd1 tc = tend - tstart kp = dPV / dCO tcs.append(tc) kps.append(kp) cs.append(sim.cool_rate) print("Const:", sim.cool_rate.quantize(repr_quant), "Ti:", int(tc), "Kp:", kp.quantize(repr_quant)) except KeyboardInterrupt: return list(zip(cs, tcs, kps))
def test_quiet_iter(self): """ @return: @rtype: """ for args in self.init_args: exp_sim = TempSim(*args, leak_const=0) test_sim = TempSim(*args, leak_const=0) step = exp_sim.step n = 10000 for _ in range(n): step() test_sim.quietiter(n) self.assertEqual(exp_sim, test_sim) # test quiet step while we're here step() test_sim.quietstep() self.assertEqual(exp_sim, test_sim) # repeat the same thing to ensure iterate works # on subsequent calls. for _ in range(n): step() test_sim.quietiter(n) self.assertEqual(exp_sim, test_sim) # test quiet step while we're here step() test_sim.quietstep() self.assertEqual(exp_sim, test_sim)