2
$\begingroup$

I am new to Mathematica and have recently been trying to investigate solar weather on power grids. I have managed to plot the power grid being studied where the vertices are substations and would like to animate the data I have (geo-electric field intensity where x = time and y = field intensity) using the manipulate function where I can use the slider option to control the time being elapsed and while I do this the value is changing within the three areas which can be seen as one of the color schemes such as temperature. Ideally after this I would like to be able to illustrate that the vertices are no longer operational after a certain time just through something as simple as starting as green and then turning red.

Here is my code so far:

cdata = {
  {0, 0}, {1, 0}, {2, 0.1}, {3, 0.18}, {4, 0.28}, {5, 0.5}, {6, 
   1.2}, {7, 1.5}, {8, 0.6}, {9, 0.25}, {10, 0.50}, {11, 0.4}, {12, 
   0.36}, {13, 0.1}, {14, 0.3}, {15, 0.2}, {16, 0.16}, {17, 
   0.05}, {18, 0.2}, {19, 0.42}, {20, 0.39}, {21, 0.2}
  }

jdata = {
  {0, 0}, {1, 0}, {2, 0.15}, {3, 0.10}, {4, 0.2}, {5, 0.16}, {6, 
   0.7}, {7, 1.4}, {8, 1}, {9, 0.38}, {10, 0.65}, {11, 0.56}, {12, 
   0.2}, {13, 0.25}, {14, 0.38}, {15, 0.22}, {16, 0.3}, {17, 
   0.22}, {18, 0.32}, {19, 0.56}, {20, 0.82}, {21, 0.46}
  }

mdata = {
  {0, 0}, {1, 0}, {2, 0.2}, {3, 0.17}, {4, 0.5}, {5, 1.37}, {6, 
   1.2}, {7, 1}, {8, 0.1} {9, 0.4}, {10, 0.61}, {11, 0.3}, {12, 
   0.19}, {13, 0.21}, {14, 0.2}, {15, 0.17}, {16, 0.2}, {17, 
   0.52}, {18, 0.3}, {19, 0.35}, {20, 0.70}, {21, 0.25}
  }

plot = Graph[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 
   17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30}, {1 <-> 2, 
   1 <-> 3, 2 <-> 3, 3 <-> 4, 4 <-> 5, 5 <-> 6, 5 <-> 7, 7 <-> 1, 
   7 <-> 4, 3 <-> 8, 4 <-> 9, 9 <-> 11, 8 <-> 9, 8 <-> 10, 10 <-> 12, 
   11 <-> 19, 11 <-> 25, 12 <-> 13, 13 <-> 14, 13 <-> 17, 14 <-> 15, 
   15 <-> 16, 16 <-> 17, 16 <-> 18, 17 <-> 10, 18 <-> 19, 19 <-> 20, 
   19 <-> 25, 20 <-> 21, 20 <-> 26, 21 <-> 22, 22 <-> 23, 23 <-> 24, 
   24 <-> 15, 24 <-> 21, 21 <-> 28, 25 <-> 26, 26 <-> 27, 28 <-> 26, 
   28 <-> 27, 27 <-> 29, 29 <-> 30}, 
  VertexCoordinates -> {{0.1645`, 0.8585`}, {0.14200000000000002`, 
     0.8345`}, {0.203`, 0.6595`}, {0.2515`, 0.66`}, {0.293`, 
     0.8275`}, {0.359`, 0.846`}, {0.23700000000000002`, 
     0.8425`}, {0.218`, 0.505`}, {0.272`, 
     0.5085000000000001`}, {0.222`, 0.358`}, {0.3595`, 
     0.4415`}, {0.244`, 0.2465`}, {0.2575`, 
     0.20450000000000002`}, {0.276`, 0.17`}, {0.302`, 
     0.178`}, {0.311`, 0.20450000000000002`}, {0.289`, 
     0.2205`}, {0.3335`, 0.226`}, {0.3965`, 
     0.28250000000000003`}, {0.41600000000000004`, 0.2995`}, {0.4315`,
      0.274`}, {0.428`, 0.24`}, {0.4045`, 0.1665`}, {0.3645`, 
     0.2245`}, {0.429`, 0.41600000000000004`}, {0.5515`, 
     0.5125`}, {0.64`, 0.5535`}, {0.5735`, 0.486`}, {0.674`, 
     0.7015`}, {0.729`, 0.8175`}}]


    cir1 = (-0.2275 + x)^2 + (-0.701 + y)^2 < 0.0484
    cir2 = (-0.6605 + x)^2 + (-0.643 + y)^2 < 0.042
    cir3 = (-0.339 + x)^2 + (-0.303 + y)^2 < 0.0324
    cirPlot = 
 RegionPlot[{cir1, cir2, cir3}, {x, 0, 1}, {y, 0, 1}, Frame -> False]
Show[cirPlot, plot]

*substation failures*
  @t = 3 : {1, 2, 6, 12, 13, 17, 18, 19, 21, 23, 25, 26, 27, 28}
@t = 4 : {1, 2, 3, 6, 8, 12, 13, 17, 18, 19, 21, 23, 25, 26, 27, 28, 
   29, 30}
@t = 5 : {1, 2, 3, 6, 8, 9, 12, 13, 14, 17, 18, 19, 21, 22, 23, 24, 
   25, 26, 27, 28, 29, 30}
@t = 6 : {1, 2, 3, 6, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
    22, 23, 24, 25, 26, 27, 28, 29, 30}

The plot so far with the three areas indicated by the circles

I have thought of using the contour plot function to represent my data but I'm unsure which function to use for this. Any help with this task would be much appreciated!

$\endgroup$
2
  • 1
    $\begingroup$ How should we interpret cdata, jdata, mdata? Where is the data for your field? $\endgroup$
    – MarcoB
    Apr 21, 2022 at 18:47
  • $\begingroup$ My apologies mdata is the field data for circle 1(cir1), cdata is the field data for circle 2 (cir2), jdata is the field data for circle 3 (cir3) $\endgroup$
    – Kadooble
    Apr 21, 2022 at 19:08

2 Answers 2

5
$\begingroup$

With your definitions, try the following, either with Animate or with Manipulate:

(* Extract intensity data as a function of time *)
{c1Intensity, c2Intensity, c3Intensity} = 
 Rescale[#[[All, 2]], {0, 1.5}] & /@ {cdata, jdata, mdata}

Animate[
 Show[
   plot,
   Graphics[{
     Opacity[0.3],
     Blend[{Blue, Red}, c1Intensity[[t + 1]]], Disk[{0.2275, 0.701}, [email protected]],
     Blend[{Blue, Red}, c2Intensity[[t + 1]]], Disk[{0.6605, 0.643}, [email protected]],
     Blend[{Blue, Red}, c3Intensity[[t + 1]]], Disk[{0.3390, 0.303}, [email protected]]
   }]
 ],
 {t, 0, 20, 1}
]

In the above, I used simple Graphics objects to represent your circles, rather than using the much slower RegionPlot.

animation from the plot above

$\endgroup$
4
  • $\begingroup$ This is great thank you! By any chance would you know how to edit the nature of the vertices? For example, having them all start as green and after a certain time has passed have them change to red? $\endgroup$
    – Kadooble
    Apr 21, 2022 at 21:13
  • $\begingroup$ @Kadooble Would the time be different for each vertex? Or would they all change color at the same time? Do you have a list of the times? Since it's a pretty different request, it may be more appropriate for another question. $\endgroup$
    – MarcoB
    Apr 21, 2022 at 22:19
  • $\begingroup$ I meant to edit the original code but instead managed to edit your reply with the substation failure times. I will probably follow your advice and ask a separate question if this is more complex than I imagined. I would eventually like to make a more general case for the substations for example they trip after a certain value is exceeded. $\endgroup$
    – Kadooble
    Apr 22, 2022 at 2:05
  • $\begingroup$ @Kadooble Feel free to edit the info into your original post if you'd like, but I think you may be more successful with a new question. $\endgroup$
    – MarcoB
    Apr 22, 2022 at 2:17
3
$\begingroup$

Define vertex failures:

fail[_?(# < 3 &)] := {};
fail[3] = {1, 2, 6, 12, 13, 17, 18, 19, 21, 23, 25, 26, 27, 28};
fail[4] = {1, 2, 3, 6, 8, 12, 13, 17, 18, 19, 21, 23, 25, 26, 27, 28, 
   29, 30};
fail[5] = {1, 2, 3, 6, 8, 9, 12, 13, 14, 17, 18, 19, 21, 22, 23, 24, 
   25, 26, 27, 28, 29, 30};
fail[_?(# >= 6 &)] := {1, 2, 3, 6, 7, 8, 9, 12, 13, 14, 15, 16, 17, 
   18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30};

Interpolation functions for intensities:

intf = Interpolation[#, InterpolationOrder -> 1] & /@ {cdata, jdata, 
    mdata};

cirles = 
  Disk[#, Sqrt@#2] & @@@ {{{0.2275, 0.701}, 
     0.0484}, {{0.6605, 0.643}, 0.042}, {{0.3390, 0.303}, 0.0324}};

Manipulate:

Manipulate[
 Show[{Graphics[{Opacity[.2], Thread[{Hue[#[t]] & /@ intf, cirles}]}],
    Graph[plot, 
    VertexStyle -> {Green, 
      x_ /; MemberQ[fail[Floor[t]], x] -> Red}]}], {t, 0, 21}]
$\endgroup$

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.