1from circuit import pycircuit
2
3FS = pycircuit.fs
4
5class Triode(pycircuit.tcParams):
6
7    comp_id = "tc"
8    comp_name = "single triode"
9
10    u0 = (-37, -14, 341, 341-(-14), 341-350)  #Un = 350
11
12    start_grid = (
13        (-40.0, 40.0, 2),
14        (-15.0, 15.0, 2),
15        )
16
17    ranges = ()
18
19    circuit = dict(
20        Gco = -0.2,
21        Gcf = 1e-5,
22        mu  = 100.0,
23        Ex  = 1.4,
24        Kg1 = 1060.0,
25        Kp  = 600.0,
26        Kvb = 300.0,
27
28        Ck  = 680e-9,
29
30        G1  = 1/68e3,   # 1/R1
31        G2  = 1/1e0,    # 1/R2
32        Gg  = 1/1e6,    # 1/Rg
33        Gk  = 1/2.7e3,  # 1/Rk
34        Ga  = 1/100e3,  # 1/Ra
35        Gl  = 1/4e6,    # 1/Rl
36
37        Un = 350,
38        )
39
40
41class CoupledTriode(pycircuit.ctcParams):
42
43    comp_id = "ct"
44    comp_name = "coupled triodes"
45
46    u0 = (-18, 0, 313, 214, 45, 35, 37)
47
48    start_grid = (
49        (-80.0, 80.0, 220),
50        (0.0, 10.0, 2*30),
51        (30.0, 350.0, 2*18),
52        )
53
54    @property
55    def operating_point(self):
56        return [2.2423, 266.95][:]
57
58    ranges = (
59        (-40,40),
60        (0,10),
61        (100,350),
62        )
63
64    def pre(a):
65        a[0] += a[1]
66        return a
67
68    def post(a, o):
69        o[1] -= a[1]
70        o[2] -= a[2]
71        return o
72
73    basegrid = (
74        (((331, 4), (4, 4), (10, 4)), pre, post),
75        #L(((351, 2), (4, 2), (10, 2)), pre, post),
76        (((331, 2), (10, 2), (10, 2)), pre, post, 1e-3),
77        (((331, 2), (20, 2), (40, 2)), pre, post, 1e-3),
78        )
79
80    circuit = dict(
81        Gco = -0.2,
82        Gcf = 1e-5,
83        mu  = 100.0,
84        Ex  = 1.4,
85        Kg1 = 1060.0,
86        Kp  = 600.0,
87        Kvb = 300.0,
88        Ck = 680e-9,
89        Ca = 22e-9,
90        Un = 350,
91        G1 = 1/68e3,
92        G2 = 1/1e0,
93        Gg = 1/1e6,
94        Gk = 1/2.7e3,
95        Ga = 1/100e3,
96        G3 = 1/470e3,
97        Gg2 = 1/1e6,
98        Gk2 = 1/10e3,
99        Ga2 = 1/100e3,
100        Gl = 1/4e6,
101        )
102
103
104class PhaseSplitter(pycircuit.psParams):
105
106    comp_id = "ps"
107    comp_name = "phasesplitter"
108
109    u0 = (-4.99999142644, -4.99999053336, 3.7459813383, 391.962467113,
110          3.57356994824, 0.0264493076678, 0.0264491824349, 0.0264496771595,
111          354.458081186)
112
113    start_grid = (
114        (-40.0, 40.0, 60),
115        (-36.0, 0.0, 4),
116        (20.0, 35.0, 4),
117        (0.07, 0.25, 3),
118        )
119
120    @property
121    def operating_point(self):
122        return [-30.5966, 30.4599, 0.1367][:]
123
124    ranges = (
125        (slice(-40,40,81j), 3),
126        (slice(-36.0,-1.0,30j), 3),
127        (slice(23.0,35.0,8j), 3),
128        (slice(0.07,0.26,2j), 2),
129        )
130
131    circuit = dict(
132        Gco = -0.2,
133        Gcf = 1e-5,
134        mu  = 100.0,
135        Ex  = 1.4,
136        Kg1 = 1060.0,
137        Kp  = 600.0,
138        Kvb = 300.0,
139        C1 = 100e-9,   # corrected from 100e-6
140        C2 = 100e-9,   # corrected from 100e-6
141        C3 = 100e-9,   # corrected from 100e-6
142        Un = 400,
143        G1 = 1/1e0,    # 1/R1
144        Gg1 = 1/1e6,   # 1/Rg1
145        Gg2 = 1/1e6,   # 1/Rg2
146        Gk = 1/470e0,  # 1/Rk
147        G2 = 1/10e3,   # 1/R2
148        G3 = 1/100e3,  # 1/R3
149        G4 = 1/22e3,   # 1/R4
150        G5 = 1/4.7e3,  # 1/R5
151        Ga1 = 1/82e3,  # 1/Ra1
152        Ga2 = 1/100e3, # 1/Ra2
153        Gl1 = 1/4e6,   # 1/Rl1
154        Gl2 = 1/4e6,   # 1/Rl2
155        )
156
157
158class PPGate(pycircuit.pagParams):
159
160    comp_id = "ppg"
161    comp_name = "poweramp gate"
162
163    u0 = (-49.011342155, -93.9168241966, -93.9168241966)
164
165    start_grid = (
166        (-200,200,41),
167        (-70,170,8),
168        )
169
170    @property
171    def operating_point(self):
172       return [311.045][:]
173
174    ranges = (
175        (slice(45,425,60j), 3),
176        (slice(95,445,60j), 3),
177        )
178
179    circuit = dict(
180        Gco = -0.2,
181        Gcf = 1e-5,
182        C1  = 22e-9,
183        G1  = 1/30e3,
184        Gb  = 1/220e3,
185        Gg  = 1/5e3,
186        Ub  = -48,
187        )
188
189
190class PPPlate(pycircuit.papParams):
191
192    comp_id = "ppp"
193    comp_name = "poweramp plate"
194
195    u0 = (-93.9168241966, 400.010411242, 400.010411241, 399.983840905, 399.983840905)
196
197    start_grid = (
198        (-200,200,41),
199        (-200,200,41),
200        (350.0,450.0,2),
201        )
202
203    @property
204    def operating_point(self):
205        return [427.582][:]
206
207    ranges = (
208        (slice(-287,185,110j), 3),
209        (slice(-265,-51,40j), 3),
210        (slice(302,428,10j), 3),
211        )
212
213    circuit = dict(
214        Kp = 48.0,
215        mu = 8.7,
216        Ex = 1.35,
217        Kg1 = 1460.0,
218        Kg2 = 4500.0,
219        Kvb = 12.0,
220        Un = 450,
221        C2 = 100e-6,
222        Gd = 1/500e0,
223        Ga = 1/1.7e3,
224        Gs = 1/1e3,
225        )
226
227
228################################################################
229# JCM800 Poweramp
230#
231
232class PhaseSplitter_JCM800(pycircuit.psParams):
233
234    comp_id = "ps_jcm800"
235    comp_name = "jcm800 phasesplitter"
236
237    u0 = (-4.99999142644, -4.99999053336, 3.7459813383, 391.962467113,
238          3.57356994824, 0.0264493076678, 0.0264491824349, 0.0264496771595,
239          354.458081186)
240
241    start_grid = (
242        (-70.0, 105.0, 60),
243        (-76.0, 45.0, 25),
244        (25.0, 35.0, 4),
245        (0.07, 0.25, 3),
246        )
247
248    @property
249    def operating_point(self):
250        return [-29.77995343, 29.64688073, 0.13308519][:]
251
252    ranges = (
253        (-105,60),
254        (-51.0,0.0),
255        (25.0,35.0),
256        (0.07,0.26),
257        )
258
259    def pre(a):
260        a[0] += a[1]
261        return a
262
263    def post(a, o):
264        o[2] -= a[1]
265        o[3] -= a[2]
266        o[4] -= a[3]
267        return o
268
269    basegrid = (
270        (((301,4), (2,2), (20,4), (2,2)), pre, post, 4e-5),
271        (((301,4), (2,2), (30,4), (2,2)), pre, post, 4e-5),
272        #L(((950,2), (2,2), (80,2), (2,2)), pre, post, 4e-5),
273        #L(((1100,2), (2,2), (100,2), (2,2)), pre, post, 4e-5),
274        (((600,2), (2,2), (30,2), (2,2)), pre, post, 1e-4),
275        (((700,2), (2,2), (50,2), (2,2)), pre, post, 1e-3),
276        (((700,2), (2,2), (50,2), (2,2)), pre, post, 1e-3),
277        )
278
279    circuit = dict(
280        # 12AX7 tube parameters
281        Gco = -0.2,
282        Gcf = 1e-5,
283        mu  = 100.0,
284        Ex  = 1.4,
285        Kg1 = 1060.0,
286        Kp  = 600.0,
287        Kvb = 300.0,
288        # other parameters
289        C1 = 22e-9,
290        C2 = 100e-9,
291        C3 = 100e-9,
292        Un = 390,
293        G1 = 1/1e0,    # ??
294        Gg1 = 1/1e6,
295        Gg2 = 1/1e6,
296        Gk = 1/470e0,
297        G2 = 1/10e3,
298        G3 = 1/100e3,
299        G4 = 1/22e3,
300        #G4 = 1/1.0,
301        G5 = 1/4.7e3,
302        Ga1 = 1/82e3,
303        Ga2 = 1/100e3,
304        Gl1 = 1/4e6,
305        Gl2 = 1/4e6,
306        )
307
308
309class PPGate_JCM800(pycircuit.pagParams):
310
311    comp_id = "ppg_jcm800"
312    comp_name = "jcm800 poweramp gate"
313
314    u0 = (-49.011342155, -93.9168241966, -93.9168241966)
315
316    start_grid = (
317        (-200,200,41),
318        (-70,170,8),
319        )
320
321    @property
322    def operating_point(self):
323       return [311.045][:]
324
325    ranges = (
326        (-40, 500),
327        (95, 445),
328        )
329
330    def pre_c1(a):
331        a[0] += a[1] - 311.045
332        return a
333
334    def post_c1(a, o):
335        o[1] -= a[1] - 311.045
336        return o
337
338    basegrid = (
339        #S(((120, 4), (2, 2)), pre_c1, None),
340        (((120, 2), (2, 2)), pre_c1, None),
341        (((120, 2), (2, 2)), pre_c1, post_c1, 1e-3),
342        )
343
344    circuit = dict(
345        Gco = -0.2,
346        Gcf = 1e-5,
347        C1  = 22e-9,
348        G1  = 1/30e3,  # ??
349        Gb  = 1/150e3,
350        Gg  = 1/5.6e3,
351        #Ub  = -57,
352        Ub  = -60,
353        )
354
355
356class PPPlate_JCM800(pycircuit.papParams):
357
358    comp_id = "ppp_jcm800"
359    comp_name = "jcm800 poweramp plate"
360
361    u0 = (-93.9168241966, 400.010411242, 400.010411241, 399.983840905, 399.983840905,
362          (-93.9168241966+400.010411241/2), (400.010411242+400.010411241/2))
363
364    start_grid = (
365        #(-290,200,16*41),
366        #(-290,200,4*41),
367        #(300.0,440.0,2*2),
368        (-200,200,41),
369        (-200,200,41),
370        (335.0,430.0,20),
371        )
372
373    @property
374    def operating_point(self):
375        return [427.582][:]
376
377    ranges = (
378        (-56.59-240,-56.59+210),
379        #(-265,-51),
380        (-56.59-240,-56.59+210),
381        (340,468),
382        )
383
384    #def pre_in1(a):
385    #    a[1] += a[0]
386    #    return a
387
388    def post(a, o):
389        o[1] -= a[2]
390        return o
391
392    # basegrid = (
393    #     (((110, 3), (110, 3), (10, 3)), None, None),
394    #     (((110, 3), (110, 3), (10, 3)), None, None, 1e-6),
395    #     #(((150, 4), (70, 4), (10, 4)), pre_in1, None),
396    #     #(((4, 2), (4, 2), (4, 2)), None, None),
397    #     )
398    basegrid = (
399        (((2*110, 4), (2*110, 4), (10, 4)), None, post, 1e-4),
400        #L(((270, 2), (270, 2), (20, 2)), None, post, 1e-4),
401        (((110, 2), (110, 2), (10, 2)), None, post, 1e-3),
402        #(((150, 4), (70, 4), (10, 4)), pre_in1, None),
403        #(((4, 2), (4, 2), (4, 2)), None, None),
404        )
405
406    circuit = dict(
407        # EL34 tube parameters
408        Kp = 60.0,
409        mu = 11.0,
410        Ex = 1.35,
411        Kg1 = 650.0,
412        Kg2 = 4200.0,
413        Kvb = 24.0,
414        #
415        Un = 468,
416        C2 = 100e-6,
417        Gd = 1/500e0,  # ??
418        Ga = 1/1.7e3,  # ??
419        Gs = 1/1.5e3,
420        )
421