diff --git a/src/net/relinc/libraries/sample/HopkinsonBarSample.java b/src/net/relinc/libraries/sample/HopkinsonBarSample.java index 11508f9..7cf1c25 100644 --- a/src/net/relinc/libraries/sample/HopkinsonBarSample.java +++ b/src/net/relinc/libraries/sample/HopkinsonBarSample.java @@ -1,5 +1,9 @@ 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; @@ -7,6 +11,7 @@ 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; @@ -97,6 +102,35 @@ public double[] getEngineeringStrainFromIncidentBarReflectedPulseStrain(double[] return strain; } + public Map 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 map = new HashMap(); + 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; @@ -117,10 +151,21 @@ public double[] getFrontFaceForce() { return null; } double sign = getTransmissionPulseSign(); - return reflectedPulse.getFrontFaceForce(barSetup.IncidentBar, incidentPulse.getUsefulTrimmedData(), sign); } + public Map getBackFaceForceInterpolated() { + double sign = getTransmissionPulseSign(); + + TransmissionPulse transmissionPulse = (TransmissionPulse) getCurrentLoadDatasubset(); + + double[] force = transmissionPulse.getBackFaceForcePulse(barSetup.TransmissionBar, sign); + HashMap map = new HashMap(); + 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; } diff --git a/src/net/relinc/libraries/sample/LoadDisplacementSampleResults.java b/src/net/relinc/libraries/sample/LoadDisplacementSampleResults.java index bb5ee06..6f46626 100644 --- a/src/net/relinc/libraries/sample/LoadDisplacementSampleResults.java +++ b/src/net/relinc/libraries/sample/LoadDisplacementSampleResults.java @@ -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"); @@ -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]))