Retour

Source de pst-rlcl.tex

Fichier TeX
\def\fileversion{0.23}
\def\filedate{2003/02/18}

\message{`PST-rlcl' v\fileversion, \filedate\space Manuel Luque)}

\csname PSTRlcl\endcsname
\let\PSTRlclLoaded\endinput

% Require PSTricks, pstplot and multido packages
\ifx\PSTplotLoaded\endinput\else\input pst-plot.tex\fi
% DPC interface to the `keyval' package (until keyval based version of PSTricks)
\ifx\PSTKeyLoaded\endinput\else\input pst-key.sty\fi
\ifx\PSTcolLoaded\endinput\else\input pstcol.sty\fi

\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{MonGris}{rgb}{0.8,0.8,0.8}
\definecolor{Vert}{cmyk}{1,0,1,0.4}
\definecolor{BleuClair}{cmyk}{0.1,0,0,0}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpsstyle{colorVert}{plotpoints=10000,linecolor=Vert}
\newpsstyle{colorBlue}{plotpoints=10000,linecolor=blue}
\newpsstyle{colorRed}{plotpoints=10000,linecolor=red}
\newpsstyle{colorscreen}{fillstyle=solid,fillcolor=MonGris}
\newpsstyle{colorcadre}{linestyle=none,fillstyle=solid,fillcolor=blue,framearc=0.05}
\newpsstyle{enveloppeJaune}{fillstyle=vlines,hatchcolor=yellow,hatchsep=1\pslinewidth,hatchangle=0,hatchwidth=0.1\pslinewidth}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% les composants
\define@key{psset}{L}{\edef\psk@pstRLC@Self{#1}}
\define@key{psset}{C}{\edef\psk@pstRLC@Capacitor{#1}}
\define@key{psset}{rb}{\edef\psk@pstRLC@ResistorBobine{#1}}
\define@key{psset}{rv}{\edef\psk@pstRLC@ResistorVariable{#1}}
\define@key{psset}{E}{\edef\psk@pstRLC@TensionInitiale{#1}}
%
% Les réglages de l'oscilloscope
% vitesse de balayage horizontal en ms
\define@key{psset}{balayage}{\edef\psk@pstRLC@Balayage{#1}}
% sensibilités verticales
\define@key{psset}{Y1}{%
\@namedef{psk@pstRLC@amplitude1}{#1}}
\define@key{psset}{Y2}{%
\@namedef{psk@pstRLC@amplitude2}{#1}}
% Mode XY
\newif\ifPst@pstRLC@XY
\define@key{psset}{XY}[false]{%
\@nameuse{Pst@pstRLC@XY#1}}
% représenter aussi r'i ?
\newif\ifPst@pstRLC@i
\define@key{psset}{i}[false]{%
\@nameuse{Pst@pstRLC@i#1}}
% Décaler verticalement les traces
\define@key{psset}{offsetY1}{%
\@namedef{psk@pstRLC@offsetY1}{#1}}
\define@key{psset}{offsetY2}{%
\@namedef{psk@pstRLC@offsetY2}{#1}}
% Inverser le signal (changer de signe)
\newif\ifPst@pstRLC@invertYA
\define@key{psset}{invertY1}[false]{%
\@nameuse{Pst@pstRLC@invertYA#1}}
\newif\ifPst@pstRLC@invertYB
\define@key{psset}{invertY2}[false]{%
\@nameuse{Pst@pstRLC@invertYB#1}}
% additionner les deux voies
\newif\ifPst@pstRLC@add
\define@key{psset}{add}[false]{%
\@nameuse{Pst@pstRLC@add#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Afficher les valeurs des composants
\newif\ifPst@pstRLC@datas
\define@key{psset}{datas}{%
\@nameuse{Pst@pstRLC@datas#1}}
% Afficher les réglages
\newif\ifPst@pstRLC@reglages
\define@key{psset}{reglages}{%
\@nameuse{Pst@pstRLC@reglages#1}}
% représenter la tension sinusoïdale
\newif\ifPst@pstRLC@sinus
\define@key{psset}{sinus}[false]{%
\@nameuse{Pst@pstRLC@sinus#1}}
% représenter l'enveloppe
\newif\ifPst@pstRLC@enveloppe
\define@key{psset}{enveloppe}[false]{%
\@nameuse{Pst@pstRLC@enveloppe#1}}
% le design de l'oscillo
\define@key{psset}{styleY1}{\edef\psk@pstRLC@Yone{#1}}
\define@key{psset}{styleY2}{\edef\psk@pstRLC@Ytwo{#1}}
\define@key{psset}{styleXY}{\edef\psk@pstRLC@XY{#1}}
\define@key{psset}{stylescreen}{\edef\psk@pstRLC@screen{#1}}
\define@key{psset}{styleenveloppe}{\edef\psk@pstRLC@enveloppe{#1}}
\define@key{psset}{stylecadre}{\edef\psk@pstRLC@cadre{#1}}
% les valeurs par défaut
\setkeys{psset}{styleY1=colorVert}
\setkeys{psset}{styleY2=colorBlue}
\setkeys{psset}{styleXY=colorRed}
\setkeys{psset}{stylescreen=colorscreen}
\setkeys{psset}{styleenveloppe=enveloppeJaune}
\setkeys{psset}{stylecadre=colorcadre}
% Les valeurs par défaut
\setkeys{psset}{Y1=2,Y2=2,%
    L=0.04,C=1e-6,E=5,balayage=1,%
    rb=10,rv=10,%
    offsetY1=0,offsetY2=0,%
    reglages=true,datas=true}

\SpecialCoor

\def\psRLC{\@ifnextchar[{\pst@psRLC}{\pst@psRLC[]}}

\def\pst@psRLC[#1]{{%
\setkeys{psset}{#1}
\pspicture(-5,-4.5)(5,4.5)
\pstVerb{% conditions initiales :
 /E \psk@pstRLC@TensionInitiale\space def % valeur de u à t=0
 /balayage \psk@pstRLC@Balayage\space def % en ms/cm
 /L \psk@pstRLC@Self\space def % en H
 /rb \psk@pstRLC@ResistorBobine\space def % en ohms
 /rv \psk@pstRLC@ResistorVariable\space def % en ohms
 /Rt rv rb add def % résistance totale
 /C \psk@pstRLC@Capacitor\space def % capacité en F
 /lambda Rt L 2 mul div def % amortissement
 /omega2 1 L C mul div def % pulsation propre^2
 /omega omega2 sqrt def
 /Rc 2 L C div sqrt mul def % résistance critique
 /T0 2 3.14159 mul omega div def % période propre
 /Y1 \@nameuse{psk@pstRLC@amplitude1}\space def % amplitude verticale en V/cm
 /Y2 \@nameuse{psk@pstRLC@amplitude2}\space def
 /offsetY1 \@nameuse{psk@pstRLC@offsetY1}\space def % décalage en V
 /offsetY2 \@nameuse{psk@pstRLC@offsetY2}\space def % décalage en V
 }
% dessin de l'écran de l'oscilloscope
\psframe[style=\psk@pstRLC@cadre](-5.1,-4.5)(5.1,4.5)
\psframe[style=\psk@pstRLC@screen](-5,-4)(5,4)
\psgrid[gridlabels=0,subgriddiv=0,gridwidth=0.5\pslinewidth,subgridwidth=0.2\pslinewidth](-5,-4)(5,4)
\psline[linestyle=dotted](-5,2.5)(5,2.5)
\psline[linestyle=dotted](-5,-2.5)(5,-2.5)
\multido{\nxDiv=-5.0+0.2}{50}{%
\psline(\nxDiv,-.1)(\nxDiv,0.1)}
% ajout 29 janvier 2003
\multido{\nxDiv=-5.0+0.2}{50}{%
\psline(\nxDiv,-2.05)(\nxDiv,-1.95)}
\multido{\nxDiv=-5.0+0.2}{50}{%
\psline(\nxDiv,2.05)(\nxDiv,1.95)}
%
\multido{\nyDiv=-4.0+0.2}{40}{%
\psline(-.1,\nyDiv)(.1,\nyDiv)}
\ifPst@pstRLC@datas
    \rput(0,-4.3){\textcolor{white}{\texttt{Rv$=$\psk@pstRLC@ResistorVariable{}\,$\Omega$
    L$=$\psk@pstRLC@Self{}\,H C$=$\psk@pstRLC@Capacitor{}\,F}}}
  \else
    \rput(0,-4.3){\textcolor{white}{\texttt{PSTricks-Oscilloscope}}}
\fi
\ifPst@pstRLC@reglages
    \rput(0,4.2){\textcolor{white}{\texttt{CH1 : \@nameuse{psk@pstRLC@amplitude1}{}V/div
    CH2 : \@nameuse{psk@pstRLC@amplitude2}{}V/div time/div : \psk@pstRLC@Balayage{}ms/div}}}
\fi
\rput(-5,0){%
\psclip{\psframe[linestyle=none](0,-4)(10,4)}
% représentation de l'enveloppe
\ifPst@pstRLC@enveloppe
\pscustom[linestyle=dotted]{
\parametricplot[plotpoints=200]{0}{10}{
    /temps t balayage 1000 div mul def
    /tension E 2.71828 lambda temps mul neg exp mul
     Y1 div % sensibilité verticale
     def
     t tension}%
\gsave%
\parametricplot[plotpoints=200]{10}{0}{
    /temps t balayage 1000 div mul def
    /tension E 2.71828 lambda temps mul neg exp mul neg
     Y1 div % sensibilité verticale
     def
     t tension}%
\fill[style=\psk@pstRLC@enveloppe]%
    \grestore}%
\parametricplot[plotpoints=200,linestyle=dotted]{10}{0}{
    /temps t balayage 1000 div mul def
    /tension E 2.71828 lambda temps mul neg exp mul neg
     Y1 div % sensibilité verticale
     def
     t tension}%
\fi
% dessin de la tension sinusoïdale
\ifPst@pstRLC@sinus
\parametricplot[plotpoints=10000,linecolor=gray]{0}{10}{%
     /temps t balayage 1000 div mul def
     /tension E omega 180 mul 3.14159 div temps mul cos mul
     Y1 div % sensibilité verticale
     offsetY1 add % décalage
     def
     t tension}
\fi
\ifPst@pstRLC@XY
\parametricplot[style=\psk@pstRLC@XY]{0}{10}{%
    /temps t balayage 1000 div mul def
    Rt Rc lt {%
     /Omega omega2 lambda dup mul sub sqrt def
     /tension E 2.71828 lambda temps mul neg exp mul
     Omega temps mul 180 mul 3.14159 div cos
     lambda Omega div Omega temps mul 180 mul 3.14159 div sin mul add mul
     Y1 div % sensibilité verticale
     offsetY1 add % décalage
     def
     /intensity E C mul 2.71828 lambda temps mul neg exp mul
     Omega temps mul 180 mul 3.14159 div sin mul
     Omega lambda dup mul Omega div sub mul
     rv mul neg % voie inversée
     Y2 div % sensibilité verticale
     offsetY2 add % décalage
     def} if
      Rt Rc gt {%
     /Omega omega2 lambda dup mul sub neg sqrt def
% les coefficients pour le régime apériodique
     /r1 lambda neg Omega add def
     /r2 lambda neg Omega sub def
     /aa r2 E mul neg r1 r2 sub div def
     /bb r1 E mul r1 r2 sub div def
     /tension aa 2.71828 r1 temps mul exp mul
              bb 2.71828 r2 temps mul exp mul
              add
     Y1 div % sensibilité verticale
     offsetY1 add % décalage
     def
     /intensity aa r1 mul 2.71828 r1 temps mul exp mul
              bb r2 mul 2.71828 r2 temps mul exp mul
              add C mul rv mul
     Y2 div % sensibilité verticale
     offsetY2 add % décalage
     def } if
% le régime critique
      Rt Rc eq {%
      /tension E 2.71828 lambda temps mul neg exp mul
               lambda temps mul 1 add mul
               def
      Y1 div % sensibilité verticale
      offsetY1 add % décalage
      /intensity E C mul 2.71828 lambda temps mul neg exp mul
               lambda dup mul mul
      Y2 div neg % sensibilité verticale
      offsetY2 add % décalage
               def} if
      intensity 5 add tension
}
\else
\ifPst@pstRLC@add
\parametricplot[style=\psk@pstRLC@Yone]{0}{10}{%
    /temps t balayage 1000 div mul def
    Rt Rc lt {%
     /Omega omega2 lambda dup mul sub sqrt def
     /tension E 2.71828 lambda temps mul neg exp mul
     Omega temps mul 180 mul 3.14159 div cos
     lambda Omega div Omega temps mul 180 mul 3.14159 div sin mul add mul
     \ifPst@pstRLC@invertYA
        neg
     \fi
     def
     /intensity E C mul 2.71828 lambda temps mul neg exp mul
     Omega temps mul 180 mul 3.14159 div sin mul
     Omega lambda dup mul Omega div sub mul
     rv mul neg %
     \ifPst@pstRLC@invertYB
        neg
      \fi
     def } if
      Rt Rc gt {%
     /Omega omega2 lambda dup mul sub neg sqrt def
% les coefficients pour le régime apériodique
     /r1 lambda neg Omega add def
     /r2 lambda neg Omega sub def
     /aa r2 E mul neg r1 r2 sub div def
     /bb r1 E mul r1 r2 sub div def
     /tension aa 2.71828 r1 temps mul exp mul
              bb 2.71828 r2 temps mul exp mul
              add
     \ifPst@pstRLC@invertYA
        neg
      \fi
     def
     /intensity aa r1 mul 2.71828 r1 temps mul exp mul
              bb r2 mul 2.71828 r2 temps mul exp mul
              add C mul rv mul
     \ifPst@pstRLC@invertYB
        neg
      \fi
     def } if
% le régime critique
      Rt Rc eq {%
      /tension E 2.71828 lambda temps mul neg exp mul
               lambda temps mul 1 add mul
      \ifPst@pstRLC@invertYA
        neg
      \fi
      def
      /intensity E C mul 2.71828 lambda temps mul neg exp mul
               lambda dup mul mul neg
      \ifPst@pstRLC@invertYB
        neg
      \fi
      def } if
      t tension intensity add Y1 div
     }
\else
% Représentation de la tension aux bornes du condensateur sur Y1
\parametricplot[style=\psk@pstRLC@Yone]{0}{10}{%
    /temps t balayage 1000 div mul def
    Rt Rc lt {%
     /Omega omega2 lambda dup mul sub sqrt def
     /tension E 2.71828 lambda temps mul neg exp mul
     Omega temps mul 180 mul 3.14159 div cos
     lambda Omega div Omega temps mul 180 mul 3.14159 div sin mul add mul
    \ifPst@pstRLC@invertYA
        neg
    \fi
     Y1 div % sensibilité verticale
     offsetY1 add % décalage
     def } if
      Rt Rc gt {%
     /Omega omega2 lambda dup mul sub neg sqrt def
% les coefficients pour le régime apériodique
     /r1 lambda neg Omega add def
     /r2 lambda neg Omega sub def
     /aa r2 E mul neg r1 r2 sub div def
     /bb r1 E mul r1 r2 sub div def
     /tension aa 2.71828 r1 temps mul exp mul
              bb 2.71828 r2 temps mul exp mul
              add
     \ifPst@pstRLC@invertYA
        neg
     \fi
     Y1 div % sensibilité verticale
     offsetY1 add % décalage
     def } if
% le régime critique
      Rt Rc eq {%
      /tension E 2.71828 lambda temps mul neg exp mul
               lambda temps mul 1 add mul
      \ifPst@pstRLC@invertYA
        neg
      \fi
      Y1 div % sensibilité verticale
      offsetY1 add % décalage
      def} if
    t tension
}
%
\ifPst@pstRLC@i
\parametricplot[style=\psk@pstRLC@Ytwo]{0}{10}{%
    /temps t balayage 1000 div mul def
    Rt Rc lt {%
     /Omega omega2 lambda dup mul sub sqrt def
     /intensity E C mul 2.71828 lambda temps mul neg exp mul
     Omega temps mul 180 mul 3.14159 div sin mul
     Omega lambda dup mul Omega div sub mul
     rv mul
     \ifPst@pstRLC@invertYB
        neg % voie inversée
     \fi
     Y2 div % sensibilité verticale
     offsetY2 add % décalage
     def } if
      Rt Rc gt {%
     /Omega omega2 lambda dup mul sub neg sqrt def
% les coefficients pour le régime apériodique
     /r1 lambda neg Omega add def
     /r2 lambda neg Omega sub def
     /aa r2 E mul neg r1 r2 sub div def
     /bb r1 E mul r1 r2 sub div def
     /intensity aa r1 mul 2.71828 r1 temps mul exp mul
              bb r2 mul 2.71828 r2 temps mul exp mul
              add C mul rv mul
              neg
     \ifPst@pstRLC@invertYB
        neg % voie inversée
     \fi
     Y2 div % sensibilité verticale
     offsetY2 add % décalage
     def } if
% le régime critique
      Rt Rc eq {%
      /intensity E C mul 2.71828 lambda temps mul neg exp mul
               lambda dup mul mul
      Y2 div neg % sensibilité verticale
      \ifPst@pstRLC@invertYB
        neg % voie inversée
      \fi
      offsetY2 add % décalage
               def
      } if
    t intensity
}
\fi
\fi
\fi
\endpsclip}
\endpspicture}}
\catcode`\@=\PstAtCode\relax
\endinput