public void testScene1() throws LayerDelaunayError { System.out.println("________________________________________________"); System.out.println("Scene 1 :"); long startMakeScene = System.currentTimeMillis(); //////////////////////////////////////////////////////////////////////////// // Build Scene with One Building GeometryFactory factory = new GeometryFactory(); Coordinate[] building1Coords = { new Coordinate(15., 5., 0.), new Coordinate(30., 5., 0.), new Coordinate(30., 30., 0.), new Coordinate(15., 30., 0.), new Coordinate(15., 5., 0.) }; Polygon building1 = factory.createPolygon(factory.createLinearRing(building1Coords), null); //////////////////////////////////////////////////////////////////////////// // Add road source as one point List<Geometry> srclst = new ArrayList<Geometry>(); srclst.add(factory.createPoint(new Coordinate(40, 15, 0))); // Scene dimension Envelope cellEnvelope = new Envelope(new Coordinate(-170., -170., 0.), new Coordinate(170, 170, 0.)); // Add source sound level List<ArrayList<Double>> srcSpectrum = new ArrayList<ArrayList<Double>>(); srcSpectrum.add(new ArrayList<Double>()); srcSpectrum.get(0).add(PropagationProcess.dbaToW(100.)); // 100 dB(A) @ 125 Hz List<Integer> freqLvl = new ArrayList<Integer>(); freqLvl.add(125); // Build query structure for sources QueryGeometryStructure sourcesIndex = new QueryGridIndex(cellEnvelope, 8, 8); int idsrc = 0; for (Geometry src : srclst) { sourcesIndex.appendGeometry(src, idsrc); idsrc++; } System.out.println( "Construction scene in " + (System.currentTimeMillis() - startMakeScene) + "ms"); long startObstructionTest = System.currentTimeMillis(); // Create obstruction test object FastObstructionTest manager = new FastObstructionTest(); manager.addGeometry(building1); manager.finishPolygonFeeding(cellEnvelope); // Retrieve Delaunay triangulation of scene List<Triangle> tri = manager.getTriangles(); List<Coordinate> vert = manager.getVertices(); Stack<PropagationResultTriRecord> dataStack = new Stack<PropagationResultTriRecord>(); PropagationProcessData propData = new PropagationProcessData( vert, null, tri, manager, sourcesIndex, srclst, srcSpectrum, freqLvl, 0, 2, 80., 50., 1., 0., 0, null, null); PropagationProcessOut propDataOut = new PropagationProcessOut(dataStack, null); PropagationProcess propManager = new PropagationProcess(propData, propDataOut); propManager.initStructures(); System.out.println( "Propagation initialisation in " + (System.currentTimeMillis() - startObstructionTest) + "ms"); long startSimulation = System.currentTimeMillis(); // Run test ///////////////////////////////////////////////////////////////////////// // Single diffraction test propData.diffractionOrder = 1; propData.reflexionOrder = 0; splCompare(splCompute(propManager, new Coordinate(15, 40, 0)), "Scene 1 R4_S1", 46.81); ///////////////////////////////////////////////////////////////////////// // Dual diffraction test propData.diffractionOrder = 2; propData.reflexionOrder = 0; splCompare(splCompute(propManager, new Coordinate(5, 15, 0)), "Scene 1 R1_S1", 34.97); ///////////////////////////////////////////////////////////////////////// // Geometric dispersion test // Get reference spl value at 5m propData.reflexionOrder = 0; propData.diffractionOrder = 0; double dbaRef = splCompute(propManager, new Coordinate(40, 20, 0)); // spl value at 10m double dbaReduced = splCompute(propManager, new Coordinate(40, 25, 0)); splCompare( dbaReduced, "Scene 1 R2_S1", dbaRef - 6.); // Double distance, then loss 6 dB. Atmospheric attenuation is not significant at // 125Hz and 5 m distance ///////////////////////////////////////////////////////////////////////// // First reflection test dbaRef = splCompute(propManager, new Coordinate(35, 15, 0)); // Ref, at 5m of src, at 5m of wall double dbaRef2 = splCompute( propManager, new Coordinate( 40, 15 + 15, 0)); // Ref2, at 15m of src (Src->Receiver->Wall->Receiver : 5+5+5) propData.reflexionOrder = 1; propData.wallAlpha = 0.2; double dbaReflection = splCompute( propManager, new Coordinate( 35, 15, 0)); // dbaReflection must be equal to the energetic sum of Ref&Ref2, with Ref2 // attenuated by wall alpha. splCompare( dbaReflection, "Scene 1 R3_S1", PropagationProcess.wToDba( PropagationProcess.dbaToW(dbaRef) + PropagationProcess.dbaToW(dbaRef2) * (1 - propData.wallAlpha))); ///////////////////////////////////////////////////////////////////////// // Energetic sum of source test // The same source duplicated at the same position must be equal to a single point source with // an energetic sum of SPL. // Get reference spl value propData.reflexionOrder = 0; propData.diffractionOrder = 0; srcSpectrum.get(0).set(0, PropagationProcess.dbaToW(100.) + PropagationProcess.dbaToW(100.)); double dbaSingleSource = splCompute(propManager, new Coordinate(40, 20, 0)); // spl value srcSpectrum.add(new ArrayList<Double>()); srcSpectrum.get(0).set(0, PropagationProcess.dbaToW(100.)); srcSpectrum.get(1).add(PropagationProcess.dbaToW(100.)); // 100 dB(A) @ 125 Hz srclst.add(factory.createPoint(new Coordinate(40, 15, 0))); sourcesIndex.appendGeometry(srclst.get(1), idsrc); idsrc++; double dbaDupp = splCompute(propManager, new Coordinate(40, 20, 0)); splCompare(dbaSingleSource, "Scene 1 R3_S2", dbaDupp); System.out.println( "Simulation done in " + (System.currentTimeMillis() - startSimulation) + "ms"); System.out.println(manager.getNbObstructionTest() + " obstruction test has been done.."); System.out.println( "testScene1 done in " + (System.currentTimeMillis() - startMakeScene) + "ms"); }
private double splCompute(PropagationProcess propManager, Coordinate receiverPosition) { double energeticSum[] = {0.}; propManager.computeSoundLevelAtPosition(receiverPosition, energeticSum); return PropagationProcess.wToDba(energeticSum[0]); }