Skip to content

Conversation

@HansOlsson
Copy link
Contributor

This clears up the unit-issues in the Hysteresis models.

Facts about the PR:

  • Unit-consistent
  • Without unit-casts
  • Are the new unit strings correct? I don't know; it's possible - even likely, but I haven't seen the original model.

It requires more than Modelica Language 3.6, due to the odd units.

@HansOlsson HansOlsson added the L: Magnetic.FluxTubes Issue addresses Modelica.Magnetic.FluxTubes label Dec 13, 2023
@HansOlsson HansOlsson added the requires Modelica 3.7 Issue that requires Modelica Language Specification 3.7 label Dec 13, 2023
parameter Real M(final unit="T")=0.95
"Related to saturation value of magnetization";
parameter Real r(final unit="1")=0.55
parameter Real r(final unit="T-(1/2)")=0.55
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See: modelica/ModelicaSpecification#3439 for this new unit-string, added after Modelica Language 3.6.

@HansOlsson HansOlsson requested review from ThomasBoedrich and removed request for AHaumer December 13, 2023 08:06
@christiankral
Copy link
Contributor

christiankral commented Dec 13, 2023

I understand that the proposed change of units somehow leads to a consistent set of units:

  • I do not understand the physical meaning of the parameters P1...P4 with their unit $\sqrt{\mathrm T}$ and of the parameter r with its unit $\sqrt{\frac{1}{\mathrm T}}$. Parameters with such weird units are usually related with emperic "numeric value equations".
  • Yet, if unit consistency requires such weird units, it shall be fine with me.
  • The term (1-mat.r), however, does not make sense to me at all, as the 1 has to have the same unit as r to make this calculation unit consistent.

@HansOlsson
Copy link
Contributor Author

  • The term (1-mat.r), however, does not make sense to me at all, as the 1 has to have the same unit as r to make this calculation unit consistent.

True, that would imply mat.r.unit="1".

The derivation of the unit for P1...P4 was independent of that; so then the conclusion is then that P1.unit="T(1/2)", mat.r.unit="1", and mat.M.unit="T(1/2)" (since P1=mat.M*mat.r); and the eps-binding in GenericHystTellinenEverett is just broken.
Note that this complete fixes Modelica.Magnetic.FluxTubes.Shapes.HysteresisAndMagnets.GenericHystPreisachEverett; where eps is just a fixed constant.

Someone really need to look up the original models - to me the most likely way to solve that is that the eps-binding equation is wrong in some way; likely that it seemed logical to relate the eps to mat.M and it wasn't considered in detail.

Also note that (1-mat.r) will change sign if mat.r passes through 1, and Modelica.Magnetic.FluxTubes.Material.HysteresisEverettParameter.Vacodur50 has mat.r>1; I don't know the significance of that.

@christiankral
Copy link
Contributor

Someone really need to look up the original models - to me the most likely way to solve that is that the eps-binding equation is wrong in some way; likely that it seemed logical to relate the eps to mat.M and it wasn't considered in detail.

I would guess the quantity eps is solely used to numericall stabilize the model. Most likely, there is no physical reason to have it.

@HansOlsson
Copy link
Contributor Author

Someone really need to look up the original models - to me the most likely way to solve that is that the eps-binding equation is wrong in some way; likely that it seemed logical to relate the eps to mat.M and it wasn't considered in detail.

I would guess the quantity eps is solely used to numericall stabilize the model. Most likely, there is no physical reason to have it.

Seems that way; I tried some simple experiment, and it seemed the result was fairly unchanged even if eps was changed by an order of magnitude.

@HansOlsson
Copy link
Contributor Author

I have now updated to mat.r.unit="1" and changed eps to a unit-consistent value.

@christiankral
Copy link
Contributor

In order to somehow understand the physics behind the equations

  hystR = -Js + (P1*P2-P3*P4) + mu0*Hstat - eps/2;
  hystF =  Js + (P4*P2-P3*P1) + mu0*Hstat + eps/2;

we need know the literature source. From what ist listed in Modelica.Magnetic.FluxTubes.UsersGuide.Literature I cannot find any source which uses the variables P1, P2, P3, P4.

I guess the first step where to identify the literature reference, on which the implemented equations are based.

So far I could only identify the variable P1 in [Ma03]:

image

This does not indicate what unit P1 is as it is not clear what unit $v_1$ has:

image

@christiankral
Copy link
Contributor

I wonder if @ThomasBoedrich could give some input here.

@AHaumer
Copy link
Contributor

AHaumer commented Oct 12, 2024

This solution is weird: Units like T^(-1/2) bare physical meaning.
I think the only way to cure this part of Modelica.Magnetic is a major redesign:

  • Search for all relevant pubilcations and formulas. If necessary, ask @ThomasBoedrich .
  • Formulate the equations with dimensionless variables, i.e.
    r=(B/Bref)^(-1/2)
    This is the clean solution for such equations. However, this is a considerable amount of work.
    But we should stop curing single occurences of variables and parameters with weird units.
    @casella @christiankral What is your opinion?

@HansOlsson
Copy link
Contributor Author

This solution is weird: Units like T^(-1/2) bare physical meaning.

I agree that it is somewhat odd. However, it is now T^(1/2) instead of T^(-1/2) and the logic is that we have:

P1= mat.M*...
P2=mat.M*...
P3=mat.M*...
P4=mat.M*...
hystR = -Js + (P1*P2-P3*P4)+...

So basically Js and mat.M^2 have the same unit "T".

But I have no idea if that formula is correct, and why one would have mat.M as the parameter, or if it should be something else like hystR = -Js + Js*(P1*P2-P3*P4)+... (but then the same error in two other models).

I think the only way to cure this part of Modelica.Magnetic is a major redesign:

  • Search for all relevant pubilcations and formulas. If necessary, ask @ThomasBoedrich .

Agreed. The really confusing part is that this model references Ya89, which isn't even listed (but it could the paper from the same year by Y& others.)

  • Formulate the equations with dimensionless variables, i.e.
    r=(B/Bref)^(-1/2)
    This is the clean solution for such equations. However, this is a considerable amount of work.

That is a valid approach, but I'm not sure it is ideal. One downside is that as soon as you have constructed dimensionless variables there is no unit-checking of the formula. (See also below.)

But we should stop curing single occurences of variables and parameters with weird units.

I agree, but in this case the benefit is that we remove the unitT, which just randomly changes the unit of the equation to silence the check.

Note that we have to differentiate between using Bref and unitT; the idea with dimensionless variables is that one computes a Bref based on other model-variables, based on Buckingham π theorem - whereas unitT is just a hack to make it dimensionless.

I'm getting more and more suspicious about those factors, except for well-defined cases like s-parametrization.

@casella @christiankral What is your opinion?

@HansOlsson
Copy link
Contributor Author

This solution is weird: Units like T^(-1/2) bare physical meaning.

I agree that it is somewhat odd. However, it is now T^(1/2) instead of T^(-1/2) and the logic is that we have:

P1= mat.M*...
P2=mat.M*...
P3=mat.M*...
P4=mat.M*...
hystR = -Js + (P1*P2-P3*P4)+...

So basically Js and mat.M^2 have the same unit "T".

But I have no idea if that formula is correct, and why one would have mat.M as the parameter, or if it should be something else like hystR = -Js + Js*(P1*P2-P3*P4)+... (but then the same error in two other models).

Thinking more it could also be that P2 and P4 shouldn't have a factor mat.M in them, and then M would have unit "T" (since the default mat.M is close to 1 it has little impact). But all of those changes require that someone finds the references.

@christiankral
Copy link
Contributor

This solution is weird: Units like T^(-1/2) bare physical meaning.

  • Formulate the equations with dimensionless variables, i.e.
    r=(B/Bref)^(-1/2)
    This is the clean solution for such equations. However, this is a considerable amount of work.

I am very unhappy with the units T^(1/2) as they lack any physical reason. However, I think will not have a really good and sound solution anytime soon. Consequently, the unitless equation is still the "best" solution to me, or the least eval.

@HansOlsson
Copy link
Contributor Author

HansOlsson commented Jun 26, 2025

This solution is weird: Units like T^(-1/2) bare physical meaning.

  • Formulate the equations with dimensionless variables, i.e.
    r=(B/Bref)^(-1/2)
    This is the clean solution for such equations. However, this is a considerable amount of work.

I am very unhappy with the units T^(1/2) as they lack any physical reason. However, I think will not have a really good and sound solution anytime soon. Consequently, the unitless equation is still the "best" solution to me, or the least eval.

I can understand that we just keep the model broken if we cannot find a solution.
Above it seemed as if there was some change that at least made one model better - even if it didn't fix the rest; will check that.

To me this has shown that:

  • Unit-checking can help in detecting errors, but correcting them in a good way requires a lot more. Multiplying by unit-X terms (as was done in this model) is plain harmful, similarly as adding all mispellings to the spell-checker to avoid the red squiggly marks.
  • We need to improve the quality of some packages; like this one; or consider making them obsolete.

Note that there are square-root-units in some applications, e.g., the spice-parameter gamma - #4377 - but likely not for this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L: Magnetic.FluxTubes Issue addresses Modelica.Magnetic.FluxTubes requires Modelica 3.7 Issue that requires Modelica Language Specification 3.7

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants