3 class OrientationAngles(Base):
5 Class for analysis of the orientation of the eigenvectors of the gyration
6 tensor, relative to the flow direction.
14 The run to analyze, as an instance of `Run`.
22 Returns a `matplotlib.axes.Axes` object that contains a plot of the
23 orientation angles of the three eigenvectors of the gyration tensor with
24 the flow direction, with the horizontal axis showing the simulation
25 time `t`, and the vertical axis showing the angles in radians.
28 import matplotlib.figure
30 figure = matplotlib.figure.Figure()
31 axes = figure.add_subplot(1, 1, 1)
37 for datum
in data.values():
39 angles[i].append(datum[i][1])
41 _line, = axes.plot(data.keys(), angles[0])
43 legendLabels.append(
"Orientation Angle: Smallest Eigenvalue")
45 _line, = axes.plot(data.keys(), angles[1])
47 legendLabels.append(
"Orientation Angle: Middle Eigenvalue")
49 _line, = axes.plot(data.keys(), angles[2])
51 legendLabels.append(
"Orientation Angle: Largest Eigenvalue")
53 axes.legend(lines, legendLabels)
55 axes.set_title(
"Star Polymer Orientation Angles")
56 axes.set_xlabel(
"Simulation Time t")
57 axes.set_ylabel(
"Orientation Angles [rad]")
62 def _computeValueAsFunctionOfTime(self):
64 Takes the raw simulation output, and computes the orientation angles as
65 a function of time. The result is returned as an
66 `collcections.OrderedDict`.
69 from collections
import OrderedDict
71 config = self.
getRun().getConfiguration()
76 timestep = config[
"mpc.timestep"]
77 time = timestep * config[
"mpc.warmupSteps"]
82 particles = snapshots.readTimestep()
83 particles.setUniformMass(starPolymers.getParticleMass())
85 if particles.isEmpty():
88 particles.shiftToCenterOfMassFrame()
89 starPolymers.setParticles(particles)
96 def _getCacheFilename(self):
98 Returns the filename where cached data is (expected to be) saved to.
101 return "orientationAngles.txt"
104 def _getCacheMetadata(self):
106 Returns the cache metadata.
113 "cacheVersion": cacheVersion,
119 def _getCacheValueInterpreter(self):
121 Returns what is to be used as the `valueInterpreter` argument to
122 `Cache.getDataOrderedDict`.
125 def valueInterpreter(string):
127 return ast.literal_eval(string)
129 return valueInterpreter
132 def _getFlowDirection(self):
134 Returns the flow direction of shear flow.
137 return [1.0, 0.0, 0.0]