3 class MagneticClusterCount(Base):
5 Class for analysis of the number of magnetic clusters in a star polymer.
13 The run to analyze, as an instance of `Run`.
16 super(MagneticClusterCount, self).
__init__(run)
21 Returns a `matplotlib.axes.Axes` object that contains a plot of the
22 number of magnetic clusters, with the horizontal axis showing the
23 simulation time `t`, and the vertical axis showing the cluster count.
26 import matplotlib.figure
28 figure = matplotlib.figure.Figure()
29 axes = figure.add_subplot(1, 1, 1)
34 _line, = axes.plot(data.keys(), data.values())
36 legendLabels.append(
"Magnetic Cluster Count")
38 axes.legend(lines, legendLabels)
40 axes.set_title(
"Magnetic Cluster Count")
41 axes.set_xlabel(
"Simulation Time t")
42 axes.set_ylabel(
"Magnetic Cluster Count")
47 def _computeValueAsFunctionOfTime(self):
49 Takes the raw simulation output, and computes the magnetic cluster count
50 as a function of time. The result is returned as an
51 `collcections.OrderedDict`.
54 from collections
import OrderedDict
56 config = self.
getRun().getConfiguration()
61 timestep = config[
"mpc.timestep"]
62 time = timestep * config[
"mpc.warmupSteps"]
64 lastTimestepAnalyzed = -9e9
68 particles = snapshots.readTimestep()
72 lastTimestepAnalyzed = time
75 if particles.isEmpty():
78 starPolymers.setParticles(particles)
81 starPolymers.getMagneticClusterCount(
87 def _getCacheFilename(self):
89 Returns the filename where cached data is (expected to be) saved to.
92 return "magneticClusterCount.txt"
95 def _getCacheMetadata(self):
97 Returns the cache metadata.
104 "cacheVersion": cacheVersion,
105 "magneticClusterMaxDistance":
112 def _getMagneticClusterMaxDistance(self):
114 Returns the maximum distance that two particles may be apart and still
115 be considered to be part of the same magnetic cluster.
121 def _getAnalysisTimestep(self):
123 Returns the timestep between to analysis points.