actionneurs_prog.py

Created by famille-bvc

Created on January 19, 2026

3.46 KB


# NumWorks - Actionneurs electriques
# Version exam - application directe des formules
# ASCII only

from math import sqrt, pi

def ask(txt, default=None):
    s = input(txt)
    if s == "" and default is not None:
        return float(default)
    return float(s)

def rpm_to_omega(n):
    return 2*pi*n/60

# =========================
# MOTEUR ASYNCHRONE
# =========================
def mas():
    print("=== MAS (moteur asynchrone) ===")

    U = ask("U ligne-ligne (V) = ")
    I = ask("I ligne (A) = ")
    f = ask("f (Hz) = ")
    cosphi = ask("cos(phi) = ")
    N = ask("N rotor (tr/min) = ")

    # Poles
    mode = input("Donner P(paires) ou Ns ? (P/Ns) = ").strip()
    if mode == "P":
        P = ask("P (paires de poles) = ")
        Ns = 60*f/P
    else:
        Ns = ask("Ns (tr/min) = ")
        P = 60*f/Ns

    # Couplage
    couplage = input("Couplage etoile ou triangle ? (Y/D) = ").strip()

    # Resistance mesuree
    Rm = ask("R mesuree entre 2 phases (ohm) = ")

    if couplage == "Y":
        Rph = Rm/2
        Iph = I
    else:
        Rph = 1.5*Rm
        Iph = I/sqrt(3)

    # Losses
    Pjs = 3*Rph*(Iph**2)
    Pfer = ask("Pertes fer Pfer (W) = ", default="0")
    Pmec = ask("Pertes mecaniques Pmec (W) = ", default="0")

    # Powers
    Pa = sqrt(3)*U*I*cosphi
    Pem = Pa - Pjs - Pfer
    g = (Ns - N)/Ns
    Pjr = g*Pem
    Pu = Pa - Pjs - Pfer - Pjr - Pmec

    # Torque
    omega = rpm_to_omega(N)
    Tu = Pu/omega if omega != 0 else 0
    eta = Pu/Pa if Pa != 0 else 0

    print("\n--- RESULTATS MAS ---")
    print("P (paires) = ", P)
    print("Ns (tr/min) = ", Ns)
    print("g = ", g)
    print("Pa (W) = ", Pa)
    print("Pjs (W) = ", Pjs)
    print("Pem (W) = ", Pem)
    print("Pjr (W) = ", Pjr)
    print("Pu (W) = ", Pu)
    print("Tu (N.m) = ", Tu)
    print("eta = ", eta)
    print("---------------------\n")

# =========================
# MOTEUR COURANT CONTINU
# =========================
def mcc():
    print("=== MCC (moteur courant continu) ===")

    mode = input("Mode moteur ou generatrice ? (M/G) = ").strip()
    U = ask("U (V) = ")
    R = ask("R induit (ohm) = ")
    I = ask("I induit (A) = ")
    n = ask("n (tr/min) = ")

    omega = rpm_to_omega(n)

    know_k = input("Constante k connue ? (O/N) = ").strip()

    if know_k == "O":
        k = ask("k (SI) = ")
        E = k*omega
        Tem = k*I
    else:
        if mode == "M":
            E = U - R*I
        else:
            E = U + R*I
        Tem = ask("Tem (N.m) si donne sinon 0 = ", default="0")

    Pem = E*I
    Pj = R*(I**2)

    Pfer = ask("Pertes fer Pfer (W) = ", default="0")
    Pmec = ask("Pertes mecaniques Pmec (W) = ", default="0")
    Pe = ask("Puissance excitation Pe (W) = ", default="0")

    Pu = Pem - Pfer - Pmec

    if mode == "M":
        Pa = U*I + Pe
    else:
        Pa = Pem + Pfer + Pmec + Pe

    eta = Pu/Pa if Pa != 0 else 0

    print("\n--- RESULTATS MCC ---")
    print("omega (rad/s) = ", omega)
    print("E (V) = ", E)
    print("Pem (W) = ", Pem)
    print("Pj (W) = ", Pj)
    print("Pu (W) = ", Pu)
    print("Pa (W) = ", Pa)
    print("eta = ", eta)
    if Tem != 0:
        print("Tem (N.m) = ", Tem)
    print("---------------------\n")

# =========================
# MENU
# =========================
def main():
    while True:
        print("Choisir : 1=MAS  2=MCC  0=Quitter")
        c = input("> ").strip()
        if c == "1":
            mas()
        elif c == "2":
            mcc()
        elif c == "0":
            break

main()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.