Skip to main content
added 162 characters in body
Source Link
Steve
  • 1.2k
  • 7
  • 18

Example output, by exchanging ListAnimate here for Show.

enter image description here

Example output, by exchanging ListAnimate here for Show.

enter image description here

Source Link
Steve
  • 1.2k
  • 7
  • 18

I want to give a big thanks to user bbgodfrey for the elegant solution to the problem posed.

However, for variety and extension, I'm posting this answer in addition. Basically, I modified his/her solution by

  1. exchanging Append to Join in spectrum definition
  2. exchanging Map,Extract to Part in what would be the definition of eig
  3. forgoing definition of eig in favor of building that functionality into the ListContourPlot
  4. exchanging Show, Apply to Show, Table in the ListContourPlot
  5. including plotting qualities in the function

The majority of these changes are aesthetic, simply because I don't have a lot of experience coding with Map and Apply, so they aren't intuitive. The last point is a simple extension that is beyond the scope of the question I posed here but I include only for other interested readers.

Block[{dim = 4, grain = 250, matrix, domain, range, cuts, spectrum, colors},
matrix = DiagonalMatrix[Table[Sqrt[(x + 1/2 - (1 + Exp[-(i - 1)])^(-1))^2 + (y (1 + Exp[-2 (i - 1)])^(-1))^2], {i, 1, dim}]];
domain = Flatten[Table[{x, y}, {x, -1, 1, 2./(grain - 1)}, {y, -1, 1,2./(grain - 1)}], 1];  
range = Range[0, 0.15, 0.15/(cuts - 1)];  
spectrum = Table[Join[\[Sigma],Sort@Re@Eigenvalues[ReplaceAll[matrix, {x -> \[Sigma][[1]],y -> \[Sigma][[2]]}]]], {\[Sigma], domain}];
  
discreteConPlot[energy_, quality_] := Show@Table[
ListContourPlot[spectrum[[All, {1, 2, \[Sigma] + 2}]], 
 ContourStyle -> {quality[[1]], Thickness[quality[[2]]]}, 
 InterpolationOrder -> quality[[3]], ImageSize -> quality[[4]], 
 Contours -> {energy}, ContourShading -> None, 
 PlotRange -> {{-0.2, 0.6}, {-0.4, 0.4}}], {\[Sigma], 1, dim}];

colors = Table[Hue[\[Sigma], 1, 0.7], {\[Sigma], Range[0, 0.8, 0.8/(cuts -1)]}];

ListAnimate[
Table[discreteConPlot[range[[s]], {colors[[s]], 0.005, 1, 400}], {s,1, Length@range}]
, AnimationRunning -> False]

]  

This block produces cuts-many contours across the range of values chosen, with a hue-spread across Hue[0,1,0.7] to Hue[0.8,1,0.7] and other qualities that can be adjusted readily.

Several of the Table throughout this algorithm can likely be improved by Parallelization but the optimal choice may depend on the user's machine and the size of dim and grain, amongst others.