-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver.cpp
More file actions
755 lines (704 loc) · 22.2 KB
/
Copy pathdriver.cpp
File metadata and controls
755 lines (704 loc) · 22.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
/*
* KFilter6
* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright (C) 2002-2026 Martin Erdtmann
*/
/*
* Historical note:
*
* This file contains code derived from the original KFilter calculation core,
* which started as Turbo Pascal code developed on an 8088-based PC. Some of the
* structure still reflects performance optimizations that were necessary on
* that hardware, including many explicit special-case branches.
*
* The remaining German comments are also a historical artifact of the original
* code base. They were written during the early development of KFilter and have
* intentionally not been translated mechanically, because some of them may
* capture implementation details or domain-specific reasoning that should be
* reviewed carefully during refactoring.
*
* These optimizations improved runtime performance in the original version, but
* reduce readability today. The intended long-term direction is to refactor this
* code into clearer and more maintainable calculation modules while preserving
* the established numerical behaviour.
*/
#include "driver.h"
#include "kfilterfrequencygrid.h"
#include <cmath>
driver::driver()
{
resetToDefaults();
}
driver::~driver()
{
}
void driver::resetToDefaults()
{
Rdc=5.1;
Lsp=0.00017;
F0=307;
Qts=1.14;
Qms=1.9;
Qes=2.87;
Vas=10;
Dm=7.3;
gain = 1.0;
plotState_ = {};
phaseInverted=false;
show_reflex_only=false;
Vb=0;
V2=0;
Fb=0;
Ql=10;
pistonLowPassInductance=0;
pistonLowPassCapacitance=0;
pistonLowPassQ=0;
pistonLowPassFrequency=0;
enclosureTypeProposal = EnclosureType::OpenBaffle;
pistonLowPassActive=false;
fullCircuitFlag=false;
network = {};
m_qstringTitle = "This is a default driver";
calculateParameters();
setModified();
}
void driver::setModified(void)
{
dirty_pressure = true;
dirty_impedance = true;
}
void driver::calculateParameters(void)
{
double pi = 3.141592654;
sealedHighPassLossConductance = 1.0;
sealedLeakageConductance = 0.0;
if (F0!=0)
{
if (Dm==0)
{
Dm=10;
}
// Full-circuit ideal-piston model: this normalized capacitance models
// the driver's radiation resistance. The simplified model uses the
// separate 0 dB-normalized pistonLowPassInductance/pistonLowPassCapacitance approximation instead.
radiationCapacitance=1/(2*pi*34000/Dm);
motionalResistance=Qms*Rdc/Qes;
motionalCapacitance=Qes/(2*pi*Rdc*F0);
motionalInductance=Rdc/(2*pi*Qes*F0);
//************************************************************************************************
//double ii;
//for (int i=99; i>-1; i--)
//{
// ii=i;
// Cline[i]=StrahlC;
// Lline[i]=1/(pow((2*pi*50*(ii+1)/100),2.0)*Cline[i]);
// Rline[i]= 2*pi*50*(ii+1)/100*Lline[i]/2.0;
//}
//************************************************************************************************
if ((Vb==0)||(enclosureTypeProposal==EnclosureType::OpenBaffle))
{
acousticHighPassCapacitance=Qts/(2*pi*F0);
acousticHighPassInductance=1/(Qts*2*pi*F0);
enclosureType=EnclosureType::OpenBaffle;
}
else
{
const double sealedComplianceRatio = Vas/Vb+1;
acousticHighPassCapacitance=Qts/(2*pi*F0);
acousticHighPassInductance=1/(2*pi*F0*Qts*sealedComplianceRatio);
enclosureType=EnclosureType::Sealed;
//}
if ((Fb!=0)&&(static_cast<int>(enclosureTypeProposal)>=static_cast<int>(EnclosureType::Vented)))
{
enclosureType=EnclosureType::Vented;
enclosureBranchInductance=Vb*motionalInductance/Vas;
enclosureBranchCapacitance=1/( enclosureBranchInductance*pow((2*pi*Fb),2.0) );
enclosureBranchResistance=(2*pi*Fb*enclosureBranchInductance/Ql); // Legacy source questioned an alternative formula here: sqrt(C/L)/Ql; ?
ventedDenominatorA0=pow((Fb/F0),2.0);
ventedDenominatorA1=ventedDenominatorA0/Qts + Fb/(Ql*F0);
ventedDenominatorA2=1 + ventedDenominatorA0 + Fb/(Ql*F0*Qts) + Vas/Vb;
ventedDenominatorA3=1/Qts + Fb/(Ql*F0);
if ((V2!=0)&&(static_cast<int>(enclosureTypeProposal)>=static_cast<int>(EnclosureType::Bandpass)))
{
enclosureType=EnclosureType::Bandpass;
// Preserve the historical recalculation before applying the V2
// modification to the motional branch.
enclosureBranchInductance=Vb*motionalInductance/Vas;
motionalInductance=1/(1/motionalInductance+Vas/(V2*motionalInductance));
}
}
else // -> Fb ist jetzt gleich Null s.o.
{
enclosureType=EnclosureType::Sealed;
sealedEffectiveMotionalInductance=1/(1/motionalInductance+Vas/(Vb*motionalInductance));
const double idealSealedQuality = Qts*sqrt(sealedComplianceRatio);
sealedHighPassLossConductance=1+idealSealedQuality/Ql;
sealedLeakageConductance=sqrt(motionalCapacitance/sealedEffectiveMotionalInductance)/Ql;
}
} //Vb==0
}
//if f0 != 0
// Historical 0 dB-normalized approximation of the natural upper roll-off
// of an ideal piston radiator. pistonLowPassQ/pistonLowPassFrequency currently have no
// productive setter/UI path; keep the model dormant until the original
// parameter derivation has been reconstructed.
if ((pistonLowPassQ!=0) && (pistonLowPassFrequency!=0))
{
pistonLowPassInductance = 1/(2*pi*pistonLowPassQ*pistonLowPassFrequency);
pistonLowPassCapacitance = pistonLowPassQ/(2*pi*pistonLowPassFrequency);
pistonLowPassActive = true;
}
else
{
pistonLowPassActive = false;
}
// Preserve the historical full-circuit normalization exactly. The calibration
// gain is numerically about +22 dB; its original absolute reference is unknown.
fullCircuitNormalizationFactor=sqrt(8/Rdc)*LegacyFullCircuitCalibrationGain * sqrt(2.0); //{/sqrt(1 + 1/Qms )}
}
void driver::calculatePressureResponse(void)
{
if (dirty_pressure)
{
calculateParameters();
double omega = 125.6637061;
for (std::size_t sampleIndex=0; sampleIndex<resultPressure.size(); ++sampleIndex)
{
const int lastSectionIndex = findLastNetworkSectionIndex();
std::complex<double> response{1.0, 0.0};
std::complex<double> networkImpedance = calculateEquivalentCircuit(omega);
for (int sectionIndex = lastSectionIndex; sectionIndex >= 0; --sectionIndex)
{
const NetworkSection& section = network[static_cast<std::size_t>(sectionIndex)];
calculateParallelBranch(networkImpedance, omega, section.parallel);
const std::complex<double> terminationImpedance = networkImpedance;
calculateSeriesBranch(networkImpedance, omega, section.series);
response *= terminationImpedance / networkImpedance;
}
if (F0 != 0)
{
calculateAcousticResponse(response, omega);
}
//berechneaktivefilter;
//ausgleichberechnen;
resultPressure[sampleIndex] = (phaseInverted ? -response : response) * gain;
omega = omega*KFilterFrequencyStep;
}
dirty_pressure = false;
}
}
void driver::calculateImpedanceResponse(void)
{
if (dirty_impedance)
{
calculateParameters();
double omega = 125.6637061;
for (std::size_t sampleIndex=0; sampleIndex<resultImpedance.size(); ++sampleIndex)
{
const int lastSectionIndex = findLastNetworkSectionIndex();
std::complex<double> networkImpedance = calculateEquivalentCircuit(omega);
for (int sectionIndex = lastSectionIndex; sectionIndex >= 0; --sectionIndex)
{
const NetworkSection& section = network[static_cast<std::size_t>(sectionIndex)];
calculateParallelBranch(networkImpedance, omega, section.parallel);
calculateSeriesBranch(networkImpedance, omega, section.series);
}
resultImpedance[sampleIndex] = networkImpedance;
omega=omega*KFilterFrequencyStep;
}
dirty_impedance = false;
}
}
std::complex<double> driver::calculateEquivalentCircuit(double omega)
{
if (F0 == 0)
{
return {Rdc, omega * Lsp};
}
std::complex<double> admittance;
switch (enclosureType)
{
case EnclosureType::Sealed :
admittance = {1/motionalResistance+sealedLeakageConductance, omega*motionalCapacitance-1/(omega*sealedEffectiveMotionalInductance)};
break;
case EnclosureType::Vented : case EnclosureType::Bandpass :
{
admittance = {1/motionalResistance, omega*motionalCapacitance-1/(omega*motionalInductance)};
const std::complex<double> branchImpedance{enclosureBranchResistance, omega*enclosureBranchInductance-1/(omega*enclosureBranchCapacitance)};
admittance += 1.0 / branchImpedance;
break;
}
case EnclosureType::OpenBaffle :
admittance = {1/motionalResistance, omega*motionalCapacitance-1/(omega*motionalInductance)};
break;
}
return std::complex<double>{Rdc, omega*Lsp} + 1.0 / admittance;
}
void driver::calculateAcousticResponse(std::complex<double>& response, double omega)
{
std::complex<double> networkImpedance;
std::complex<double> terminationImpedance;
double bw;
double bu;
double bx;//,hilfe;
//if hub then BEGIN berechnehub;exit END;
// Physical Driver-model component, not the user-configurable Active Filter
// low-pass. The historical implementation contributes magnitude only and
// is normalized to 0 dB in its pass band.
if (pistonLowPassActive)
{
networkImpedance = 1.0 / std::complex<double>{1.0, omega * pistonLowPassCapacitance};
terminationImpedance = networkImpedance;
networkImpedance += std::complex<double>{0.0, omega * pistonLowPassInductance};
response *= std::abs(terminationImpedance / networkImpedance);
}
switch (enclosureType)
{
case EnclosureType::OpenBaffle : if (fullCircuitFlag)
{
//********************************************************************************test
//xa=1; ya=f*Cline[99]; inverse(&xa,&ya);
//x=xa+Rline[99]; y=ya+f*Lline[99]; Quotient();
//for (int i=98; i>-1; i--){
//xa=x; ya=y+f*Cline[i]; inverse(&xa,&ya);
//x=xa+Rline[i]; y=ya+f*Lline[i]; Quotient();
//}
//********************************************************************************test
terminationImpedance = 1.0 / std::complex<double>{1/motionalResistance, omega*motionalCapacitance-1/(omega*motionalInductance)};
networkImpedance = terminationImpedance + std::complex<double>{Rdc, omega*Lsp};
response *= terminationImpedance / networkImpedance;
terminationImpedance = {1.0, 0.0};
networkImpedance = {1.0, -1/(omega*radiationCapacitance)};
response *= terminationImpedance / networkImpedance; //Strahlungswiederstand
response *= fullCircuitNormalizationFactor;
}
else
{
networkImpedance = 1.0 / std::complex<double>{1.0, -1/(omega*acousticHighPassInductance)};
terminationImpedance = networkImpedance;
networkImpedance += std::complex<double>{0.0, -1/(omega*acousticHighPassCapacitance)};
const std::complex<double> transfer = terminationImpedance / networkImpedance;
response *= transfer;
} //ELSE von realschall
break;
case EnclosureType::Sealed : if (fullCircuitFlag)
{
terminationImpedance = 1.0 / std::complex<double>{1/motionalResistance+sealedLeakageConductance, omega*motionalCapacitance-1/(omega*sealedEffectiveMotionalInductance)};
networkImpedance = terminationImpedance + std::complex<double>{Rdc, omega*Lsp};
response *= terminationImpedance / networkImpedance;
terminationImpedance = {1.0, 0.0};
networkImpedance = {1.0, -1/(omega*radiationCapacitance)};
response *= terminationImpedance / networkImpedance; //Strahlungswiederstand
response *= fullCircuitNormalizationFactor;
}
else
{
networkImpedance = 1.0 / std::complex<double>{sealedHighPassLossConductance, -1/(omega*acousticHighPassInductance)};
terminationImpedance = networkImpedance;
networkImpedance += std::complex<double>{0.0, -1/(omega*acousticHighPassCapacitance)};
const std::complex<double> transfer = terminationImpedance / networkImpedance;
response *= transfer;
} //ELSE von realschall
break;
case EnclosureType::Vented :
if (fullCircuitFlag)
{
terminationImpedance = {0.0, omega*enclosureBranchInductance};
networkImpedance = {enclosureBranchResistance, omega*enclosureBranchInductance-1/(omega*enclosureBranchCapacitance)};
response *= terminationImpedance / networkImpedance;
networkImpedance = 1.0 / networkImpedance;
terminationImpedance = networkImpedance + std::complex<double>{1/motionalResistance, omega*motionalCapacitance-1/(omega*motionalInductance)};
terminationImpedance = 1.0 / terminationImpedance;
networkImpedance = terminationImpedance + std::complex<double>{Rdc, omega*Lsp};
response *= terminationImpedance / networkImpedance;
terminationImpedance = {1.0, 0.0};
networkImpedance = {1.0, -1/(omega*radiationCapacitance)};
response *= terminationImpedance / networkImpedance; //Strahlungswiederstand
response *= fullCircuitNormalizationFactor;
}
else
{
if (!show_reflex_only)
{
// Fourth-order high-pass H(s) = s^4 / (s^4 + a3*s^3 + a2*s^2 + a1*s + a0)
// evaluated at s = j*bw. The historical implementation formed only
// |H| by taking the square root of the sum of the squared real and
// imaginary parts of the denominator, which discarded the phase and
// left the vector summation of a vented driver incorrect. Forming
// the denominator as a complex number instead keeps the magnitude
// bit-for-bit equivalent and restores the phase rotation.
bw=omega*0.159154943/F0; //omega/(2*pi)
bu=pow(bw,2.0);
bx=pow(bu,2.0);
const std::complex<double> ventedDenominator{
bx-ventedDenominatorA2*bu+ventedDenominatorA0,
ventedDenominatorA1*bw-ventedDenominatorA3*bu*bw};
response *= bx / ventedDenominator;
}
else
{
terminationImpedance = {0.0, -1/(omega*enclosureBranchCapacitance)};
networkImpedance = {enclosureBranchResistance, -1/(omega*enclosureBranchCapacitance)+omega*enclosureBranchInductance};
response *= terminationImpedance / networkImpedance;
networkImpedance = 1.0 / networkImpedance;
terminationImpedance = networkImpedance + std::complex<double>{1/motionalResistance, omega*motionalCapacitance-1/(omega*motionalInductance)};
terminationImpedance = 1.0 / terminationImpedance;
networkImpedance = terminationImpedance + std::complex<double>{Rdc, omega*Lsp};
response *= terminationImpedance / networkImpedance;
terminationImpedance = {1.0, 0.0};
networkImpedance = {1.0, -1/(omega*radiationCapacitance)};
response *= terminationImpedance / networkImpedance; //Strahlungswiederstand
response *= fullCircuitNormalizationFactor;
}
}
break;
case EnclosureType::Bandpass :
{
terminationImpedance = {0.0, -1/(omega*enclosureBranchCapacitance)};
networkImpedance = {enclosureBranchResistance, -1/(omega*enclosureBranchCapacitance)+omega*enclosureBranchInductance};
response *= terminationImpedance / networkImpedance;
networkImpedance = 1.0 / networkImpedance;
terminationImpedance = networkImpedance + std::complex<double>{1/motionalResistance, omega*motionalCapacitance-1/(omega*motionalInductance)};
terminationImpedance = 1.0 / terminationImpedance;
networkImpedance = terminationImpedance + std::complex<double>{Rdc, omega*Lsp};
response *= terminationImpedance / networkImpedance;
terminationImpedance = {1.0, 0.0};
networkImpedance = {1.0, -1/(omega*radiationCapacitance)};
response *= terminationImpedance / networkImpedance; //Strahlungswiederstand
response *= fullCircuitNormalizationFactor;
}
} //switch
}
int driver::findLastNetworkSectionIndex(void) const
{
for (int sectionIndex = static_cast<int>(network.size()) - 1; sectionIndex >= 0; --sectionIndex)
{
const NetworkSection& section = network[static_cast<std::size_t>(sectionIndex)];
if (section.series.resistance != 0.0 ||
section.series.capacitance != 0.0 ||
section.series.inductance != 0.0 ||
section.parallel.resistance != 0.0 ||
section.parallel.capacitance != 0.0 ||
section.parallel.inductance != 0.0)
{
return sectionIndex;
}
}
return -1;
}
void driver::calculateParallelBranch(std::complex<double>& networkImpedance, double omega, const NetworkBranch& branch)
{
std::complex<double> branchImpedance;
const double resistance = branch.resistance;
if (branch.capacitance==0)
{
if (branch.inductance==0)
{
if (branch.resistance==0)
{
return;
}
else
{
branchImpedance = {resistance, 0.0};
}
}
else
{
branchImpedance = {resistance, omega*branch.inductance};
}
}
else
{
if (branch.inductance==0)
{
branchImpedance = {resistance, -1/(omega*branch.capacitance)};
}
else
{
branchImpedance = {resistance, omega*branch.inductance - 1/(omega*branch.capacitance)};
}
}
networkImpedance = 1.0 / (1.0 / networkImpedance + 1.0 / branchImpedance);
}
void driver::calculateSeriesBranch(std::complex<double>& networkImpedance, double omega, const NetworkBranch& branch)
{
if (branch.capacitance==0)
{
if (branch.inductance==0)
{
networkImpedance += std::complex<double>{branch.resistance, 0.0};
}
else
{
networkImpedance += std::complex<double>{branch.resistance, omega*branch.inductance};
}
}
else
{
double susceptance;
if (branch.inductance==0)
{
susceptance = omega*branch.capacitance;
}
else
{
susceptance = omega*branch.capacitance - 1/(omega*branch.inductance);
}
if (branch.resistance==0)
{
networkImpedance += std::complex<double>{0.0, -1/susceptance};
}
else
{
const std::complex<double> branchAdmittance{1/branch.resistance, susceptance};
networkImpedance += 1.0 / branchAdmittance;
}
}
}
const driver::ResponseArray& driver::pressureResponse() const
{
return resultPressure;
}
const driver::ResponseArray& driver::impedanceResponse() const
{
return resultImpedance;
}
const DriverPlotState& driver::plotState() const
{
return plotState_;
}
void driver::setPlotState(const DriverPlotState& state)
{
plotState_ = state;
}
QString driver::getTitle() const
{
return m_qstringTitle;
}
void driver::setTitle( const QString& a_qstringTitle )
{
m_qstringTitle = a_qstringTitle;
}
/** Sets Rdc value */
void driver::setRdc(double rdc){
Rdc = rdc;
setModified();
}
/** Sets Lsp value */
void driver::setLsp(double lsp){
Lsp = lsp;
setModified();
}
/** Sets F0 value*/
void driver::setF0(double f0){
F0 = f0;
setModified();
}
/** Sets total driver Q (Qts). */
void driver::setQts(double qts){
Qts = qts;
setModified();
}
/** Sets Qes value */
void driver::setQes(double qes){
Qes = qes;
setModified();
}
/** Sets the full circuit flag */
void driver::setFullCircuit(bool toggle){
fullCircuitFlag = toggle;
setModified();
}
/** Gives the full circuit flag */
bool driver::getFullCircuit() const{
return fullCircuitFlag;
}
/** Sets Qms value */
void driver::setQms(double qms){
Qms = qms;
setModified();
}
/** Sets Vas value */
void driver::setVas(double vas){
Vas = vas;
setModified();
}
/** Sets Dm value */
void driver::setDm(double dm){
Dm = dm;
setModified();
}
/** Sets Vb value */
void driver::setVb(double vb){
Vb = vb;
setModified();
}
/** Sets Fb value */
void driver::setFb(double fb){
Fb = fb;
setModified();
}
/** Sets Ql value */
void driver::setQl(double ql){
Ql = ql;
setModified();
}
/** Sets V2 value */
void driver::setV2(double v2){
V2 = v2;
setModified();
}
/** Sets linear gain value */
void driver::setGainLinear(double linearGain){
gain = linearGain;
setModified();
}
/** Sets pressure-response phase inversion (polarity reversal). */
void driver::setPhaseInverted(bool inverted){
phaseInverted = inverted;
setModified();
}
/** Sets requested enclosure alignment. */
void driver::setEnclosureTypeProposal(EnclosureType type){
enclosureTypeProposal = type;
setModified();
}
/** No descriptions */
double driver::getRdc() const{
return Rdc;
}
/** No descriptions */
double driver::getLsp() const{
return Lsp;
}
/** No descriptions */
double driver::getF0() const{
return F0;
}
/** No descriptions */
double driver::getQts() const{
return Qts;
}
/** No descriptions */
double driver::getQes() const{
return Qes;
}
/** No descriptions */
double driver::getQms() const{
return Qms;
}
/** No descriptions */
double driver::getVas() const{
return Vas;
}
/** No descriptions */
double driver::getDm() const{
return Dm;
}
/** Gets Vb value */
double driver::getVb() const{
return Vb;
}
/** Gets Fb value */
double driver::getFb() const{
return Fb;
}
/** Gets Ql value */
double driver::getQl() const{
return Ql;
}
/** Gets V2 value */
double driver::getV2() const{
return V2;
}
/** Gets linear gain value */
double driver::getGainLinear() const{
return gain;
}
/** Returns pressure-response phase inversion state. */
bool driver::isPhaseInverted() const{
return phaseInverted;
}
/** Returns requested enclosure alignment. */
EnclosureType driver::getEnclosureTypeProposal() const{
return enclosureTypeProposal;
}
driver::NetworkBranch* driver::networkBranch(int sectionIndex, NetworkBranchType branch)
{
if (sectionIndex < 0 || sectionIndex >= static_cast<int>(NetworkSectionCount))
{
return nullptr;
}
NetworkSection& section = network[static_cast<std::size_t>(sectionIndex)];
switch (branch)
{
case NetworkBranchType::Series:
return §ion.series;
case NetworkBranchType::Shunt:
return §ion.parallel;
}
return nullptr;
}
const driver::NetworkBranch* driver::networkBranch(int sectionIndex, NetworkBranchType branch) const
{
if (sectionIndex < 0 || sectionIndex >= static_cast<int>(NetworkSectionCount))
{
return nullptr;
}
const NetworkSection& section = network[static_cast<std::size_t>(sectionIndex)];
switch (branch)
{
case NetworkBranchType::Series:
return §ion.series;
case NetworkBranchType::Shunt:
return §ion.parallel;
}
return nullptr;
}
void driver::setNetworkValue(int sectionIndex,
NetworkBranchType branch,
NetworkComponent component,
double value)
{
NetworkBranch* selectedBranch = networkBranch(sectionIndex, branch);
if (selectedBranch == nullptr)
{
return;
}
switch (component)
{
case NetworkComponent::Resistance:
selectedBranch->resistance = value;
break;
case NetworkComponent::Capacitance:
selectedBranch->capacitance = value;
break;
case NetworkComponent::Inductance:
selectedBranch->inductance = value;
break;
default:
return;
}
setModified();
}
double driver::getNetworkValue(int sectionIndex,
NetworkBranchType branch,
NetworkComponent component) const
{
const NetworkBranch* selectedBranch = networkBranch(sectionIndex, branch);
if (selectedBranch == nullptr)
{
return -1.0;
}
switch (component)
{
case NetworkComponent::Resistance:
return selectedBranch->resistance;
case NetworkComponent::Capacitance:
return selectedBranch->capacitance;
case NetworkComponent::Inductance:
return selectedBranch->inductance;
}
return -1.0;
}