eeeeeeee.py

Created by teivaetienne

Created on December 03, 2025

7.46 KB


from ion import *
from kandinsky import *
from time import *

# --- MOTEUR D'AFFICHAGE ---
def wrap(txt, width=31):
  # Decoupe le texte pour l'ecran
  lines = []
  for para in txt.split('\n'):
    while len(para) > width:
      # Coupe au dernier espace
      cut = para.rfind(' ', 0, width)
      if cut == -1: cut = width
      lines.append(para[:cut])
      para = para[cut:].strip()
    lines.append(para)
  return lines

def show(title, content):
  lines = wrap(content)
  scroll = 0
  # 12 lignes affichables a la fois
  max_lines = 11 
  
  while True:
    fill_rect(0, 0, 320, 222, (255, 255, 255))
    # Titre en haut (bleu)
    fill_rect(0, 0, 320, 20, (230, 230, 250))
    draw_string(title, 10, 0, (0,0,0), (230, 230, 250))
    
    # Affiche les lignes
    for i in range(max_lines + 1):
      idx = scroll + i
      if idx < len(lines):
        # Texte en noir
        draw_string(lines[idx], 2, 25 + i * 18)
    
    # Barre de defilement a droite
    if len(lines) > 0:
      pct = scroll / len(lines)
      h_bar = int(200 * (max_lines / len(lines)))
      y_bar = 25 + int(180 * pct)
      fill_rect(315, 25, 5, 190, (200,200,200))
      fill_rect(315, y_bar, 5, 10, (0,0,255))

    sleep(0.15) # Anti-rebond touches

    # Gestion Touches
    if keydown(KEY_DOWN):
      if scroll < len(lines) - max_lines:
        scroll += 1
    elif keydown(KEY_UP):
      if scroll > 0:
        scroll -= 1
    elif keydown(KEY_RIGHT): # Page suivante
      scroll = min(scroll + 10, len(lines) - max_lines)
    elif keydown(KEY_LEFT): # Page prec
      scroll = max(0, scroll - 10)
    elif keydown(KEY_BACK) or keydown(KEY_OK):
      break

# --- CONTENU DES COURS ---
# Je mets tout le texte ici dans des variables

TXT_THERMO_COURS = """-- COURBES (Diag PV) --
Axe Y=Pression / Axe X=Volume

1. ISOCHORE (V=cst):
- Droite VERTICALE
- W=0 (Surface nulle)
- ex: Chauffage recipient ferme

2. ISOBARE (P=cst):
- Droite HORIZONTALE
- W = Rectangle sous courbe
- ex: Piston libre a l'air

3. ISOTHERME (T=cst):
- Hyperbole (courbe douce)
- P = nRT/V
- La temperature ne change pas

4. ADIABATIQUE (Q=0):
- Hyperbole PENTE RAIDE
- Pente + forte que Isotherme
- PV^gamma = Cst
- ex: Compression rapide

-- CYCLES --
HORAIRE (Aiguilles montre):
-> MOTEUR (W < 0, fourni)
-> W = Aire interieure

ANTI-HORAIRE (Trigo):
-> RECEPTEUR (W > 0, recu)
-> Frigo ou PAC"""

TXT_THERMO_FORM = """-- GAZ PARFAITS --
PV = nRT
Unites: P(Pa), V(m3), T(Kelvin)
T(K) = T(C) + 273.15
1 bar = 10^5 Pa | 1 L = 10^-3 m3
R = 8.314 J/mol.K
M(Air)=29 g/mol | n=m/M

-- COEFFICIENTS --
Alpha = 1/V (dV/dT)p (Isobare)
Beta = 1/P (dP/dT)v (Isochore)
Khi_T = -1/V (dV/dP)T (Isoth)
Lien: Alpha = P . Beta . Khi_T

-- 1er PRINCIPE (Ferme) --
dU = W + Q
Loi Joule (GP): dU = n.Cv.dT
Mayer: Cp - Cv = R
Gamma(y) = Cp/Cv (>1)
Mono: y=1.67 | Di(Air): y=1.4
Cv = R/(y-1) | Cp = yR/(y-1)

-- CALCUL TRAVAIL (W) --
Isochore: W = 0
Isobare:  W = -P(V2-V1)
Isotherme:W = -nRT.ln(V2/V1)
Adiabat.: W = dU = n.Cv.dT
          W = (P2V2-P1V1)/(y-1)

-- LOIS LAPLACE (Adiaba) --
Seulement si Adiabatique Rev!
1. PV^y = Cst
2. TV^(y-1) = Cst
3. T^y . P^(1-y) = Cst

-- RENDEMENTS (e) --
Def: e = |Utile / Payee|
1. MOTEUR (W<0, Qc>0):
   e = -W / Qc = 1 + Qf/Qc
   (0 < e < 1)
2. FRIGO (W>0, Qf>0):
   COP = Qf / W (souvent > 1)
3. PAC (W>0, Qc<0):
   COP = -Qc / W
   Lien: COP_pac = COP_fr + 1"""

TXT_THERMO_METH = """-- METHODE EXO THERMO --
1. IDENTIFIER TRANSFORMATION
   - 'Volume constant' -> Isochore
   - 'Pression cst' -> Isobare
   - 'Temp cst' -> Isotherme
   - 'Calorifuge/Rapide' -> Adiabatique

2. CALCULER VARIABLES (P,V,T)
   - Utiliser PV=nRT a l'etat 1
   - Utiliser la loi de la transfo
     (ex: P1V1=P2V2 si Isotherme)
     (ex: P1/T1=P2/T2 si Isochore)

3. CALCULER ENERGIES
   - Calculer W (voir Formules)
   - Calculer dU = n.Cv.(T2-T1)
   - Deduire Q = dU - W
   (Sauf si Adia: Q=0, W=dU)"""

TXT_FLUIDE_COURS = """-- REGIMES ECOULEMENT --
Nombre Reynolds: Re = rho.v.D / mu
 ou Re = v.D / nu

1. LAMINAIRE (Re < 2000):
   - Filets paralleles, calme
   - Profil vitesse parabolique
   - Pertes charge lineaires

2. TURBULENT (Re > 3000):
   - Melange, tourbillons
   - Profil vitesse 'plat'
   - Pertes charge en V^2

-- VISCOSITE --
Dynamique (mu): Pa.s (ou Poiseuille)
Cinematique (nu): m2/s (ou Stokes)
Lien: nu = mu / rho"""

TXT_FLUIDE_FORM = """-- HYDROSTATIQUE (Repos) --
P_bas - P_haut = rho.g.h
P_abs = P_rel + P_atm
Force Paroi: F = Integrale(P.dS)
Mur rect (Lxh): F = 1/2.rho.g.L.h^2
Centre Poussee: a h/3 du fond
ARCHIMEDE: Pi = rho_fluide.V_imm.g
Pt appli: Centre carene (vol imm)

-- DYNAMIQUE (Mvt) --
Debit: Qv = S.v (m3/s)
Masse: Qm = rho.Qv (kg/s)
Continuite: S1.v1 = S2.v2

-- BERNOULLI (Energy) --
Hyp: Incomp, Parfait, Perm
P + rho.g.z + 0.5.rho.v^2 = Cst
Avec Pertes (J ou dP):
Charge_A = Charge_B + dP_AB
Charge_A + Pompe = Charge_B + dP

-- PERTES DE CHARGE --
dP_tot = dP_lin + dP_sing
LINEAIRES (Darcy):
   dP = lam . (L/D) . (0.5.rho.v^2)
   Si Laminaire: lam = 64/Re
   Si Turbulent: Blasius 0.316.Re^-0.25
SINGULIERES (Coudes, vannes):
   dP = K . (0.5.rho.v^2)
   (K donne ou abaque)

-- FORMULES SPECIALES --
Torricelli (Vidange): v = sqrt(2gh)
Pitot (Vitesse): v = sqrt(2dP/rho)
Venturi (Debit):
   Qv = S1.S2.sqrt(2dP/rho(S1^2-S2^2))
Euler (Force jet):
   F = Qm * (v_sortie - v_entree)"""

TXT_FLUIDE_METH = """-- METHODE BERNOULLI --
1. CHOIX DES POINTS A et B
   - Surface libre (P=Patm, v=0)
   - Sortie a l'air (P=Patm)

2. ECRIRE L'EQUATION
   Pa + rgzA + 0.5rvA^2 + Pomp
   = Pb + rgzB + 0.5rvB^2 + Pertes

3. SIMPLIFIER
   - Si A et B a l'air: Pa=Pb
   - Si grand reservoir: vA=0
   - Si tuyau horizontal: zA=zB

4. CALCULER PERTES
   - Calculer Re d'abord
   - Trouver lambda
   - Sommer les K"""

TXT_ECHANGE = """-- MODES TRANSFERT --
1. CONDUCTION (Solide, Fourier)
   Flux = dT / R_th
   R_mur = e / (lambda.S)
   R_tube = ln(Re/Ri)/(2pi.L.lam)
   Mur serie: R_eq = R1 + R2

2. CONVECTION (Fluide, Newton)
   Flux = h . S . (Tparoi - Tfluide)
   R_conv = 1 / (h . S)
   h depend vitesse, fluide...

-- ECHANGEURS --
CO-COURANT: Fluides meme sens
   - T sortie froid < T sortie chaud
   - Moins efficace
CONTRE-COURANT: Sens opposes
   - T sortie froid peut > T s ch
   - Plus efficace (DTLM + grand)

-- CALCULS ECHANGEUR --
1. BILAN PUISSANCE (Adiabatique)
   Phi = Qm_c.Cp_c.(Te_c - Ts_c)
       = Qm_f.Cp_f.(Ts_f - Te_f)
   (Permet de trouver une Temp)

2. DIMENSIONNEMENT (Surface)
   Phi = U . S . DTLM
   U = Coeff global (inverse des R)
   1/US = 1/hiSi + Rcond + 1/heSe

3. DTLM (Moyenne Log)
   DTLM = (dT1 - dT2) / ln(dT1/dT2)
   dT1 = Ecart T entree echangeur
   dT2 = Ecart T sortie echangeur
   /!\ Bien faire le schema sens!"""

# --- MENU PRINCIPAL ---
def menu():
  opts = [
    ("Thermo: Cours", TXT_THERMO_COURS),
    ("Thermo: Formules", TXT_THERMO_FORM),
    ("Thermo: Methode", TXT_THERMO_METH),
    ("Fluides: Cours", TXT_FLUIDE_COURS),
    ("Fluides: Formules", TXT_FLUIDE_FORM),
    ("Fluides: Methode", TXT_FLUIDE_METH),
    ("Echangeurs: Tout", TXT_ECHANGE)
  ]
  
  sel = 0
  while True:
    fill_rect(0,0,320,222, (255,255,255))
    draw_string("MENU REVISIONS", 100, 10, (0,0,0))
    
    for i, (titre, _) in enumerate(opts):
      col = (0,0,0)
      bg = (255,255,255)
      if i == sel:
        col = (255,255,255)
        bg = (0,0,0)
        fill_rect(10, 40+i*20, 300, 20, bg)
      draw_string(titre, 15, 40+i*20, col, bg)
      
    sleep(0.15)
    if keydown(KEY_DOWN): sel = (sel+1)%len(opts)
    elif keydown(KEY_UP): sel = (sel-1)%len(opts)
    elif keydown(KEY_OK) or keydown(KEY_EXE):
      show(opts[sel][0], opts[sel][1])

try:
  menu()
except:
  pass

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.