FreeCAD

Форк
0
/
Unit.cpp 
687 строк · 24.8 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2011 Jürgen Riegel <juergen.riegel@web.de>              *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
6
 *   This library is free software; you can redistribute it and/or         *
7
 *   modify it under the terms of the GNU Library General Public           *
8
 *   License as published by the Free Software Foundation; either          *
9
 *   version 2 of the License, or (at your option) any later version.      *
10
 *                                                                         *
11
 *   This library  is distributed in the hope that it will be useful,      *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU Library General Public License for more details.                  *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU Library General Public     *
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24
#ifndef _PreComp_
25
#include <cmath>
26
#include <limits>
27
#include <sstream>
28
#endif
29

30
#include "Unit.h"
31
#include "Exception.h"
32
#include "Quantity.h"
33

34

35
using namespace Base;
36

37
// clang-format off
38
static inline void checkPow(UnitSignature sig, double exp)
39
{
40
    auto isInt = [](double value) {
41
        return std::fabs(std::round(value) - value) < std::numeric_limits<double>::epsilon();
42
    };
43
    if (!isInt(sig.Length * exp) ||
44
        !isInt(sig.Mass * exp) ||
45
        !isInt(sig.Time * exp) ||
46
        !isInt(sig.ElectricCurrent * exp) ||
47
        !isInt(sig.ThermodynamicTemperature * exp) ||
48
        !isInt(sig.AmountOfSubstance * exp) ||
49
        !isInt(sig.LuminousIntensity * exp) ||
50
        !isInt(sig.Angle * exp)) {
51
        throw Base::UnitsMismatchError("pow() of unit not possible");
52
    }
53
}
54

55
static inline void checkRange(const char * op, int length, int mass, int time, int electricCurrent,
56
                              int thermodynamicTemperature, int amountOfSubstance, int luminousIntensity, int angle)
57
{
58
    if ( ( length                   >=  (1 << (UnitSignatureLengthBits                   - 1)) ) ||
59
         ( mass                     >=  (1 << (UnitSignatureMassBits                     - 1)) ) ||
60
         ( time                     >=  (1 << (UnitSignatureTimeBits                     - 1)) ) ||
61
         ( electricCurrent          >=  (1 << (UnitSignatureElectricCurrentBits          - 1)) ) ||
62
         ( thermodynamicTemperature >=  (1 << (UnitSignatureThermodynamicTemperatureBits - 1)) ) ||
63
         ( amountOfSubstance        >=  (1 << (UnitSignatureAmountOfSubstanceBits        - 1)) ) ||
64
         ( luminousIntensity        >=  (1 << (UnitSignatureLuminousIntensityBits        - 1)) ) ||
65
         ( angle                    >=  (1 << (UnitSignatureAngleBits                    - 1)) ) ) {
66
        throw Base::OverflowError((std::string("Unit overflow in ") + std::string(op)).c_str());
67
    }
68
    if ( ( length                   <  -(1 << (UnitSignatureLengthBits                   - 1)) ) ||
69
         ( mass                     <  -(1 << (UnitSignatureMassBits                     - 1)) ) ||
70
         ( time                     <  -(1 << (UnitSignatureTimeBits                     - 1)) ) ||
71
         ( electricCurrent          <  -(1 << (UnitSignatureElectricCurrentBits          - 1)) ) ||
72
         ( thermodynamicTemperature <  -(1 << (UnitSignatureThermodynamicTemperatureBits - 1)) ) ||
73
         ( amountOfSubstance        <  -(1 << (UnitSignatureAmountOfSubstanceBits        - 1)) ) ||
74
         ( luminousIntensity        <  -(1 << (UnitSignatureLuminousIntensityBits        - 1)) ) ||
75
         ( angle                    <  -(1 << (UnitSignatureAngleBits                    - 1)) ) ) {
76
        throw Base::UnderflowError((std::string("Unit underflow in ") + std::string(op)).c_str());
77
    }
78
}
79

80
Unit::Unit(int8_t Length, //NOLINT
81
           int8_t Mass,
82
           int8_t Time,
83
           int8_t ElectricCurrent,
84
           int8_t ThermodynamicTemperature,
85
           int8_t AmountOfSubstance,
86
           int8_t LuminousIntensity,
87
           int8_t Angle)
88
{
89
    checkRange("unit",
90
               Length,
91
               Mass,
92
               Time,
93
               ElectricCurrent,
94
               ThermodynamicTemperature,
95
               AmountOfSubstance,
96
               LuminousIntensity,
97
               Angle);
98

99
    Sig.Length                   = Length;
100
    Sig.Mass                     = Mass;
101
    Sig.Time                     = Time;
102
    Sig.ElectricCurrent          = ElectricCurrent;
103
    Sig.ThermodynamicTemperature = ThermodynamicTemperature;
104
    Sig.AmountOfSubstance        = AmountOfSubstance;
105
    Sig.LuminousIntensity        = LuminousIntensity;
106
    Sig.Angle                    = Angle;
107
}
108

109

110
Unit::Unit() //NOLINT
111
{
112
    Sig.Length                   = 0;
113
    Sig.Mass                     = 0;
114
    Sig.Time                     = 0;
115
    Sig.ElectricCurrent          = 0;
116
    Sig.ThermodynamicTemperature = 0;
117
    Sig.AmountOfSubstance        = 0;
118
    Sig.LuminousIntensity        = 0;
119
    Sig.Angle                    = 0;
120
}
121

122
Unit::Unit(const QString& expr)  // NOLINT
123
{
124
    try {
125
        *this = Quantity::parse(expr).getUnit();
126
    }
127
    catch (const Base::ParserError&) {
128
        Sig.Length                   = 0;
129
        Sig.Mass                     = 0;
130
        Sig.Time                     = 0;
131
        Sig.ElectricCurrent          = 0;
132
        Sig.ThermodynamicTemperature = 0;
133
        Sig.AmountOfSubstance        = 0;
134
        Sig.LuminousIntensity        = 0;
135
        Sig.Angle                    = 0;
136
    }
137
}
138

139
Unit Unit::pow(double exp) const
140
{
141
    checkPow(Sig, exp);
142
    checkRange("pow()",
143
               static_cast<int>(Sig.Length * exp),
144
               static_cast<int>(Sig.Mass * exp),
145
               static_cast<int>(Sig.Time * exp),
146
               static_cast<int>(Sig.ElectricCurrent * exp),
147
               static_cast<int>(Sig.ThermodynamicTemperature * exp),
148
               static_cast<int>(Sig.AmountOfSubstance * exp),
149
               static_cast<int>(Sig.LuminousIntensity * exp),
150
               static_cast<int>(Sig.Angle * exp));
151

152
    Unit result;
153
    result.Sig.Length                   = static_cast<int8_t>(Sig.Length                    * exp);
154
    result.Sig.Mass                     = static_cast<int8_t>(Sig.Mass                      * exp);
155
    result.Sig.Time                     = static_cast<int8_t>(Sig.Time                      * exp);
156
    result.Sig.ElectricCurrent          = static_cast<int8_t>(Sig.ElectricCurrent           * exp);
157
    result.Sig.ThermodynamicTemperature = static_cast<int8_t>(Sig.ThermodynamicTemperature  * exp);
158
    result.Sig.AmountOfSubstance        = static_cast<int8_t>(Sig.AmountOfSubstance         * exp);
159
    result.Sig.LuminousIntensity        = static_cast<int8_t>(Sig.LuminousIntensity         * exp);
160
    result.Sig.Angle                    = static_cast<int8_t>(Sig.Angle                     * exp);
161

162
    return result;
163
}
164

165
bool Unit::isEmpty()const
166
{
167
    return (this->Sig.Length == 0)
168
        && (this->Sig.Mass == 0)
169
        && (this->Sig.Time == 0)
170
        && (this->Sig.ElectricCurrent == 0)
171
        && (this->Sig.ThermodynamicTemperature == 0)
172
        && (this->Sig.AmountOfSubstance == 0)
173
        && (this->Sig.LuminousIntensity == 0)
174
        && (this->Sig.Angle == 0);
175
}
176

177
bool Unit::operator ==(const Unit& that) const
178
{
179
    return (this->Sig.Length == that.Sig.Length)
180
        && (this->Sig.Mass == that.Sig.Mass)
181
        && (this->Sig.Time == that.Sig.Time)
182
        && (this->Sig.ElectricCurrent == that.Sig.ElectricCurrent)
183
        && (this->Sig.ThermodynamicTemperature == that.Sig.ThermodynamicTemperature)
184
        && (this->Sig.AmountOfSubstance == that.Sig.AmountOfSubstance)
185
        && (this->Sig.LuminousIntensity == that.Sig.LuminousIntensity)
186
        && (this->Sig.Angle == that.Sig.Angle);
187
}
188

189

190
Unit Unit::operator *(const Unit &right) const
191
{
192
    checkRange("* operator",
193
               Sig.Length +right.Sig.Length,
194
               Sig.Mass + right.Sig.Mass,
195
               Sig.Time + right.Sig.Time,
196
               Sig.ElectricCurrent + right.Sig.ElectricCurrent,
197
               Sig.ThermodynamicTemperature + right.Sig.ThermodynamicTemperature,
198
               Sig.AmountOfSubstance + right.Sig.AmountOfSubstance,
199
               Sig.LuminousIntensity + right.Sig.LuminousIntensity,
200
               Sig.Angle + right.Sig.Angle);
201

202
    Unit result;
203
    result.Sig.Length                   = Sig.Length                    + right.Sig.Length;
204
    result.Sig.Mass                     = Sig.Mass                      + right.Sig.Mass;
205
    result.Sig.Time                     = Sig.Time                      + right.Sig.Time;
206
    result.Sig.ElectricCurrent          = Sig.ElectricCurrent           + right.Sig.ElectricCurrent;
207
    result.Sig.ThermodynamicTemperature = Sig.ThermodynamicTemperature  + right.Sig.ThermodynamicTemperature;
208
    result.Sig.AmountOfSubstance        = Sig.AmountOfSubstance         + right.Sig.AmountOfSubstance;
209
    result.Sig.LuminousIntensity        = Sig.LuminousIntensity         + right.Sig.LuminousIntensity;
210
    result.Sig.Angle                    = Sig.Angle                     + right.Sig.Angle;
211

212
    return result;
213
}
214

215
Unit Unit::operator /(const Unit &right) const
216
{
217
    checkRange("/ operator",
218
               Sig.Length - right.Sig.Length,
219
               Sig.Mass - right.Sig.Mass,
220
               Sig.Time - right.Sig.Time,
221
               Sig.ElectricCurrent - right.Sig.ElectricCurrent,
222
               Sig.ThermodynamicTemperature - right.Sig.ThermodynamicTemperature,
223
               Sig.AmountOfSubstance - right.Sig.AmountOfSubstance,
224
               Sig.LuminousIntensity - right.Sig.LuminousIntensity,
225
               Sig.Angle - right.Sig.Angle);
226

227
    Unit result;
228
    result.Sig.Length                   = Sig.Length                    - right.Sig.Length;
229
    result.Sig.Mass                     = Sig.Mass                      - right.Sig.Mass;
230
    result.Sig.Time                     = Sig.Time                      - right.Sig.Time;
231
    result.Sig.ElectricCurrent          = Sig.ElectricCurrent           - right.Sig.ElectricCurrent;
232
    result.Sig.ThermodynamicTemperature = Sig.ThermodynamicTemperature  - right.Sig.ThermodynamicTemperature;
233
    result.Sig.AmountOfSubstance        = Sig.AmountOfSubstance         - right.Sig.AmountOfSubstance;
234
    result.Sig.LuminousIntensity        = Sig.LuminousIntensity         - right.Sig.LuminousIntensity;
235
    result.Sig.Angle                    = Sig.Angle                     - right.Sig.Angle;
236

237
    return result;
238
}
239

240
QString Unit::getString() const
241
{
242
    std::stringstream ret;
243

244
    if (isEmpty()) {
245
        return {};
246
    }
247

248
    if (Sig.Length                  > 0 ||
249
        Sig.Mass                    > 0 ||
250
        Sig.Time                    > 0 ||
251
        Sig.ElectricCurrent         > 0 ||
252
        Sig.ThermodynamicTemperature> 0 ||
253
        Sig.AmountOfSubstance       > 0 ||
254
        Sig.LuminousIntensity       > 0 ||
255
        Sig.Angle                   > 0 ){
256

257
        bool mult = false;
258
        if (Sig.Length > 0) {
259
            mult = true;
260
            ret << "mm";
261
            if (Sig.Length > 1) {
262
                ret << "^" << Sig.Length;
263
            }
264
        }
265

266
        if (Sig.Mass > 0) {
267
            if (mult) {
268
                ret<<'*';
269
            }
270
            mult = true;
271
            ret << "kg";
272
            if (Sig.Mass > 1) {
273
                ret << "^" << Sig.Mass;
274
            }
275
        }
276

277
        if (Sig.Time > 0) {
278
            if (mult) {
279
                ret<<'*';
280
            }
281
            mult = true;
282
            ret << "s";
283
            if (Sig.Time > 1) {
284
                ret << "^" << Sig.Time;
285
            }
286
        }
287

288
        if (Sig.ElectricCurrent > 0) {
289
            if (mult) {
290
                ret<<'*';
291
            }
292
            mult = true;
293
            ret << "A";
294
            if (Sig.ElectricCurrent > 1) {
295
                ret << "^" << Sig.ElectricCurrent;
296
            }
297
        }
298

299
        if (Sig.ThermodynamicTemperature > 0) {
300
            if (mult) {
301
                ret<<'*';
302
            }
303
            mult = true;
304
            ret << "K";
305
            if (Sig.ThermodynamicTemperature > 1) {
306
                ret << "^" << Sig.ThermodynamicTemperature;
307
            }
308
        }
309

310
        if (Sig.AmountOfSubstance > 0){
311
            if (mult) {
312
                ret<<'*';
313
            }
314
            mult = true;
315
            ret << "mol";
316
            if (Sig.AmountOfSubstance > 1) {
317
                ret << "^" << Sig.AmountOfSubstance;
318
            }
319
        }
320

321
        if (Sig.LuminousIntensity > 0) {
322
            if (mult) {
323
                ret<<'*';
324
            }
325
            mult = true;
326
            ret << "cd";
327
            if (Sig.LuminousIntensity > 1) {
328
                ret << "^" << Sig.LuminousIntensity;
329
            }
330
        }
331

332
        if (Sig.Angle > 0) {
333
            if (mult) {
334
                ret<<'*';
335
            }
336
            mult = true; //NOLINT
337
            ret << "deg";
338
            if (Sig.Angle > 1) {
339
                ret << "^" << Sig.Angle;
340
            }
341
        }
342
    }
343
    else {
344
        ret << "1";
345
    }
346

347
    if (Sig.Length                  < 0 ||
348
        Sig.Mass                    < 0 ||
349
        Sig.Time                    < 0 ||
350
        Sig.ElectricCurrent         < 0 ||
351
        Sig.ThermodynamicTemperature< 0 ||
352
        Sig.AmountOfSubstance       < 0 ||
353
        Sig.LuminousIntensity       < 0 ||
354
        Sig.Angle                   < 0 ){
355
        ret << "/";
356

357
        int nnom = 0;
358
        nnom += Sig.Length<0?1:0;
359
        nnom += Sig.Mass<0?1:0;
360
        nnom += Sig.Time<0?1:0;
361
        nnom += Sig.ElectricCurrent<0?1:0;
362
        nnom += Sig.ThermodynamicTemperature<0?1:0;
363
        nnom += Sig.AmountOfSubstance<0?1:0;
364
        nnom += Sig.LuminousIntensity<0?1:0;
365
        nnom += Sig.Angle<0?1:0;
366

367
        if (nnom > 1) {
368
            ret << '(';
369
        }
370

371
        bool mult=false;
372
        if (Sig.Length < 0) {
373
            ret << "mm";
374
            mult = true;
375
            if (Sig.Length < -1) {
376
                ret << "^" << abs(Sig.Length);
377
            }
378
        }
379

380
        if (Sig.Mass < 0) {
381
            if (mult) {
382
                ret<<'*';
383
            }
384
            mult = true;
385
            ret << "kg";
386
            if (Sig.Mass < -1) {
387
                ret << "^" << abs(Sig.Mass);
388
            }
389
        }
390

391
        if (Sig.Time < 0) {
392
            if (mult) {
393
                ret<<'*';
394
            }
395
            mult = true;
396
            ret << "s";
397
            if (Sig.Time < -1) {
398
                ret << "^" << abs(Sig.Time);
399
            }
400
        }
401

402
        if (Sig.ElectricCurrent < 0) {
403
            if (mult) {
404
                ret<<'*';
405
            }
406
            mult = true;
407
            ret << "A";
408
            if (Sig.ElectricCurrent < -1) {
409
                ret << "^" << abs(Sig.ElectricCurrent);
410
            }
411
        }
412

413
        if (Sig.ThermodynamicTemperature < 0) {
414
            if (mult) {
415
                ret<<'*';
416
            }
417
            mult = true;
418
            ret << "K";
419
            if (Sig.ThermodynamicTemperature < -1) {
420
                ret << "^" << abs(Sig.ThermodynamicTemperature);
421
            }
422
        }
423

424
        if (Sig.AmountOfSubstance < 0) {
425
            if (mult) {
426
                ret<<'*';
427
            }
428
            mult = true;
429
            ret << "mol";
430
            if (Sig.AmountOfSubstance < -1) {
431
                ret << "^" << abs(Sig.AmountOfSubstance);
432
            }
433
        }
434

435
        if (Sig.LuminousIntensity < 0) {
436
            if (mult) {
437
                ret<<'*';
438
            }
439
            mult = true;
440
            ret << "cd";
441
            if (Sig.LuminousIntensity < -1) {
442
                ret << "^" << abs(Sig.LuminousIntensity);
443
            }
444
        }
445

446
        if (Sig.Angle < 0) {
447
            if (mult) {
448
                ret<<'*';
449
            }
450
            mult = true; //NOLINT
451
            ret << "deg";
452
            if (Sig.Angle < -1) {
453
                ret << "^" << abs(Sig.Angle);
454
            }
455
        }
456

457
        if (nnom > 1) {
458
            ret << ')';
459
        }
460
    }
461

462
    return QString::fromUtf8(ret.str().c_str());
463
}
464

465
QString Unit::getTypeString() const
466
{
467
    if (*this == Unit::Acceleration) {
468
        return QString::fromLatin1("Acceleration");
469
    }
470
    if (*this == Unit::AmountOfSubstance) {
471
        return QString::fromLatin1("AmountOfSubstance");
472
    }
473
    if (*this == Unit::Angle) {
474
        return QString::fromLatin1("Angle");
475
    }
476
    if (*this == Unit::AngleOfFriction) {
477
        return QString::fromLatin1("AngleOfFriction");
478
    }
479
    if (*this == Unit::Area) {
480
        return QString::fromLatin1("Area");
481
    }
482
    if (*this == Unit::CurrentDensity) {
483
        return QString::fromLatin1("CurrentDensity");
484
    }
485
    if (*this == Unit::Density) {
486
        return QString::fromLatin1("Density");
487
    }
488
    if (*this == Unit::DissipationRate) {
489
        return QString::fromLatin1("DissipationRate");
490
    }
491
    if (*this == Unit::DynamicViscosity) {
492
        return QString::fromLatin1("DynamicViscosity");
493
    }
494
    if (*this == Unit::ElectricalCapacitance) {
495
        return QString::fromLatin1("ElectricalCapacitance");
496
    }
497
    if (*this == Unit::ElectricalConductance) {
498
        return QString::fromLatin1("ElectricalConductance");
499
    }
500
    if (*this == Unit::ElectricalConductivity) {
501
        return QString::fromLatin1("ElectricalConductivity");
502
    }
503
    if (*this == Unit::ElectricalInductance) {
504
        return QString::fromLatin1("ElectricalInductance");
505
    }
506
    if (*this == Unit::ElectricalResistance) {
507
        return QString::fromLatin1("ElectricalResistance");
508
    }
509
    if (*this == Unit::ElectricCharge) {
510
        return QString::fromLatin1("ElectricCharge");
511
    }
512
    if (*this == Unit::ElectricCurrent) {
513
        return QString::fromLatin1("ElectricCurrent");
514
    }
515
    if (*this == Unit::ElectricPotential) {
516
        return QString::fromLatin1("ElectricPotential");
517
    }
518
    if (*this == Unit::Frequency) {
519
        return QString::fromLatin1("Frequency");
520
    }
521
    if (*this == Unit::Force) {
522
        return QString::fromLatin1("Force");
523
    }
524
    if (*this == Unit::HeatFlux) {
525
        return QString::fromLatin1("HeatFlux");
526
    }
527
    if (*this == Unit::InverseArea) {
528
        return QString::fromLatin1("InverseArea");
529
    }
530
    if (*this == Unit::InverseLength) {
531
        return QString::fromLatin1("InverseLength");
532
    }
533
    if (*this == Unit::InverseVolume) {
534
        return QString::fromLatin1("InverseVolume");
535
    }
536
    if (*this == Unit::KinematicViscosity) {
537
        return QString::fromLatin1("KinematicViscosity");
538
    }
539
    if (*this == Unit::Length) {
540
        return QString::fromLatin1("Length");
541
    }
542
    if (*this == Unit::LuminousIntensity) {
543
        return QString::fromLatin1("LuminousIntensity");
544
    }
545
    if (*this == Unit::MagneticFieldStrength) {
546
        return QString::fromLatin1("MagneticFieldStrength");
547
    }
548
    if (*this == Unit::MagneticFlux) {
549
        return QString::fromLatin1("MagneticFlux");
550
    }
551
    if (*this == Unit::MagneticFluxDensity) {
552
        return QString::fromLatin1("MagneticFluxDensity");
553
    }
554
    if (*this == Unit::Magnetization) {
555
        return QString::fromLatin1("Magnetization");
556
    }
557
    if (*this == Unit::Mass) {
558
        return QString::fromLatin1("Mass");
559
    }
560
    if (*this == Unit::Pressure) {
561
        return QString::fromLatin1("Pressure");
562
    }
563
    if (*this == Unit::Power) {
564
        return QString::fromLatin1("Power");
565
    }
566
    if (*this == Unit::ShearModulus) {
567
        return QString::fromLatin1("ShearModulus");
568
    }
569
    if (*this == Unit::SpecificEnergy) {
570
        return QString::fromLatin1("SpecificEnergy");
571
    }
572
    if (*this == Unit::SpecificHeat) {
573
        return QString::fromLatin1("SpecificHeat");
574
    }
575
    if (*this == Unit::Stiffness) {
576
        return QString::fromLatin1("Stiffness");
577
    }
578
    if (*this == Unit::StiffnessDensity) {
579
        return QString::fromLatin1("StiffnessDensity");
580
    }
581
    if (*this == Unit::Stress) {
582
        return QString::fromLatin1("Stress");
583
    }
584
    if (*this == Unit::Temperature) {
585
        return QString::fromLatin1("Temperature");
586
    }
587
    if (*this == Unit::ThermalConductivity) {
588
        return QString::fromLatin1("ThermalConductivity");
589
    }
590
    if (*this == Unit::ThermalExpansionCoefficient) {
591
        return QString::fromLatin1("ThermalExpansionCoefficient");
592
    }
593
    if (*this == Unit::ThermalTransferCoefficient) {
594
        return QString::fromLatin1("ThermalTransferCoefficient");
595
    }
596
    if (*this == Unit::TimeSpan) {
597
        return QString::fromLatin1("TimeSpan");
598
    }
599
    if (*this == Unit::UltimateTensileStrength) {
600
        return QString::fromLatin1("UltimateTensileStrength");
601
    }
602
    if (*this == Unit::VacuumPermittivity) {
603
        return QString::fromLatin1("VacuumPermittivity");
604
    }
605
    if (*this == Unit::Velocity) {
606
        return QString::fromLatin1("Velocity");
607
    }
608
    if (*this == Unit::Volume) {
609
        return QString::fromLatin1("Volume");
610
    }
611
    if (*this == Unit::VolumeFlowRate) {
612
        return QString::fromLatin1("VolumeFlowRate");
613
    }
614
    if (*this == Unit::VolumetricThermalExpansionCoefficient) {
615
        return QString::fromLatin1("VolumetricThermalExpansionCoefficient");
616
    }
617
    if (*this == Unit::Work) {
618
        return QString::fromLatin1("Work");
619
    }
620
    if (*this == Unit::YieldStrength) {
621
        return QString::fromLatin1("YieldStrength");
622
    }
623
    if (*this == Unit::YoungsModulus) {
624
        return QString::fromLatin1("YoungsModulus");
625
    }
626

627
    return {};
628
}
629

630
// SI base units
631
const Unit Unit::AmountOfSubstance          (0, 0, 0, 0, 0, 1);
632
const Unit Unit::ElectricCurrent            (0, 0, 0, 1);
633
const Unit Unit::Length                     (1);
634
const Unit Unit::LuminousIntensity          (0, 0, 0, 0, 0, 0, 1);
635
const Unit Unit::Mass                       (0, 1);
636
const Unit Unit::Temperature                (0, 0, 0, 0, 1);
637
const Unit Unit::TimeSpan                   (0, 0, 1);
638

639
// all other units
640
const Unit Unit::Acceleration               (1, 0, -2);
641
const Unit Unit::Angle                      (0, 0, 0, 0, 0, 0, 0, 1);
642
const Unit Unit::AngleOfFriction            (0, 0, 0, 0, 0, 0, 0, 1);
643
const Unit Unit::Area                       (2);
644
const Unit Unit::CompressiveStrength        (-1, 1, -2);
645
const Unit Unit::CurrentDensity             (-2, 0, 0, 1);
646
const Unit Unit::Density                    (-3, 1);
647
const Unit Unit::DissipationRate   (2, 0, -3); // https://cfd-online.com/Wiki/Turbulence_dissipation_rate
648
const Unit Unit::DynamicViscosity           (-1, 1, -1);
649
const Unit Unit::ElectricalCapacitance      (-2, -1, 4, 2);
650
const Unit Unit::ElectricalConductance      (-2, -1, 3, 2);
651
const Unit Unit::ElectricalConductivity     (-3, -1, 3, 2);
652
const Unit Unit::ElectricalInductance       (2, 1, -2, -2);
653
const Unit Unit::ElectricalResistance       (2, 1, -3, -2);
654
const Unit Unit::ElectricCharge             (0, 0, 1, 1);
655
const Unit Unit::ElectricPotential          (2, 1, -3, -1);
656
const Unit Unit::Force                      (1, 1, -2);
657
const Unit Unit::Frequency                  (0, 0, -1);
658
const Unit Unit::HeatFlux                   (0, 1, -3, 0, 0);
659
const Unit Unit::InverseArea                (-2, 0, 0);
660
const Unit Unit::InverseLength              (-1, 0, 0);
661
const Unit Unit::InverseVolume              (-3, 0, 0);
662
const Unit Unit::KinematicViscosity         (2, 0, -1);
663
const Unit Unit::MagneticFieldStrength      (-1,0,0,1);
664
const Unit Unit::MagneticFlux               (2,1,-2,-1);
665
const Unit Unit::MagneticFluxDensity        (0,1,-2,-1);
666
const Unit Unit::Magnetization              (-1,0,0,1);
667
const Unit Unit::Pressure                   (-1,1,-2);
668
const Unit Unit::Power                      (2, 1, -3);
669
const Unit Unit::ShearModulus               (-1,1,-2);
670
const Unit Unit::SpecificEnergy             (2, 0, -2);
671
const Unit Unit::SpecificHeat               (2, 0, -2, 0, -1);
672
const Unit Unit::Stiffness                  (0, 1, -2);
673
const Unit Unit::StiffnessDensity           (-2, 1, -2);
674
const Unit Unit::Stress                     (-1,1,-2);
675
const Unit Unit::ThermalConductivity        (1, 1, -3, 0, -1);
676
const Unit Unit::ThermalExpansionCoefficient(0, 0, 0, 0, -1);
677
const Unit Unit::ThermalTransferCoefficient (0, 1, -3, 0, -1);
678
const Unit Unit::UltimateTensileStrength    (-1,1,-2);
679
const Unit Unit::VacuumPermittivity         (-3, -1, 4,  2);
680
const Unit Unit::Velocity                   (1, 0, -1);
681
const Unit Unit::Volume                     (3);
682
const Unit Unit::VolumeFlowRate             (3, 0, -1);
683
const Unit Unit::VolumetricThermalExpansionCoefficient(0, 0, 0, 0, -1);
684
const Unit Unit::Work                       (2, 1, -2);
685
const Unit Unit::YieldStrength              (-1,1,-2);
686
const Unit Unit::YoungsModulus              (-1,1,-2);
687
// clang-format on
688

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.