MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / differentiate

Method differentiate

SRC/domain/pattern/TrapezoidalTimeSeriesIntegrator.cpp:125–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125TimeSeries*
126TrapezoidalTimeSeriesIntegrator::differentiate(TimeSeries *theSeries, double delta)
127{
128 // Check for zero time step, before dividing to get number of steps
129 if (delta <= 0.0) {
130 opserr << "TrapezoidalTimeSeriesIntegrator::differentiate() Attempting to differentiate using time step" <<
131 delta << "<= 0\n";
132 return 0;
133 }
134
135 // check a TimeSeries object was passed
136 if (theSeries == 0) {
137 opserr << "TrapezoidalTimeSeriesIntegrator::differentiate() - - no TimeSeries passed\n";
138 return 0;
139 }
140
141 // Add one to get ceiling out of type cast
142 long long numSteps = (long long)(theSeries->getDuration() / delta + 1.0);
143
144 Vector *theDif = new Vector (numSteps);
145
146 // Check that the Vector was allocated properly
147 if (theDif == 0 || theDif->Size() == 0) {
148 opserr << "TrapezoidalTimeSeriesIntegrator::differentiate() Ran out of memory allocating Vector " << endln;
149
150 if (theDif != 0)
151 delete theDif;
152
153 return 0;
154 }
155
156 double dummyTime; // Dummy variable for integrating
157 double Fi, Fj; // function values
158 double f; // derivative value
159
160 dummyTime = theSeries->getStartTime();
161
162 f = 0.0;
163
164 Fi = 0.0;
165
166 opserr<<"differentiate()\n";
167 for (long long i = 0; i < numSteps; i++, dummyTime += delta) {
168 Fj = theSeries->getFactor(dummyTime);
169
170 // Apply the trapezoidal rule to update the derivative
171 f = 2.0 * (Fj - Fi) / delta - f;
172
173 (*theDif)[i] = f;
174
175 Fi = Fj;
176 if (i < 10)
177 opserr<<"data"<<f<<" "<<Fi<<" "<<Fj<<"\n";
178 }
179
180 // Set the method return value
181 PathSeries *returnSeries = new PathSeries (0, *theDif, delta, 1.0, true, false, theSeries->getStartTime());
182 delete theDif;

Callers

nothing calls this directly

Calls 4

getDurationMethod · 0.45
SizeMethod · 0.45
getStartTimeMethod · 0.45
getFactorMethod · 0.45

Tested by

no test coverage detected