Ondes électriques amorties dans un coaxial

FondamentalDiaporama du micro-contenu (rafraichir la page si redimensionnée)

SimulationProgramme Python

1
à copier
1
# -*- coding: utf-8 -*-
2
"""
3
Coaxial
4
O. Thual, 21/08/2021
5
"""
6
7
#  clear all
8
for iglob in list(globals().keys()):
9
    if(iglob[0] != '_'):
10
        exec('del {}'.format(iglob))
11
# import libraries
12
import numpy as np
13
import matplotlib.pyplot as plt
14
import os
15
16
17
def inifig(xaxe=0,yaxe=0,xlab='x',ylab='y'):
18
    plt.figure(2)
19
    plt.axvline(xaxe)
20
    plt.axhline(yaxe)
21
    plt.xticks(fontsize=12)
22
    plt.yticks(fontsize=12)
23
    plt.xlabel(xlab,fontsize=16 )
24
    plt.ylabel(ylab,fontsize=16)
25
    
26
def zfi(x,le=2):
27
    miss=le-len(str(x))
28
    a='0'*miss+str(x)
29
    return a
30
31
def animation(name):
32
    acont=np.linspace(0,L,501);
33
    t=0; 
34
    dt=Time/Nt
35
    for i in range(0,Nt):
36
        title=name+" i="+zfi(i)
37
        titlefig=name
38
        print(title)
39
        fig=plt.figure(1,figsize=(7,4))
40
        plt.xlabel(r'$x$',fontsize=16 )
41
        plt.ylabel(r'Courant $I$',fontsize=16)
42
        plt.title(titlefig,fontsize=16)
43
        # signal
44
        t=dt*i;
45
        xicont=signal(acont,t)
46
        plt.plot(acont,xicont,color='black',linewidth=3)
47
        plt.xlim(0,L)
48
        plt.ylim(ymin,ymax)
49
        namei=name+zfi(i)+'.png';
50
        plt.grid(color='black', axis='y', linestyle='-', linewidth=1)        
51
        plt.grid(color='black', axis='x', linestyle='-', linewidth=1)        
52
        plt.savefig(namei)
53
        plt.show()
54
        plt.close()
55
    gifanim="Anim"+name+".gif"
56
    #os.system('/opt/local/bin/convert -set delay '+delay+' '+name+'* '+gifanim);
57
    os.system('/usr/local/bin/convert -set delay '+delay+' '+name+'* '+gifanim);
58
    if Flagrm: os.system('rm '+name+'*');   
59
60
def anistatio(name):
61
    acont=np.linspace(0,L,501);
62
    t=0; 
63
    dt=Time/Nt
64
    fig=plt.figure(1,figsize=(7,4))
65
    plt.xlabel(r'$x$',fontsize=16 )
66
    plt.ylabel(r'Déplacement $y$',fontsize=16)
67
    plt.xlim(0,L)
68
    plt.ylim(ymin,ymax)
69
    titlefig=name
70
    plt.title(titlefig,fontsize=16)
71
    title=name
72
    print(title)
73
    for i in range(0,Nt+1):
74
        # signal
75
        t=dt*i;
76
        xicont=signal(acont,t)
77
        plt.plot(acont,xicont,color='black',linewidth=1)
78
        namei=name+zfi(i)+'.png';
79
        plt.grid(color='black', axis='y', linestyle='-', linewidth=1)        
80
        plt.grid(color='black', axis='x', linestyle='-', linewidth=1)        
81
    xicont=signal(acont,t)
82
    plt.plot(acont,xicont,color='red',linewidth=3)
83
    plt.savefig(namei)
84
    plt.show()
85
86
87
def spirale(name):
88
    ti=np.linspace(0,Time,501);
89
    I=np.exp(-la*ti)*np.sin(-omega*ti)
90
    dIdt=-np.exp(-la*ti)*np.cos(-omega*ti)
91
    dt=Time/Nt
92
    fig=plt.figure(1,figsize=(7,7))
93
    plt.xlim(-1,1)
94
    plt.ylim(-1,1)
95
    titlefig=name
96
    plt.title(titlefig,fontsize=16)
97
    title=name
98
    print(title)
99
    plt.grid(color='black', axis='y', linestyle='-', linewidth=1)        
100
    plt.grid(color='black', axis='x', linestyle='-', linewidth=1)        
101
    plt.plot(I,dIdt,color='blue',linewidth=3)
102
    plt.savefig(name)
103
    plt.show()
104
105
106
# Main 
107
F=False; T=True
108
Flagrm=F; Redpoint=F
109
110
def pulse(a,d):
111
    al=0*a[a<-d]; ac=a[np.abs(a)<=d]; ar=0*a[a>d];
112
    k=np.pi/d; fc=.5*(1+np.cos(k*ac));
113
    f=np.concatenate((al,fc,ar))
114
    return f
115
116
def statio(a,d):
117
    k=np.pi/d; fc=.5*(1+np.cos(k*ac));
118
    f=np.cos
119
    return f
120
121
122
 # Progressive amortissement temporel
123
if F: 
124
    L=10; c=1; 
125
    Nt=30; 
126
    k=20*np.pi/L; la=0.3;
127
    omega=k*c; Time=7*2*np.pi/omega
128
    ymin=-1; ymax=1;
129
    delay="20"
130
    # signal 
131
    def signal(a,t):
132
        xi=np.sin(k*a-omega*t)*np.exp(-la*t)
133
        return xi
134
    nom="POM-amortissement-temporel"
135
    print(nom)
136
    animation(nom) 
137
138
139
 # Spirale
140
if F: 
141
    L=10; c=1; 
142
    Nt=30; 
143
    k=20*np.pi/L; la=0.3;
144
    omega=k*c; Time=7*2*np.pi/omega
145
    # signal 
146
    nom="POM-amortissement-en-un-point"
147
    print(nom)
148
    spirale(nom) 
149
150
 
151
152
 # Progressive amortissement spatial gauche
153
if F: 
154
    L=10; c=1; 
155
    Nt=20; 
156
    k=20*np.pi/L; la=0.1;
157
    omega=k*c; Time=2*np.pi/omega
158
    ymin=-1; ymax=1;
159
    delay="10"
160
    # signal 
161
    def signal(a,t):
162
        xi=np.sin(k*a+omega*t)*np.exp(-la*(L-a))
163
        return xi
164
    nom="POM-amortissement-spatial-gauche"
165
    print(nom)
166
    animation(nom)     
167
    
168
169
 # Progressive amortissement spatial droit
170
if F: 
171
    L=10; c=1; 
172
    Nt=20; 
173
    k=20*np.pi/L; la=0.1;
174
    omega=k*c; Time=2*np.pi/omega
175
    ymin=-1; ymax=1;
176
    delay="10"
177
    # signal 
178
    def signal(a,t):
179
        xi=np.sin(k*a-omega*t)*np.exp(-la*a)
180
        return xi
181
    nom="POM-amortissement-spatial-droit"
182
    print(nom)
183
    animation(nom)  
184
    
185
# Application numerique
186
if T:
187
    Ga=1.e-10;
188
    La=16.e-8;
189
    ro=2.e-8;
190
    g=1.e-11;
191
    c=1/np.sqrt(La*Ga); print("c/1.e8=",c/1.e8)
192
    mu=ro/(2*La); print("mu=",mu)
193
    nu=g/(2*Ga); print("nu=",nu)    
194
    
195
    
196
    
197
 
198