Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def eval_U(formula, U):
- for f in formula:
- f.replace('U', str(U))
- if formula.size == 2:
- return [eval(formula[1]), eval(formula[2])]
- else:
- return eval(formula)
- def calc_I(U):
- rng = {0:"0.5 * U", 2:"0", 4:"U - 2", 8:"4"}
- formula = []
- for i in rng.keys:
- if U < i:
- formula.push_back(rng.pop(i))
- return formula
- if U == i:
- formula.push_back(rng.pop(i))
- return "0"
- t = []
- s = []
- for i in arange(-8.0, 8.0, 0.1):
- U = eval_U(calc_I(i))
- if U.size > 1:
- t.push_back(i)
- t.push_back(i)
- s.push_back(U[0])
- s.push_back(U[1])
- else:
- t.push_back(i)
- s.push_back(U[0])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement