Skip to content
This repository has been archived by the owner on Jul 15, 2018. It is now read-only.

Commit

Permalink
Refactoring face force calculations for time to be matched
Browse files Browse the repository at this point in the history
  • Loading branch information
markhalonen committed Jul 10, 2017
1 parent 28de06f commit f560d8b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
47 changes: 46 additions & 1 deletion src/net/relinc/libraries/sample/HopkinsonBarSample.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package net.relinc.libraries.sample;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import net.relinc.libraries.data.DataFile;
import net.relinc.libraries.data.DataLocation;
import net.relinc.libraries.data.DataSubset;
import net.relinc.libraries.data.Descriptor;
import net.relinc.libraries.data.DescriptorDictionary;
import net.relinc.libraries.data.IncidentPulse;
import net.relinc.libraries.data.ReflectedPulse;
import net.relinc.libraries.data.TransmissionPulse;
import net.relinc.libraries.staticClasses.Converter;
import net.relinc.libraries.staticClasses.SPOperations;
import net.relinc.libraries.staticClasses.SPSettings;
Expand Down Expand Up @@ -97,6 +102,35 @@ public double[] getEngineeringStrainFromIncidentBarReflectedPulseStrain(double[]
return strain;
}

public Map<String, double[]> getFrontFaceForceInterpolated()
{
ReflectedPulse reflectedPulse = null;//(ReflectedPulse) getCurrentDisplacementDatasubset();
IncidentPulse incidentPulse = null;
try{
reflectedPulse = (ReflectedPulse)getCurrentDisplacementDatasubset();
DataLocation reflectedLocation = getLocationOfDataSubset(reflectedPulse);
//find incident in same datafile.
DataFile file = DataFiles.get(reflectedLocation.dataFileIndex);
for(DataSubset subset : file.dataSubsets){
if(subset instanceof IncidentPulse){
incidentPulse = (IncidentPulse)subset;
break;
}
}
}
catch(Exception e){
e.printStackTrace();
return null;
}
double sign = getTransmissionPulseSign();
HashMap<String, double[]> map = new HashMap<String, double[]>();
double[] force = reflectedPulse.getFrontFaceForce(barSetup.IncidentBar, incidentPulse.getUsefulTrimmedData(), sign);
map.put("force", force);
// This is copied from ChartsGUI
map.put("time", Arrays.copyOfRange(reflectedPulse.getTrimmedTime(), 0, force.length));
return map;
}

public double[] getFrontFaceForce() {
ReflectedPulse reflectedPulse = null;//(ReflectedPulse) getCurrentDisplacementDatasubset();
IncidentPulse incidentPulse = null;
Expand All @@ -117,10 +151,21 @@ public double[] getFrontFaceForce() {
return null;
}
double sign = getTransmissionPulseSign();

return reflectedPulse.getFrontFaceForce(barSetup.IncidentBar, incidentPulse.getUsefulTrimmedData(), sign);
}

public Map<String, double[]> getBackFaceForceInterpolated() {
double sign = getTransmissionPulseSign();

TransmissionPulse transmissionPulse = (TransmissionPulse) getCurrentLoadDatasubset();

double[] force = transmissionPulse.getBackFaceForcePulse(barSetup.TransmissionBar, sign);
HashMap<String, double[]> map = new HashMap<String, double[]>();
map.put("force", force);
map.put("time", Arrays.copyOfRange(transmissionPulse.getTrimmedTime(), 0, force.length));
return map;
}

public double getTransmissionPulseSign(){
return (this instanceof CompressionSample || this instanceof ShearCompressionSample) ? -1 : 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private void renderData(double[] inputLoad, double[] loadTime, double[] displace

}

private double[] interpolateValues(double[] data, double[] timeForData, double[] timeNeeded) throws Exception {
public static double[] interpolateValues(double[] data, double[] timeForData, double[] timeNeeded) throws Exception {
double[] newData = new double[timeNeeded.length];
if (data.length != timeForData.length) {
throw new Exception("Data array and time array must be the same length");
Expand Down Expand Up @@ -87,7 +87,7 @@ private double[] interpolateValues(double[] data, double[] timeForData, double[]
return newData;
}

private double linearApprox(double[] data, double[] timeForData, double[] timeNeeded, int indexOfTimeNeeded,
public static double linearApprox(double[] data, double[] timeForData, double[] timeNeeded, int indexOfTimeNeeded,
int indexOfData, int distInterpolated) {
return data[indexOfData] + ((data[indexOfData + distInterpolated] - data[indexOfData])
/ (timeForData[indexOfData + distInterpolated] - timeForData[indexOfData]))
Expand Down

0 comments on commit f560d8b

Please sign in to comment.