3 class RotationFrequencyVector(Base):
5 Class for analysis of rotation frequency vectors.
13 The run to analyze, as an instance of `Run`.
16 super(RotationFrequencyVector, self).
__init__(run)
21 Returns a `matplotlib.axes.Axes` object that contains a plot of the
22 rotation frequencies of star polymer, with the horizontal axis showing
23 the simulation time `t`, and the Cartesian components of the rotation
24 frequency vector, in radians per time unit.
27 import matplotlib.figure
29 figure = matplotlib.figure.Figure()
30 axes = figure.add_subplot(1, 1, 1)
35 frequencies = [[], [], []]
36 for datum
in data.values():
38 frequencies[i].append(datum[i])
40 _line, = axes.plot(data.keys(), frequencies[0])
42 legendLabels.append(
"Rotation Frequency: x Component")
44 _line, = axes.plot(data.keys(), frequencies[1])
46 legendLabels.append(
"Rotation Frequency: y Component")
48 _line, = axes.plot(data.keys(), frequencies[2])
50 legendLabels.append(
"Rotation Frequency: z Component")
52 axes.legend(lines, legendLabels)
54 axes.set_title(
"Star Polymer Rotation Frequency")
55 axes.set_xlabel(
"Simulation Time t")
56 axes.set_ylabel(
"Rotation Frequency [rad/T]")
61 def _computeValueAsFunctionOfTime(self):
63 Takes the raw simulation output, and computes the rotation frequency
64 vector as a function of time. The result is returned as an
65 `collcections.OrderedDict`.
68 from collections
import OrderedDict
70 config = self.
getRun().getConfiguration()
75 timestep = config[
"mpc.timestep"]
76 time = timestep * config[
"mpc.warmupSteps"]
81 particles = snapshots.readTimestep()
82 particles.setUniformMass(starPolymers.getParticleMass())
84 if particles.isEmpty():
87 particles.shiftToCenterOfMassFrame()
88 starPolymers.setParticles(particles)
90 ret[time] = particles.getRotationFrequencyVector()
95 def _getCacheFilename(self):
97 Returns the filename where cached data is (expected to be) saved to.
100 return "rotationFrequencies.txt"
103 def _getCacheValueInterpreter(self):
105 Returns what is to be used as the `valueInterpreter` argument to
106 `Cache.getDataOrderedDict`.
109 def valueInterpreter(string):
111 return ast.literal_eval(string)
113 return valueInterpreter