Skip to content

Commit

Permalink
docs: complex character added to the "Quantity character" chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
mpusz committed Jan 24, 2025
1 parent a746589 commit 7ea23dd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/users_guide/framework_basics/design_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,14 @@ results in the `derived_dimension<isq::dim_length, per<isq::dim_time>>` type.
different [characters](../../appendix/glossary.md#character):

- scalar,
- complex,
- vector,
- tensor.

The quantity character in the **mp-units** library is implemented with the `quantity_character` enumeration:

```cpp
enum class quantity_character { scalar, vector, tensor };
enum class quantity_character { scalar, complex, vector, tensor };
```
!!! info
Expand Down

8 comments on commit 7ea23dd

@Spammed
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does complex fit into these exclusive characters?
Can something not be (scalar and complex) or
(vector and complex)?

@mpusz
Copy link
Owner Author

@mpusz mpusz commented on 7ea23dd Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know. Do you know an example of a vector complex quantity? I need complex to model things like complex power as mentioned in the last paragraph of my latest article.

@JohelEGP
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A tensor could always be of vector elements.
So far, mp-units uses these for concepts and customization points,
and doesn't concern itself with the number's element, unlike its scalar.

@mpusz
Copy link
Owner Author

@mpusz mpusz commented on 7ea23dd Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be exact, quantity_character specifies which operations can or can't be performed on a given quantity.

@Spammed
Copy link

@Spammed Spammed commented on 7ea23dd Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know an example of a vector complex quantity?

I have no dealings with these type of quantities, but they should exist.
For example, a mechanical or electrical impedance (represented as a complex-valued quantity) could be directional, so it should be possible to describe it as a vector of complex quantities.
Presumably there is also something like a complex-valued stress-strain tensor. Why not?

[real or complex]-valued and [scalar or vector or tensor]-like are different properties that are not mutually exclusive.

@mpusz
Copy link
Owner Author

@mpusz mpusz commented on 7ea23dd Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good feedback. Thank you! We need to think about how to model this. Maybe a quantity character should be a struct of enums?

@Spammed
Copy link

@Spammed Spammed commented on 7ea23dd Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't complex (not to say std::complex<...>) just another number type?
So, belongs in a line with byte, integer, float, double, ...

@mpusz
Copy link
Owner Author

@mpusz mpusz commented on 7ea23dd Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and no. Complex quantities should expose additional interfaces like real(), imag() and mod(). A result of those is another specific quantity. As I wrote in my article:

For example, in the case of complex quantities, we want to ensure that only:

  • the real part of a complex power is assigned to an active power,
  • the imaginary part of a complex power is assigned to an reactive power,
  • the modulus of a complex power is assigned to an apparent power.

Mixing the above is a fatal error in power systems engineering.

Also, a complex power should be created from active and reactive powers passed in that order and not the other way around.

Please sign in to comment.