Tue 27 Jan 2026 02:37:58 PM CET
This commit is contained in:
parent
148b0d89ac
commit
77b40eccfa
41
demo/plate1n/gendatasetn.js
Normal file
41
demo/plate1n/gendatasetn.js
Normal file
|
|
@ -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<sampleN;i++) {
|
||||
var config = readJSON(configFile)
|
||||
config.GeometricObjects[0].x0=randomInt(damx);
|
||||
config.GeometricObjects[0].y0=randomInt(damy);
|
||||
config.Export.Save_filepath = './datan'
|
||||
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'])
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user