Mon 15 Sep 09:47:09 CEST 2025

This commit is contained in:
sbosse 2025-09-15 09:49:07 +02:00
parent a677fd1d95
commit 3077be9244

View File

@ -0,0 +1,32 @@
/*
Generate a set of samples with different damage 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 randomInt( range) {
return range[0]+Math.floor(Math.random()*(range[1]-range[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<sampleN;i++) {
var config = readJSON(configFile)
config.GeometricObjects[0].x0=randomInt(damx);
config.GeometricObjects[0].y0=randomInt(damy);
config.Export.Filename = 'sample-x'+config.GeometricObjects[0].x0+'-y'+config.GeometricObjects[0].y0;
writeJSON('config.json',config)
console.log(config.Export.Filename)
cp.spawnSync(simu,['config.json'])
}