diff --git a/demo/plate1n/gendatasetn.js b/demo/plate1n/gendatasetn.js new file mode 100644 index 0000000..675c485 --- /dev/null +++ b/demo/plate1n/gendatasetn.js @@ -0,0 +1,41 @@ +/* + Generate a set of samples with different damage positions (random, normal around center positions) + One transducer (top) and one sensor (bottom, x-centered, 30mm from bottom) +*/ +var fs = require('fs'), + cp = require('child_process') + +var plate = [500,500], + damx = [100,400], + damy = [100,400], + sampleN = 1000, + simu = '../../bin/simndt2b', + configFile = 'simndt_alu_plate_hole_20mm_sensorshape.json' + +function gaussianRandom(mean, stdev) { + const u = 1 - Math.random(); // Converting [0,1) to (0,1] + const v = Math.random(); + const z = Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); + // Transform to the desired mean and standard deviation: + return z * stdev + mean; +} +function randomInt(range) { + return gaussianRandom(250,50)|0 +} +function readJSON(file) { + return JSON.parse(fs.readFileSync(file,'utf8')) +} +function writeJSON(file,config) { + return fs.writeFileSync(file,JSON.stringify(config),'utf8') +} +for(var i=0;i