Skip to content

Commit

Permalink
fix rayleigh
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f committed Dec 13, 2024
1 parent b0f1538 commit 410f479
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ public NoiseMapInStack(NoiseMap multiThreadParent) {
double[] sumLevels(List<double[]> wjSources,List<Attenuation.SourceReceiverAttenuation> receiverAttenuationLevels) {
double[] levels = new double[noiseMapComputeRaysOut.dayPathData.freq_lvl.size()];
for (Attenuation.SourceReceiverAttenuation lvl : receiverAttenuationLevels) {
levels = sumArray(levels,
dbaToW(sumArray(wToDba(wjSources.get((int) lvl.source)), lvl.value)));
if(wjSources.size() > lvl.sourceId && lvl.sourceId >= 0) {
levels = sumArray(levels,
dbaToW(sumArray(wToDba(wjSources.get((int) lvl.sourceId)), lvl.value)));
}
}
return levels;
}
Expand Down Expand Up @@ -96,7 +98,7 @@ public PathSearchStrategy onNewCutPlane(CutProfile cutProfile) {

/**
* Get propagation path result
* @param sourceId Source identifier
* @param source Source identifier
* @param sourceLi Source power per meter coefficient
* @param pathsParameter Propagation path result
*/
Expand Down Expand Up @@ -257,11 +259,11 @@ public void finalizeReceiver(int receiverId) {
AttenuationVisitor attenuationVisitor = lDENAttenuationVisitor[timePeriod.ordinal()];
for (Attenuation.SourceReceiverAttenuation lvl : attenuationVisitor.receiverAttenuationLevels) {
NoiseMapParameters.TimePeriodParameters timePeriodParameters;
if (!levelsPerSourceLines.containsKey(lvl.source)) {
if (!levelsPerSourceLines.containsKey(lvl.sourceId)) {
timePeriodParameters = new NoiseMapParameters.TimePeriodParameters();
levelsPerSourceLines.put(lvl.source, timePeriodParameters);
levelsPerSourceLines.put(lvl.sourceId, timePeriodParameters);
} else {
timePeriodParameters = levelsPerSourceLines.get(lvl.source);
timePeriodParameters = levelsPerSourceLines.get(lvl.sourceId);
}
if (timePeriodParameters.getTimePeriodLevel(timePeriod) == null) {
timePeriodParameters.setTimePeriodLevel(timePeriod, lvl.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ void processStack(String tableName, ConcurrentLinkedDeque<Attenuation.SourceRece
Attenuation.SourceReceiverAttenuation row = stack.pop();
AttenuatedPaths.queueSize.decrementAndGet();
int parameterIndex = 1;
ps.setLong(parameterIndex++, row.receiver);
ps.setLong(parameterIndex++, row.receiverId);
if(!NoiseMapParameters.mergeSources) {
ps.setLong(parameterIndex++, row.source);
ps.setLong(parameterIndex++, row.sourceId);
}

if (!noiseMapParameters.computeLAEQOnly){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6307,15 +6307,16 @@ public void TC22() throws IOException {

// Add building
builder.addBuilding(new Coordinate[]{
new Coordinate(197, 36.0, 0),
new Coordinate(179, 36, 0),
new Coordinate(179, 15, 0),
new Coordinate(197, 15, 0),
new Coordinate(197, 21, 0),
new Coordinate(187, 21, 0),
new Coordinate(187, 30, 0),
new Coordinate(197, 30, 0),
new Coordinate(197, 36, 0)}, 20, -1);
new Coordinate(197, 36.0, 20),
new Coordinate(179, 36, 20),
new Coordinate(179, 15, 20),
new Coordinate(197, 15, 20),
new Coordinate(197, 21, 20),
new Coordinate(187, 21, 20),
new Coordinate(187, 30, 20),
new Coordinate(197, 30, 20),
new Coordinate(197, 36, 20)},-1);

addGroundAttenuationTC5(builder);
addTopographicTC5Model(builder);

Expand Down Expand Up @@ -6532,14 +6533,14 @@ public void TC22() throws IOException {
double[] expectedWH = new double[]{0.00, 0.00, 0.00, 0.02, 0.11, 0.60, 3.00, 13.93};
double[] expectedCfH = new double[]{212.03, 230.71, 226.18, 101.93, 13.28, 1.67, 0.33, 0.07};
double[] expectedAGroundH = new double[]{-1.25, -1.25, -1.03, 0.77, -1.25, -1.25, -1.25, -1.25};
double[] expectedWF = new double[]{0.00, 0.00, 0.00, 0.02, 0.11, 0.59, 2.96, 13.76};
double[] expectedWF = new double[]{0.00, 0.00, 0.00, 0.01, 0.07, 0.38, 1.96, 9.49};
double[] expectedCfF = new double[]{209.34, 224.10, 237.46, 143.50, 25.94, 2.69, 0.51, 0.11};
double[] expectedAGroundF = new double[]{-1.25, -1.17, -1.25, -1.25, -1.25, -1.25, -1.25, -1.25};

expectedAlphaAtm = new double[]{0.12, 0.41, 1.04, 1.93, 3.66, 9.66, 32.77, 116.88};
expectedAAtm = new double[]{0.02, 0.08, 0.21, 0.39, 0.75, 1.97, 6.70, 23.88};
expectedADiv = new double[]{56.02, 56.02, 56.02, 56.02, 56.02, 56.02, 56.02, 56.02};
expectedLH = new double[]{15.12, 11.76, 7.43, 0.88, -1.57, -6.24, -14-10, -34.33};
expectedLH = new double[]{15.12, 11.76, 7.43, 0.88, -1.57, -6.24, -14.10, -34.33};
expectedLF = new double[]{15.12, 11.69, 7.64, 2.90, -1.57, -6.24, -14.10, -34.33};

proPath = propDataOut.getPropagationPaths().get(1);
Expand All @@ -6557,10 +6558,10 @@ public void TC22() throws IOException {
actualLH = addArray(proPath.aGlobalH, SOUND_POWER_LEVELS);
actualLF = addArray(proPath.aGlobalF, SOUND_POWER_LEVELS);

assertDoubleArrayEquals("WH - lateral right", expectedWH, actualWH, ERROR_EPSILON_LOWEST);
assertDoubleArrayEquals("CfH - lateral right", expectedCfH, actualCfH, ERROR_EPSILON_LOWEST);
assertDoubleArrayEquals("AGroundH - lateral right", expectedAGroundH, actualAGroundH, ERROR_EPSILON_LOWEST);
assertDoubleArrayEquals("WF - lateral right", expectedWF, actualWF, ERROR_EPSILON_LOWEST);
assertDoubleArrayEquals("WH - lateral right", expectedWH, actualWH, ERROR_EPSILON_VERY_LOW);
assertDoubleArrayEquals("CfH - lateral right", expectedCfH, actualCfH, ERROR_EPSILON_VERY_LOW);
assertDoubleArrayEquals("AGroundH - lateral right", expectedAGroundH, actualAGroundH, ERROR_EPSILON_VERY_LOW);
assertDoubleArrayEquals("WF - lateral right", expectedWF, actualWF, ERROR_EPSILON_VERY_LOW);
assertDoubleArrayEquals("CfF - lateral right", expectedCfF, actualCfF, ERROR_EPSILON_VERY_LOW);
assertDoubleArrayEquals("AGroundF - lateral right", expectedAGroundF, actualAGroundF, ERROR_EPSILON_VERY_LOW);

Expand All @@ -6574,7 +6575,7 @@ public void TC22() throws IOException {
expectedWH = new double[]{0.00, 0.00, 0.00, 0.02, 0.11, 0.59, 2.96, 13.76};
expectedCfH = new double[]{214.41, 233.28, 228.92, 103.46, 13.51, 1.70, 0.34, 0.07};
expectedAGroundH = new double[]{-1.26, -1.26, -1.05, 0.86, -1.26, -1.26, -1.26, -1.26};
expectedWF = new double[]{0.00, 0.00, 0.00, 0.01, 0.07, 0.59, 2.96, 13.76};
expectedWF = new double[]{0.00, 0.00, 0.00, 0.01, 0.07, 0.38, 1.96, 9.49};
expectedCfF = new double[]{211.78, 226.80, 240.03, 144.13, 25.83, 2.69, 0.51, 0.11};
expectedAGroundF = new double[]{-1.26, -1.18, -1.26, -1.26, -1.26, -1.26, -1.26, -1.26};

Expand All @@ -6600,8 +6601,8 @@ public void TC22() throws IOException {
actualLF = addArray(proPath.aGlobalF, SOUND_POWER_LEVELS);

assertDoubleArrayEquals("WH - lateral left", expectedWH, actualWH, ERROR_EPSILON_LOWEST);
assertDoubleArrayEquals("CfH - lateral left", expectedCfH, actualCfH, ERROR_EPSILON_LOWEST);
assertDoubleArrayEquals("AGroundH - lateral left", expectedAGroundH, actualAGroundH, ERROR_EPSILON_LOWEST);
assertDoubleArrayEquals("CfH - lateral left", expectedCfH, actualCfH, ERROR_EPSILON_VERY_LOW);
assertDoubleArrayEquals("AGroundH - lateral left", expectedAGroundH, actualAGroundH, ERROR_EPSILON_VERY_LOW);
assertDoubleArrayEquals("WF - lateral left", expectedWF, actualWF, ERROR_EPSILON_LOWEST);
assertDoubleArrayEquals("CfF - lateral left", expectedCfF, actualCfF, ERROR_EPSILON_VERY_LOW);
assertDoubleArrayEquals("AGroundF - lateral left", expectedAGroundF, actualAGroundF, ERROR_EPSILON_VERY_LOW);
Expand Down Expand Up @@ -8403,7 +8404,7 @@ public void TestFavorableConditionAttenuationRose() {
double globalValue = AcousticIndicatorsFunctions.sumDbArray(v.value);
if (globalValue > maxGlobalValue) {
maxGlobalValue = globalValue;
maxPowerReceiverIndex = (int) v.receiver;
maxPowerReceiverIndex = (int) v.receiverId;
}
}
assertEquals(idReceiver, maxPowerReceiverIndex);
Expand Down Expand Up @@ -8539,11 +8540,11 @@ public void testSourceLines() throws LayerDelaunayError, IOException, ParseExce
// Merge levels for each receiver for point sources
Map<Long, double[]> levelsPerReceiver = new HashMap<>();
for(Attenuation.SourceReceiverAttenuation lvl : propDataOut.receiversAttenuationLevels) {
if(!levelsPerReceiver.containsKey(lvl.receiver)) {
levelsPerReceiver.put(lvl.receiver, lvl.value);
if(!levelsPerReceiver.containsKey(lvl.receiverId)) {
levelsPerReceiver.put(lvl.receiverId, lvl.value);
} else {
// merge
levelsPerReceiver.put(lvl.receiver, sumDbArray(levelsPerReceiver.get(lvl.receiver),
levelsPerReceiver.put(lvl.receiverId, sumDbArray(levelsPerReceiver.get(lvl.receiverId),
lvl.value));
}
}
Expand All @@ -8552,11 +8553,11 @@ public void testSourceLines() throws LayerDelaunayError, IOException, ParseExce
// Merge levels for each receiver for lines sources
Map<Long, double[]> levelsPerReceiverLines = new HashMap<>();
for(Attenuation.SourceReceiverAttenuation lvl : propDataOutTest.receiversAttenuationLevels) {
if(!levelsPerReceiverLines.containsKey(lvl.receiver)) {
levelsPerReceiverLines.put(lvl.receiver, lvl.value);
if(!levelsPerReceiverLines.containsKey(lvl.receiverId)) {
levelsPerReceiverLines.put(lvl.receiverId, lvl.value);
} else {
// merge
levelsPerReceiverLines.put(lvl.receiver, sumDbArray(levelsPerReceiverLines.get(lvl.receiver),
levelsPerReceiverLines.put(lvl.receiverId, sumDbArray(levelsPerReceiverLines.get(lvl.receiverId),
lvl.value));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,16 @@ public void testPointDirectivity() throws Exception {
NoiseMap rout = (NoiseMap) out;

Attenuation.SourceReceiverAttenuation sl = rout.attenuatedPaths.lDenLevels.pop();
assertEquals(1, sl.receiver);
assertEquals(1, sl.receiverId);
assertEquals(73.3, sl.value[0], 1);
sl = rout.attenuatedPaths.lDenLevels.pop();
assertEquals(2, sl.receiver);
assertEquals(2, sl.receiverId);
assertEquals(53.3, sl.value[0], 1);
assertTrue(rout.attenuatedPaths.lDenLevels.isEmpty());

List<CnossosPath> pathsParameters = rout.getPropagationPaths();
assertEquals(2 , pathsParameters.size());
//System.out.println("laaaaaa"+rout.getPropagationPaths());

CnossosPath pathParameters = pathsParameters.remove(0);
assertEquals(1, pathParameters.getIdReceiver());
assertEquals(new Orientation(90, 15, 0), pathParameters.getSourceOrientation());
Expand Down Expand Up @@ -334,10 +334,10 @@ public void testLineDirectivity() throws Exception {
assertEquals(2, rout.attenuatedPaths.lDenLevels.size());

Attenuation.SourceReceiverAttenuation sl = rout.attenuatedPaths.lDenLevels.pop();
assertEquals(1, sl.receiver);
assertEquals(1, sl.receiverId);
assertEquals(68.3, sl.value[0], 1);
sl = rout.attenuatedPaths.lDenLevels.pop();
assertEquals(2, sl.receiver);
assertEquals(2, sl.receiverId);
assertEquals(70.8, sl.value[0], 1);

assertEquals(3 , rout.pathParameters.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public double[] addPropagationPaths(CutPointSource source, CutPointReceiver rece
}
double[] aGlobalMeteo = computeCnossosAttenuation(genericMeteoData, source.id, source.li, path);
if (aGlobalMeteo != null && aGlobalMeteo.length > 0) {
receiversAttenuationLevels.add(new SourceReceiverAttenuation(receiver,
source, aGlobalMeteo));
receiversAttenuationLevels.add(new SourceReceiverAttenuation(receiver.receiverPk,
source.sourcePk, aGlobalMeteo));
return aGlobalMeteo;
} else {
return new double[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public static void computeRayleighDiff(SegmentPath srSeg, CutProfile cutProfile,
Coordinate rcv = pts2D.get(pts2D.size() - 1);
CutPoint srcCut = cutProfile.getSource();
CutPoint rcvCut = cutProfile.getReceiver();
for (int iO = 1; iO < pts2DGround.length - 1; iO++) {
int i0Cut = cut2DGroundIndex.indexOf(iO);
for (int i0Cut = 1; i0Cut < cuts.size() - 1; i0Cut++) {
int iO = cut2DGroundIndex.get(i0Cut);
Coordinate o = pts2DGround[iO];

double dSO = src.distance(o);
Expand Down

0 comments on commit 410f479

Please sign in to comment.