def write_table(ex,f_re): global inner inner+=ocd.table_groesse(g,var,ex+offsets,"g") inner+=ocd.table_groesse(b,var,ex+offsets,"b") inner+=ocd.table_groesse(f,var,ex+offsets,"e") inner+=ocd.table_groesse(f,var,ex+offsets,"f") inner+=ocd.table_groesse(beta,var,ex+offsets,ur"beta") f_r= ocd.eval_expr(f,var,ex+offsets,"f") f_mean=np.mean(f_r.x.magnitude) f_std=np.std(f_r.x.magnitude) inner+=ur"Mittelwert: %.3f\\"%f_mean inner+=ur"Standartabweichung: %.3f\\" % np.std(f_r.x.magnitude) inner+=ur"gemessene Brechkraft: $\phi=\frac{1}{f}=%.3f +- %.3f\\ $"% ((1/f_mean),f_std/f_mean**2) inner+=ur"theoretische Brechkraft: %.3f\\ "% (1/f_re)
import ocd Werte=ocd.open_csv("versuch80/tabelle2.csv") s_unten=sy.Symbol("s_unten") s_oben=sy.Symbol("s_oben") r_unten=sy.Symbol("r_unten") r_oben=sy.Symbol("r_oben") I=sy.Symbol("I") U=sy.Symbol("U") alpha_offset=sy.Symbol("alpha_offset") alpha=sy.Symbol("alpha") B=0.78*10**(-3)*I import scipy.constants as c wz=c.e/c.m_e*B/(2*sy.pi) test=ocd.eval_expr(wz,[s_unten,s_oben,r_oben,I,U,alpha_offset,alpha],Werte,"test") print str(test)
import ocd import sympy as sy Werte=ocd.open_csv("versuch80/tabelle2.csv") s_unten=sy.Symbol("s_unten") s_oben=sy.Symbol("s_oben") r_unten=sy.Symbol("r_unten") r_oben=sy.Symbol("r_oben") I=sy.Symbol("I") U=sy.Symbol("U") alpha_offset=sy.Symbol("alpha_offset") alpha=sy.Symbol("alpha") var=[s_unten,s_oben,r_oben,I,U,alpha_offset,alpha] do = lambda expr,name: ocd.eval_expr(expr,var,Werte,name) plot = lambda expr1,expr2: ocd.plot_var(expr1,expr2,var,Werte) B=0.78*10**(-3)*I import scipy.constants as c wz=c.e/c.m_e*B/(2*sy.pi) d=r_oben-r_unten s=s_oben-s_unten y=s/(sy.pi*d) alpha2=alpha-alpha_offset x=sy.tan(alpha2) plot(s_oben,s_unten)
ocd.plot_var(f,phi,var,messung23) f_ = np.linspace(0,300000,1000) plt.plot(f_,theo_delta(f_,14.39)) plt.plot(f_,theo_delta(f_,3.33)) plt.plot(f_,theo_delta(f_,6.57)) plt.ylim(0,np.pi) plt.xlim(-0.1E5,3.1E5) plt.title(ur"Phasenverschiebung des getriebenen, gedämpften Oszillators") plt.xlabel("Frequenz in Hz") plt.ylabel("Phasenverschiebung in Radianten") plt.show() v_ = ocd.Groesse("v","dimensionless",np.array([3.33]),np.array([0.3])) w0_ = ocd.Groesse("w0","Hz",np.array([939E3]),np.array([3E3])) L_ = ocd.Groesse("L","H",np.array([953E-6]),np.array([0])) v = sy.Symbol("v") w0 = sy.Symbol("w0") L = sy.Symbol("L") (R_, expr, Sexpr)=ocd.eval_expr(L*w0/v,[v,w0,L],[v_,w0_,L_],"R") print "R=",R_ R = sy.Symbol("R") var = [R,L,w0] werte = [R_,L_,w0_] (f_, expr, Sexpr) = ocd.eval_expr(sy.sqrt(w0**2-R**2/(4*L**2))/(2*sy.pi),var,werte,"f") print f_ sy.pprint(Sexpr)
import sympy as sy import ocd Werte=ocd.open_csv("tables/table1.csv") t=sy.Symbol("t") s1=sy.Symbol("s1") s2=sy.Symbol("s2") q=sy.Symbol("q") f=(s1/t + s2/t )*q*sy.cos((s2/s1)) test=ocd.eval_expr(f,[t,s1,s2,q],Werte,"test") print str(test)
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt import numpy as np import sympy as sy import ocd Werte=[ocd.Groesse("l1","cm",np.array([4.62]),np.array([0.02])),ocd.Groesse("l2","cm",np.array([5.44]),np.array([0.05])),ocd.Groesse("l","cm",np.array([10]),np.array([0])),ocd.Groesse("Cb","F",np.array([48.5+107])*10**-9,np.array([0]))] Werte2=[ocd.Groesse("l1","cm",np.array([6.95]),np.array([0.01])),ocd.Groesse("l2","cm",np.array([3.06]),np.array([0.02])),ocd.Groesse("l","cm",np.array([10]),np.array([0])),ocd.Groesse("Lb","H",np.array([4])*10**-3,np.array([0]))] l1=sy.Symbol("l1") l2=sy.Symbol("l2") l=sy.Symbol("l") Cb=sy.Symbol("Cb") Lb=sy.Symbol("Lb") Cx1=Cb*(l-l2)/l2 Cx2=Cb*l1/(l-l1) Lx1=Lb*(l1)/(l-l1) Lx2=Lb*(l-l2)/(l2) (g,e,f)=ocd.eval_expr(Cx1,[l1,l2,l,Cb],Werte,"Cx") (g,e,f)=ocd.eval_expr(Cx2,[l1,l2,l,Cb],Werte,"Cx") (g,e,f)=ocd.eval_expr(Lx1,[l1,l2,l,Lb],Werte2,"Lx") print g sy.pprint(f) (g,e,f)=ocd.eval_expr(Lx2,[l1,l2,l,Lb],Werte2,"Lx") print g sy.pprint(f)
inner+=ur"Experiment III 1.\\ " B=sy.Symbol("B") B_orginal=sy.Symbol("B_orginal") b__=sy.Symbol("b__") b_=e_-b__+xs-xk var+=[B,b__] beta=B/B_orginal inner+=ocd.table_groesse(b_,var,ex4+offsets,ur"b'") inner+=ocd.table_groesse(b_,var,ex5+offsets,ur"b'") inner+=ocd.table_groesse(beta,var,ex4+offsets,ur"beta") inner+=ocd.table_groesse(beta,var,ex5+offsets,ur"beta") plt.figure() (a,b,Sa,Sb,Sy)=ocd.plot_var(b_,beta,var,ex4+offsets,True) (a,b,Sa,Sb,Sy)=ocd.plot_var(b_,beta,var,ex5+offsets,True) plt.xlim(0,0.9) plt.ylim(0,7) plt.xlabel(ur"b' in m ") plt.ylabel(ur"$\beta$") plt.title(ur"gemessene Brechkraft: $\phi=(%.3f \pm %.3f) \frac{1}{m}$ theoretische Brechkraft: $\phi=%.3f \frac{1}{m}$"%(b,(Sb),(1/0.11429))) plt.show() f1=sy.Symbol("f1") fges=sy.Symbol("fges") d=sy.Symbol("d") f2=fges*(f1-d)/(f1-fges) container=[ocd.Groesse("f1","m",np.array([0.08]),np.array([0])),ocd.Groesse("d","m",np.array([0.02]),np.array([0.001])),ocd.Groesse("fges","m",np.array([0.119]),np.array([0.001]))] print ocd.eval_expr(f2,[f1,fges,d],container,"f2") #ocd.write_tex(inner)