Sep 16, 2022 10:26
@AlexTrounev Hello. I did not have much time this week to put in this topic, but I could change the PDE and make it "run" unfortunately I still have some problems, because the results are not as expected. Do you want to have a look at it? Shall I open a new question for this, or shall I append it to the question here?
Sep 8, 2022 16:52
Hello xzczd and thank you also for joining. @AlexTrounev I will try to implement this. It would be interesting if this solution will be more efficient/accurate or not
Sep 8, 2022 15:57
How would you define the problem with the scalar potential? How do we bring the direction of the magnetization information into a scalar form?
Sep 8, 2022 15:12
Nice to know :-) So I guess we will continue this discussion in english. We try to figure out 2 Problems:

Problem number 1. Is the chosen DEQ suitable for that type of Problems, or does it have any drawbacks that we are not aware of. We saw, that for example Comsol multiphysics chooses another Deq https://www.comsol.com/model/download/891901/models.acdc.permanent_magnet.pdf My course about theoretical Electrodynamics was some time ago, and I am not an expert in that field

Second problem is the way, The vector field of magnetization is handled by Curl[]. While it is formally correct that t
Sep 8, 2022 14:38
As I see, Alex followed our invitation. Welcome and thank you very much for joining :-)
Sep 8, 2022 14:37
I contacted both of them. Lets see if they answer. Today I could not work on this topic. But I will continue the next days. As I am not as deep within the internal algorithms as a developer I don't know if my approaches will be from high value. If you have any suggestions how I should continue, feel free to tell me. Is it worth trying to access NDSolve via Debuger of Wolfram Workbench?
Sep 8, 2022 10:21
Do you have any Idea how I can invite them? The only way I see at the moment is posting the link in one of there answers ...
Sep 8, 2022 08:46
At least now I understand, why you know the undocumented Features that well :-)
Sep 8, 2022 08:36
No way :-), I am from germany too ... I did not know, that you can work for Wolfram Research from Germany
Sep 7, 2022 15:22
Depends on the point of view ... From Physics point of view I am not aware of a formulation of my problem, where I could utilize this construct. Although I must admit, that there are many ways to adapt the Maxwell equations in order to fit the needs of a specific simulation and I do not know them in detail.
From a Mathematica User Point of view it would be interesting if this behavior occcurs with other types of PDEs to. I dont think that the field of a permanent magnet is the only problem where a field defined by constants over different mesh regions is used. Also I why it is not affecting
Sep 7, 2022 13:33
U are right, thats way faster :-) The UnitStep Appro comes from an answer of xzczd to this Question: mathematica.stackexchange.com/questions/230282/… He writes: "The simplest solution is to approximate the piecewise constant with a continuous function:" For me the following happens: Easy Geometrie conditions will be translated to piecewise functions. Those in return can bet transformed to a function of f[x,y,z] using PiecewiseExpand. The Appro is only used to remove the Delta functions that are brought in by that, because They may disturbe NDSolve[]
Sep 7, 2022 13:33
Your answer brings the improvement, that we can get rid of the additional regions as well. Overall this feels much less hacky than before ...
Sep 7, 2022 13:33
Yes. This function is faster. I adapted the code in my answer accordingly. Anyway I could not implement it in the way you did, because I got an error, that EvaluateOnElementMesh does not evaluate to an scalar.
 
Jan 18, 2017 13:17
Ok I will do so.
Jan 18, 2017 13:12
Ok, after rechecking everything I will do. I also will definitely mention you. Is there a special way to do that? As I am new here to stack overflow I am not familiar with the "best practices" here.
Jan 18, 2017 12:49
I am still verifiying if everything works the way I expected, but until know it looks quite good.
Jan 18, 2017 12:48
But with your approach you can take the flyback diode into account in various ways. My "simple solution" works and I was even able to implement the flyback diode by generating an interpolated function using values from a real diode.
Jan 18, 2017 12:15
@xzczd Will you post your idea, as an answer or shall I do that for you?
@andre How do you get access to NGSpice from Mathematica? The approach sounds interesting for future problems.
Jan 16, 2017 10:10
I will try to verify the values, with an experiment during the next days. Hopefully this approach is suitable, for my later tasks optimizing the system automatically.
Jan 16, 2017 10:06
@all: these new ideas are amazing. @xzczd I never thought about that approach until now, but the results are very good. I can spread all values in a much broader range now, while the calculation itself is also faster.
Jan 16, 2017 10:03
@andre
Jan 13, 2017 21:15
That there is no guarantee I know. Otherwise it would not be science :-D
Jan 13, 2017 21:14
I also tried options of NDSolve ... but I got a rather odd message, that different methods are not yet implemented.
Jan 13, 2017 20:35
So do you agree, when I say: It is more suitable to blew up the function for signal generation in a way to avoid discontinuities?
Jan 13, 2017 20:29
From what you tell me I estimate, that the discontinuities are a main problem for the numerical evaluation, thats why the more sophisticated models don't fail. In view of the exponential function my feeling agrees with that.
Jan 13, 2017 20:24
Oh I have time we can do this in the way you prefer it. I always like to learn :-)
Jan 13, 2017 20:09
I understand what you are saying. I also can try to change the Signal in a way that there is no discontinuity anymore, the fact why I did not try it until now is, that the function for the PWM Signal is already complex and without diode this worked well. I try always a simple approach first and expand it when I see, I run into problems.
Jan 13, 2017 19:46
But the short explenation makes sense to me ...
Jan 13, 2017 19:36
I do my best :-)
Jan 13, 2017 19:35
Yes this is definitely a point I have to face. But I am sure there Is a way around, as PSpice and so on, also find a way for that.
Jan 13, 2017 19:28
That makes sense. One question: You set this inital condition i[0] == -1/2*10^-14 . What is the reason you dont set it to zero?
Jan 13, 2017 19:17
That would be good for me, because that would mean I only have to take care about the second one.
Jan 13, 2017 19:16
Ok, so you suggest, that we should see the error message more like a warning
Jan 13, 2017 19:08
The second one looks like, I could compensate it by scaling the values. Possibly I could do this in a way, that It works automatically, but the first one I dont understand yet.
Jan 13, 2017 19:04
Then I get
NDSolveValue::nderr: Error test failure at t == 1.0000000000000016`; unable to continue.
Jan 13, 2017 19:04
The second problem you get when you take the initial code and change the l to 0.001
Jan 13, 2017 18:59
the other one I try to reproduce now
Jan 13, 2017 18:58
This is one of the problems I ran into during my day of testing this type of solution.
Jan 13, 2017 18:56
Yes I have the same
Jan 13, 2017 18:53
NDSolveValue::ssres: NDSolve has computed values that give a zero residual for the differential-algebraic system, but some components are different from those specified.
Jan 13, 2017 18:52
No problem :-) If you take my code and change uPWM to 12 you run into the first problem.
Jan 13, 2017 17:43
Here is one example. It works like this. Unfortunately it is not numerically stable.
Jan 13, 2017 17:43
timeStart = 0;
timeEnd = 15;

r = 0.1;
l = 1;


uPWM = 1;
PWMFreq = 1;
PulseDuration = 10;
uPart[t_, PulseDuration_] :=
Piecewise[{{Sin[\[Pi]*t/PulseDuration], 0 <= t <= PulseDuration}}, 0]

u[t_, PWMFreq_, PulseDuration_] :=
If[Mod[t, 1/PWMFreq] > uPart[t, PulseDuration], 0, uPWM]

Plot[u[t, PWMFreq, PulseDuration], {t, timeStart, timeEnd},
Exclusions -> None, ImageSize -> Large]

res = NDSolveValue[{l i'[t] ==
u[t, PWMFreq, PulseDuration] -
r i[t] - (i[t] - 10^-14 Exp[vdiode[t]/0.025]) ,
vdiode[t] + l i'[t] + r i[t] == 0, vdiode[0] == 0,
Jan 13, 2017 17:43
I made a simplification where I took out the rswitch. Then I added my PWM Signal
Jan 13, 2017 16:22
Unfortunately I dont have my source code with me over the weekend, so I will need some time to write a the small part again here on my laptop ...
Jan 13, 2017 16:19
This is the first Problem I have to counter fully numerically, usually I try to solve as much as possible in an analytical way. Anyway to my mind you solution works well. The problems I run in have (to my mind) numerical reasons.
Jan 13, 2017 16:15
I am aware of the spice family and use it as a reference to proof my results. Nevertheless I want to stick to Mathematica due to the following reason: The solution of this problem will be part of a bigger toolchain I have developed within the las year. I am currently optimizing elektromechanical systems and I need the algorithms of Mathematica to run this calculations (We could not implement them in Spice).
Jan 13, 2017 16:15
Hello andre. Thank you again for your help. To my background I studied physics and now I am working for a company, where my task is to solve problems from different fields, such as mechanics (static and dynamic) and now the electronics we have here.