1
$\begingroup$

I am trying to simulate Jiles Atherton model with my experimental data,but I am not able to combine the simulated one with experimental one. I am getting the error "could not combine the graphics objects in show"

Below is the code used .Really appreciate any assistance

dataInput = Import["C:\\Users\\Lenovo\\Desktop\\JA.TEST.DAT"];
data = dataInput[[All, {1, 2}]]
p2 = ListLinePlot[data, PlotStyle -> Blue, 
  PlotRange -> {{-7000, 7000}, {-1, 1}}]

\[Mu]0 = 4 \[Pi] 10^-7;
 \[Omega] = 2 \[Pi] (1);
Man[t_] := 
 Ms (Coth[(H[t] + \[Alpha] M[t])/a] - a/(H[t] + \[Alpha] M[t]))
\[Delta]M[t_] = 
 1 - UnitStep[-H'[t]] UnitStep[Man[t] - M[t]] - 
  UnitStep[H'[t]] UnitStep[M[t] - Man[t]]; 
H[t_] := 7000 Sin[\[Omega] t]
\[Delta][t_] := Sign[H'[t]]
solns = ParametricNDSolveValue[{Block[{Ms, c, a, k, \[Alpha]}, 
     M'[t] == (\[Delta]M[t] (Man[t] - M[t]) H'[t] + 
         c k \[Delta][t] Man'[t])/(k \[Delta][t] - \[Alpha] \[Delta]M[
           t] (Man[t] - M[t]))], M[10^-3] == 0}, 
   M, {t, 0, 5}, {Ms, c, a, k, \[Alpha]}, 
   Method -> {"EquationSimplification" -> "Residual"}];
p1 = Manipulate[
  ParametricPlot[{H[t], 10^-6 solns[Ms, c, a, k, \[Alpha]][t]}, {t, 0,
     1.3}, AxesLabel -> {Row[{Style["H", Italic], " (A/m)"}], 
     Row[{Style["B", Italic], " (T)"}]}, LabelStyle -> {15}, 
   PlotRange -> {{-7000, 7000}, {-1, 1}}, PlotStyle -> Black, 
   AspectRatio -> 1, ImageSize -> 1.125 {400, 400}],
  Row[{"saturation magnetization ", 
    Subscript[Style["M", Italic], "s"], " (A/m)"}],
  {{Ms, 1. 10^6, "" }, 0.5 10^6, 1.1 10^6, Appearance -> "Labeled", 
   ImageSize -> Tiny}, "",
  Row[{"magnetization reversibility ", Style["c", Italic]}],
  {{c, 1/5.5, ""}, 1/30, 1, Appearance -> "Labeled", 
   ImageSize -> Tiny}, "",
  Row[{"domain wall density ", Style["a", Italic], " (A/m)"}],
  {{a, 1800, ""}, 1000, 2300, Appearance -> "Labeled", 
   ImageSize -> Tiny}, "",
  Row[{"average energy to \nbreak pinning site ", Style["k", Italic], 
    " (A/m)"}],
  {{k, 2000, ""}, 1000, 2500, Appearance -> "Labeled", 
   ImageSize -> Tiny}, "",
  "interdomain coupling \[Alpha] ",
  {{\[Alpha], 2.1 10^-3, ""}, 1.1 10^-3, 5.1 10^-3, 
   Appearance -> "Labeled", ImageSize -> Tiny},
  ContinuousAction -> False, SaveDefinitions -> True, 
  ControlPlacement -> Left]
Manipulate[Show[p1, p2], PlotRange -> Automatic]
$\endgroup$
2
  • 2
    $\begingroup$ Your code currently pulls data from your hard drive. We can't access it. Please supply some accessible data set or some way to generate a data set for the purposes of running this code. $\endgroup$
    – Jagra
    Commented Jul 5, 2022 at 13:42
  • 1
    $\begingroup$ Your last line of code Manipulate[Show[p1, p2], PlotRange -> Automatic] does not conform to a Manipulate. It specifies no controls. PlotRange -> Automatic is not a option for Manipulate. Not clear what you want to do. $\endgroup$
    – Jagra
    Commented Jul 5, 2022 at 13:55

1 Answer 1

2
$\begingroup$

As your link in the comment does not give a clear direction to access your data, I offer the following as a structural approach to what I think you want to achieve.

 \[Mu]0 = 4 \[Pi] 10^-7;
    \[Omega] = 2 \[Pi] (1);
    Man[t_] := 
     Ms (Coth[(H[t] + \[Alpha] M[t])/a] - 
        a/(H[t] + \[Alpha] M[t])); \[Delta]M[t_] = 
     1 - UnitStep[-H'[t]] UnitStep[Man[t] - M[t]] - 
      UnitStep[H'[t]] UnitStep[M[t] - Man[t]]; 
    H[t_] := 7000 Sin[\[Omega] t]; \[Delta][t_] := Sign[H'[t]];
    solns = ParametricNDSolveValue[{Block[{Ms, c, a, k, \[Alpha]}, 
         M'[t] == (\[Delta]M[t] (Man[t] - M[t]) H'[t] + 
             c k \[Delta][t] Man'[t])/(k \[Delta][t] - \[Alpha] \[Delta]M[
               t] (Man[t] - M[t]))], M[10^-3] == 0}, 
       M, {t, 0, 5}, {Ms, c, a, k, \[Alpha]}, 
       Method -> {"EquationSimplification" -> "Residual"}];

   dataInput = Import["C:\\Users\\Lenovo\\Desktop\\JA.TEST.DAT"];
   data = dataInput[[All, {1, 2}]];
    
    Manipulate[
     Show[
      ParametricPlot[{H[t], 10^-6 solns[Ms, c, a, k, \[Alpha]][t]}, {t, 0,
         1.3},
       AxesLabel -> {Row[{Style["H", Italic], " (A/m)"}], 
         Row[{Style["B", Italic], " (T)"}]},
       LabelStyle -> {15},
       PlotRange -> {{-7000, 7000}, {-1, 1}},
       PlotStyle -> Black,
       AspectRatio -> 1,
       ImageSize -> 1.125 {400, 400}],
      
      ListLinePlot[data, PlotStyle -> Blue, 
         PlotRange -> {{-7000, 7000}, {-1, 1}}]
  
      ],
     Row[{"saturation magnetization ",
       Subscript[Style["M", Italic], "s"], " (A/m)"}], {{Ms, 1. 10^6, ""},
       0.5 10^6, 1.1 10^6,
      Appearance -> "Labeled",
      ImageSize -> Tiny}, "",
     Row[{"magnetization reversibility ",
       Style["c", Italic]}], {{c, 1/5.5, ""}, 1/30, 1,
      Appearance -> "Labeled",
      ImageSize -> Tiny}, "",
     Row[{"domain wall density ",
       Style["a", Italic], " (A/m)"}], {{a, 1800, ""}, 1000, 2300,
      Appearance -> "Labeled",
      ImageSize -> Tiny}, "",
     Row[{"average energy to \nbreak pinning site ", Style["k", Italic], 
       " (A/m)"}], {{k, 2000, ""}, 1000, 2500,
      Appearance -> "Labeled",
      ImageSize -> 
       Tiny}, "", "interdomain coupling \[Alpha] ", {{\[Alpha], 2.1 10^-3,
        ""}, 1.1 10^-3, 5.1 10^-3,
      Appearance -> "Labeled",
      ImageSize -> Tiny},
     ContinuousAction -> False,
     SaveDefinitions -> True,
     ControlPlacement -> Left]

The above code sets your variables and defines functions the code later uses then retrieves your experimental data.

A Manipulate follows. The Manipulate manilpulates a Show. The Show has two plots, corresponding to your original p1 & p2.

$\endgroup$
1
  • $\begingroup$ Sorry I shared the wrong folder for data .This code worked and this is what I was looking for. Thank you so much....! $\endgroup$ Commented Jul 5, 2022 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.