示例#1
0
def sourceFreeParallelEquivalentCircuit(R,
                                        C,
                                        L,
                                        find="v",
                                        printEq=True,
                                        **kwargs):
    """Works in radians, not degrees"""
    alpha = 1 / (2 * R * C)
    w0 = 1 / (L * C)**(1 / 2)
    s1 = -alpha + (alpha**2 - w0**2)**(1 / 2)
    s2 = -alpha - (alpha**2 - w0**2)**(1 / 2)

    eq = list()
    if alpha > w0:
        print("Overdamped")
        eq.append("Eq(v, A1*exp(s1*t) + A2*exp(s2*t))")
    if alpha == w0:  #C=4*L/R**2
        print("Critically Damped")
        eq.append("Eq(v, (A1 + A2*t)*exp(-alpha * t))")
    if alpha < w0:
        print("Underdamped")
        # wd = (w0**2 - alpha**2)**(1/2)
        # B1 = A1 + A2
        # B2 = j*(A1 - A2)
        eq.append("Eq(v, exp(-alpha*t) * (A1*cos(wd*t) + A2*sin(wd*t)))")

    kwargs.update({
        "wd": "(w0**2 - alpha**2)**(1/2)",
        "alpha": alpha,
        "w0": w0,
        "s1": s1,
        "s2": s2
    })

    return solveEqs(eq, find="i", printEq=printEq, **kwargs)
示例#2
0
def Value(find, printEq=False, **kwargs):
    """
    usage: 
        measured in Farads (F)
        inductor is an short circuit in DC
        current cannot change abrumptly in a capacitor

    variables: 
        v=voltage
        L=inductance (measured in Henry = Volt/Ampere)
        di=change in current
        t, t0, t1, dt=time, initial time, future time, change in time
        i, i0, di = current, initial current, change in current
        w=work (J)

    Equations:
        v = L * di/dt
        i = 1/L * integrate(v,(t,t0,t1)) + i0
        p = v * i
        p = L * di/dt * i
        w = 0.5 * L * i**2
    """
    eq = list()
    eq.append("Eq(v,L*di/dt)")
    eq.append("Eq(v,L*diff(i,t))")
    eq.append("Eq(i,1/L*integrate(v,(t,t0,t1))+i0)")
    eq.append("Eq(p,v*i)")
    eq.append("Eq(p, L*di/dt*i)")
    eq.append("Eq(w,0.5*L*i**2)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#3
0
def naturalResponse(find, printEq=True, **kwargs):
    """
    Source-Free

    The natural response of a circuit refers to the behavior (in terms of
    voltages and currents) of the circuit itself, with no external sources of
    excitation.

    i(0) = I0
    
    variables: 
            v_o, v1, v2, v3 = Open loop voltage gain, voltage in
            R2, R1 = resistors (view reference image)

            tau = The time constant; the time required for the response to
            decay to a factor of 1/e or 36.8 percent of its initial value.
    """
    eq = list()
    eq.append("Eq(tau, L_eq / R_eq")
    eq.append("Eq(w0, .5 * L * I0**2")
    eq.append("Eq(v_L + v_R, 0")
    eq.append("Eq(L * di/dt + R*i, 0")
    eq.append("Eq(L * diff(i,t) + R*i, 0")
    eq.append("Eq(i, I0*exp(-t/tau))")
    eq.append("Eq(v_R, i * R)")
    eq.append("Eq(v_R, I0 * R * exp(-2*t/tau))")
    eq.append("Eq(p, v_R * i)")
    eq.append("Eq(p, I0**2 * R * exp(-2*t/tau))")
    eq.append("Eq(w, integrate(p,(t,0,tf)))")
    eq.append("Eq(w,.5 * L * I0**2 * (1-exp(-2*t/tau)))")

    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#4
0
def naturalResponse(find, printEq=True, **kwargs):
    """
    Source-Free

    The natural response of a circuit refers to the behavior (in terms of
    voltages and currents) of the circuit itself, with no external sources of
    excitation.

    v(0) = V0
    
    variables: 
            v_o, v1, v2, v3 = Open loop voltage gain, voltage in
            R2, R1 = resistors (view reference image)

            tau = The time constant; the time required for the response to
            decay to a factor of 1/e or 36.8 percent of its initial value.
    """
    eq = list()
    eq.append("Eq(tau, R_eq * C_eq")
    eq.append("Eq(v, V0 * exp(-t / tau))")
    eq.append("Eq(i_R, v / R")
    eq.append("Eq(i_R, V0 * exp(-t / tau)/R)")
    eq.append("Eq(p, v * i_R")
    eq.append("Eq(p, V0**2 * exp(-2*t / tau)/R)")
    eq.append("Eq(w, integrate(p,(t,0,tf))")
    eq.append("Eq(w, integrate(V0**2 * exp(-2*t / tau) / R, (t,0,tf))")
    eq.append("Eq(w, .5 * C * V0**2 * (1 - exp(-2*t / tau)))")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#5
0
def projectileMotionEq(find=False,
                       angleUnitRadians=True,
                       printEq=False,
                       **kwargs):
    """variables: 
            x=position-along-x, y=position-along-y,
            alpha0=original trajectory angle,
            t=time, g=standard acceleration of gravity
            vx=velocity-along-x, vy=velocity-along-y
            
        Note:
            Angle solution in radians"""

    if not (angleUnitRadians):
        dictionary_add_modify(kwargs, alpha0=radians(kwargs["alpha0"]))
    if not ("g" in kwargs):
        dictionary_add_modify(kwargs, g=scipy.constants.g)

    posx = "v0*cos(alpha0)*t"
    posy = "v0*sin(alpha0)*t - 0.5*g*t**2"
    eq = list()
    eq.append(f"Eq(x,{posx})")
    eq.append(f"Eq(y,{posy})")
    eq.append(f"Eq(vx,diff({posx},t))")
    eq.append(f"Eq(vy,diff({posy},t))")
    eq.append(f"Eq(ax,diff({posx},t,t))")
    eq.append(f"Eq(ay,diff({posy},t,t))")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#6
0
def mach(find="Ma", printEqs=True, **kwargs):
    """
    Mach Number = Flow Speed / Sound Speed
    """

    eq = list()
    eq.append("Eq(Ma, U/a)")
    return solveEqs(eq, find=find, printEq=printEqs, **kwargs)
示例#7
0
def summer(find="v_o", printEq=False, **kwargs):
    """variables: 
                v_o, v1, v2, v3 = Open loop voltage gain, voltage in
                Rf, R3, R2, R1 = resistors (view reference image)
                """
    eq = list()
    eq.append("Eq(v_o,-(Rf/R1*v1 + Rf/R2*v2 + Rf/R3*v3))")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#8
0
def differenceAmplifier(find="v_o", printEq=False, **kwargs):
    """variables: 
                v_o, v1, v2, v3 = Open loop voltage gain, voltage in
                R2, R1 = resistors (view reference image)
                """
    eq = list()
    eq.append("Eq(v_o,R2/R1*(v2-v1)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#9
0
def momentumEq(find, printEq=False, **kwargs):
    """variables: 
                m=mass  v=velocity
        Usage: Energy Applied on an object
        Sample Units: Kg*m/s"""
    eq = list()
    eq.append("Eq(p,m*v)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#10
0
def YoungsModulusEq(find="Y", printEq=False, **kwargs):
    """variables: 
            Y=young's modulus of elasticity
            sigma=stress
            epsilon=strain
    """
    eq = list()
    eq.append("Eq(Y, sigma/epsilon)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#11
0
def Resistance(find, printEq=False, **kwargs):
    """variables: 
                R=resistance
                p=density
                l=length
                A=cross sectional area"""
    eq = list()
    eq.append("Eq(R,p*l/A)")    
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#12
0
def powerEq(find, printEq=False, **kwargs):
    """variables: 
                P=power  W=Work  t=time
                f=force  v=velocity
        Base Unit = Watts"""
    eq = list()
    eq.append("Eq(P, W/t)")
    eq.append("Eq(P, F*v)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#13
0
def orbitVelocity(find="v_orb", printEq=False, **kwargs):
    """variables:
            v_orb = gravitational potential energy
            G = 6.67e-11 N*m**2/kg**2
            m_planet=mass of planet being orbited
            r=distance from center of planet being orbited"""
    dictionary_add_modify(kwargs, G=6.67e-11)
    eq = list()
    eq.append("Eq(v,(G*m_planet/r)**(1/2))")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#14
0
def gravitationAttraction(find="F_g", printEq=False, **kwargs):
    """variables:
            F_g = force of attraction due to gravity
            G = 6.67e-11 N*m**2/kg**2
            m1, m2 = mass1, mass2
            r = distance between masses"""
    dictionary_add_modify(kwargs, G=6.67e-11)
    eq = list()
    eq.append("Eq(F_g,G*m1*m2/r**2)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#15
0
def invertingAmplifier(find="v_o", printEq=False, **kwargs):
    """Variables:
                v_o, v_in = Open loop voltage gain, voltage in
                R2, R1 = resistors (view reference image)

        Equation: v_o = -R2/R1 * v_in
    """
    eq = list()
    eq.append("Eq(v_o,-R2/R1*v_in)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#16
0
def NodalAnalysis(find="i", printEq=False, **kwargs):
    """variables: 
            i = current
            vh, vl = higher/lower voltage
            r = resistor
        usage:
            Current flows from a higher potential to a lower potential in a resistor"""
    eq = list()
    eq.append("Eq(i,(v_higher-v_lower)/r)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#17
0
def forceEq(find, printEq=False, **kwargs):
    """variables: 
                W=Work  F=force  p=momentum  t=time
                x, x0, x1 = distance, start, finish
        Usage: Energy Applied on an object"""
    eq = list()
    eq.append("Eq(F,m*a)")
    eq.append("Eq(F,k*x)")
    eq.append("Eq(F,p/t)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#18
0
def workEq(find, printEq=False, **kwargs):
    """variables: 
                W=Work  F=force
                x, x0, x1 = distance, start, finish
        Usage: Energy Applied on an object"""
    eq = list()
    eq.append("Eq(W, F*x)")
    eq.append("Eq(W,integrate(F,(x,x0,x1)))")
    eq.append("Eq(W, P*t)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#19
0
def gravitationalPotentialEnergy(find="U", printEq=False, **kwargs):
    """variables:
            U = gravitational potential energy
            G = 6.67e-11 N*m**2/kg**2
            m1, m2 = mass1, mass2
            r = distance between masses"""
    dictionary_add_modify(kwargs, G=6.67e-11)
    eq = list()
    eq.append("Eq(U,-G*m1*m2/r)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#20
0
def shearModulus(find="S", printEq=False, **kwargs):
    """variables: 
            S = shear modulus
            sigma_shear = shear stress
            dx = along shear force (parallel to surface)
            h = height of subject that is subject to shear forces
    """
    eq = list()
    eq.append("Eq(S, sigma_shear/(dx/h))")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#21
0
def strain(find="epsilon", printEqs=True, **kwargs):
    """
    Change in length per unit length

    Where:
        epsilon = strain
        l, l0 = length, original length
    """
    eq = list()
    eq.append("Eq(epsilon, (l-l0)/l0)")
    return solveEqs(eq, find=find, printEq=printEqs, **kwargs)
示例#22
0
def reynolds(find="Re", printEqs=True, **kwargs):
    """
    Reynolds Number = Inertia / Viscosity
    """

    eq = list()
    eq.append("Eq(Re, rho * U * L / mu)")
    return solveEqs(eq, find=find, printEq=printEqs, **kwargs)


# ref white pg 307
示例#23
0
def S_ut(find="S_ut", printEqs=True, **kwargs):
    """
    Ultimate tensile strength 

    Where:
        HB = Brinnel Hardness
    """
    eq = list()
    eq.append("Eq(S_ut, 500*HB +/- 30*HB)")  #psi; approx
    eq.append("Eq(S_ut,3.45*HB +/- 0.2*HB")  #MPa; approx
    return solveEqs(eq, find=find, printEq=printEqs, **kwargs)
示例#24
0
def S_ys(find="S_ys", printEqs=True, **kwargs):
    """
    Shear Yield Strength
    Breaking strength in torsion

    Where:
        S_ys = shear yield strength
    """
    eq = list()
    eq.append("Eq(S_ys, 0.577*Sy")  #Approximation
    return solveEqs(eq, find=find, printEq=printEqs, **kwargs)
示例#25
0
def Capacitance(find="C", printEq=False, **kwargs):
    """
    Usage: the ratio of the charge on one plate of a capacitor to the voltage difference between the two plates, measured in farads (F).

    Variables: 
                C = capacitance (1 Farads = 1 Coulomb/Volt)
                epsilon = permitivity of the dielectric material between plates
                A = surface area of each plate
                d = distance between plates"""
    eq = list()
    eq.append("Eq(C,epsilon*A/d)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#26
0
def sigma(find="sigma", printEqs=True, **kwargs):
    """
    Stress

    Where:
        sigma = stress
        P = load
        A0 = original cross-sectional area
    """
    eq = list()
    eq.append("Eq(sigma, P / A)")
    return solveEqs(eq, find=find, printEq=printEqs, **kwargs)
示例#27
0
def impulseEq(find, printEq=False, **kwargs):
    """variables: 
                J=impulse  
                p1,p2=initial,final momentum
                F=sum of all forces
                t,t0,t1 = time initial,final
        Usage: The change in momentum of a particle during a time interval
        Sample Units: Kg*m/s"""
    eq = list()
    eq.append("Eq(J,p2-p1)")
    eq.append("Eq(J,integrate(F,(t,t0,t1)))")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#28
0
def a_rad(printEq=False, **kwargs):
    """
    Usage: radial acceleration (direction is towards axis of rotation)

    Variables: 
        v_rad=radial velocity
        r = radius
        w = magnitude of angular velocity (w_z)"""
    find = "a_rad"
    eq = list()
    eq.append("Eq(a_rad, v_rad**2/r)")
    eq.append("Eq(a_rad, w**2*r)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)
示例#29
0
def U_R(find="U_R", printEqs=True, **kwargs):
    """
    Resilience
    Where:
        U0 = strain energy density per unit volume
        sigma = stress
        epsilon = strain
    """
    eq = list()
    eq.append(
        "Eq(U_R, integrate(sigma, (epsilon, 0, epsilon_el)))")  #Approximation
    eq.append("Eq(U_R, 0.5*S_y**2/E")  #Approximation
    return solveEqs(eq, find=find, printEq=printEqs, **kwargs)
示例#30
0
def kinematicsEq(find, printEq=False, **kwargs):
    """variables: 
                d=distance, d0=initial distance, 
                v=velocity, v0=initial velocity, 
                a=acceleration, 
                t=time"""
    eq = list()
    eq.append("Eq(d, v*t)")
    eq.append("Eq(v, v0 + a*t)")  #constant x-acceleration only
    eq.append("Eq(d, d0 + v0*t + 0.5*a*t**2)")  #constant x-acceleration only
    eq.append("Eq(d, d0 + v*t - 0.5*a*t**2)")
    eq.append("Eq(v**2, v0**2 + 2*a*d)")
    return solveEqs(eq, find, printEq=printEq, **kwargs)