Message Boards Message Boards

0
|
1550 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Given the value of error, inverse the value of dt

Posted 11 months ago

Firstly I assume dt=0.00006 is known and use the following code to draw the curve of il.

{r = 22, l = 2 10^-1, c = 1 10^-4, vi = 24, initvalueil = 0, 
  initvaluevc = 0, tstart = 0, tend = 0.08, dt = 0.00006};
\[CapitalDelta]vi = 0;
A = {{0, -1/l}, {1/c, -1/(r c)}};
G = Inverse[A];
B = {1/l, 0};
S1 = Inverse[DiagonalMatrix[{1, 1}] - dt*A + 1/2*dt*dt*A . A];
S2 = Inverse[DiagonalMatrix[{1, 1}] - dt*A];
STAR1 = S1 . G . (B*vi + G . B*\[CapitalDelta]vi/dt) - 
   G . (B*(vi + \[CapitalDelta]vi) + G . B*\[CapitalDelta]vi/dt);
STAR2 = S2 . G . (B*vi + G . B*\[CapitalDelta]vi/dt) - 
   G . (B*(vi + \[CapitalDelta]vi) + G . B*\[CapitalDelta]vi/dt);
X0 = {0, 0};
X[t_] := 
  Simplify[(MatrixPower[S1, i] - MatrixPower[S2, i]) . 
      X0 + (DiagonalMatrix[{1, 1}] . (DiagonalMatrix[{1, 1}] - 
          MatrixPower[S1, i]) . 
        Inverse[DiagonalMatrix[{1, 1}] - S1]) . 
      STAR1 - (DiagonalMatrix[{1, 1}] . (DiagonalMatrix[{1, 1}] - 
          MatrixPower[S2, i]) . 
        Inverse[DiagonalMatrix[{1, 1}] - S2]) . STAR2] /. {i -> 
     t/dt};
il = X[t][[1]];
Plot[il, {t, 0, 0.08}, AxesLabel -> {"s", "il[t]/A"}, 
 PlotLegends -> {"dt=0.00006"}, PlotStyle -> {Red}, PlotRange -> All]
FindMaximum[il, {t, 0, 0.08}]

The obtained curve is shown in the following figure: enter image description here From the output results, we can know that the maximum value of il under the constraints of dt and t is 0.0019152.

Then I assigned the value of 0.0019152 to error and solved the value of dt using the following code, but the output result dt is not 0.00006. Why is this? If I want to make dt=0.00006, what instructions should I use or modify my code?

The code is as follows:

{r = 22, l = 2 10^-1, c = 1 10^-4, vi = 24, initvalueil = 0, 
  initvaluevc = 0, tstart = 0, tend = 0.08, limitdt = 0.0001, 
  error = 0.0019152};
\[CapitalDelta]vi = 0;
A = {{0, -1/l}, {1/c, -1/(r c)}};
G = Inverse[A];
B = {1/l, 0};
S1 = Inverse[DiagonalMatrix[{1, 1}] - dt*A + 1/2*dt*dt*A . A];
S2 = Inverse[DiagonalMatrix[{1, 1}] - dt*A];
STAR1 = S1 . G . (B*vi + G . B*\[CapitalDelta]vi/dt) - 
   G . (B*(vi + \[CapitalDelta]vi) + G . B*\[CapitalDelta]vi/dt);
STAR2 = S2 . G . (B*vi + G . B*\[CapitalDelta]vi/dt) - 
   G . (B*(vi + \[CapitalDelta]vi) + G . B*\[CapitalDelta]vi/dt);
X0 = {0, 0};
X[t_] := 
  Simplify[(MatrixPower[S1, i] - MatrixPower[S2, i]) . 
      X0 + (DiagonalMatrix[{1, 1}] . (DiagonalMatrix[{1, 1}] - 
          MatrixPower[S1, i]) . 
        Inverse[DiagonalMatrix[{1, 1}] - S1]) . 
      STAR1 - (DiagonalMatrix[{1, 1}] . (DiagonalMatrix[{1, 1}] - 
          MatrixPower[S2, i]) . 
        Inverse[DiagonalMatrix[{1, 1}] - S2]) . STAR2] /. {i -> 
     t/dt};
ilerror = X[t][[1]];
condequal = ilerror <= error;
maxil = FindMaximum[{ilerror, condequal, tstart <= t <= tend, 
   0 <= dt <= limitdt}, {t, dt}]
POSTED BY: James James
4 Replies
Posted 11 months ago

Okay, thank you!

POSTED BY: James James

With

condequal = ilerror == error;
maxil = FindMinimum[{dt, condequal, tstart <= t <= tend, 
   0 <= dt <= limitdt}, {t, dt}]
POSTED BY: Gianluca Gorni
Posted 11 months ago

I understand the reason, thank you! But how can I find the dt value corresponding to the red dot?

POSTED BY: James James

Your maximum problem has infinitely many solutions,as you can see from this:

Plot3D[Abs[ilerror], {t, tstart, tend}, {dt, 0, limitdt}, 
 PlotRange -> All, MeshFunctions -> {#3 &}, Mesh -> {{error}}, 
 MeshStyle -> Thick]

This is a plot of the solution set:

ContourPlot[
 Abs[ilerror] == error, {t, tstart, tend}, {dt, 0, limitdt}, 
 ContourShading -> None, PlotPoints -> 50, FrameLabel -> Automatic, 
 Epilog -> {PointSize[Large], 
   Point[{t, dt} /. {t -> 0.012500422011892092`, 
      dt -> 0.00006750970208346346`}], Red, 
   Point[{t, dt} /. {t -> 0.00899448, dt -> 0.00006}]}]

By some chance, FindMaximum converges to the black point in the picture. You expected to get the red point.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract