Skip to content

Commit d4e96db

Browse files
committed
Fixed logic in application of smooth strain spectrum.
1 parent c84e16e commit d4e96db

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

source/FrequencyDependentCalculator.cpp

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -76,36 +76,8 @@ bool FrequencyDependentCalculator::updateSubLayer(
7676
}
7777

7878
const QVector<double> strainFas = _motion->absFourierVel(strainTf);
79-
8079
const QVector<double> &freq = _motion->freq();
8180

82-
// Compute the mean frequency and mean strain parameters defined by Kausel and Assimaki (2002)
83-
double numer = 0;
84-
double denom = 0;
85-
double dFreq;
86-
87-
for (int i = 1; i < freq.size(); ++i) {
88-
dFreq = freq.at(i) - freq.at(i-1);
89-
numer += dFreq * (freq.at(i-1) * strainFas.at(i-1)
90-
+ freq.at(i) * strainFas.at(i)) / 2.;
91-
denom += dFreq * (strainFas.at(i-1) + strainFas.at(i)) / 2.;
92-
}
93-
94-
const double freqAvg = numer / denom;
95-
96-
double sum = 0;
97-
int offset = 1;
98-
99-
while (freq.at(offset) < freqAvg) {
100-
dFreq = freq.at(offset) - freq.at(offset-1);
101-
sum += dFreq * (strainFas.at(offset-1) + strainFas.at(offset)) / 2.;
102-
++offset;
103-
104-
Q_ASSERT(offset < freq.size());
105-
}
106-
107-
const double strainAvg = sum / freqAvg;
108-
10981
// Update the sublayer with the representative strain -- FIXME strainAvg doesn't appear to be representative
11082
_site->subLayers()[index].setStrain(strainMax, strainMax);
11183

@@ -115,6 +87,33 @@ bool FrequencyDependentCalculator::updateSubLayer(
11587
const SubLayer &sl = _site->subLayers().at(index);
11688

11789
if (_useSmoothSpectrum) {
90+
// Compute the mean frequency and mean strain parameters defined by Kausel and Assimaki (2002)
91+
double numer = 0;
92+
double denom = 0;
93+
double dFreq;
94+
95+
for (int i = 1; i < freq.size(); ++i) {
96+
dFreq = freq.at(i) - freq.at(i-1);
97+
numer += dFreq * (freq.at(i-1) * strainFas.at(i-1)
98+
+ freq.at(i) * strainFas.at(i)) / 2.;
99+
denom += dFreq * (strainFas.at(i-1) + strainFas.at(i)) / 2.;
100+
}
101+
102+
const double freqAvg = numer / denom;
103+
104+
double sum = 0;
105+
int offset = 1;
106+
107+
while (freq.at(offset) < freqAvg) {
108+
dFreq = freq.at(offset) - freq.at(offset-1);
109+
sum += dFreq * (strainFas.at(offset-1) + strainFas.at(offset)) / 2.;
110+
++offset;
111+
112+
Q_ASSERT(offset < freq.size());
113+
}
114+
115+
const double strainAvg = sum / freqAvg;
116+
118117
// Calculate model parameter using a least squares fit
119118
const int n = _nf - offset;
120119
double chisq;

0 commit comments

Comments
 (0)