parameterize SpirvSim over R: Real

This commit is contained in:
2022-07-25 14:49:32 -07:00
parent a1784da1cf
commit 47e11474d2
6 changed files with 54 additions and 48 deletions

View File

@@ -389,7 +389,7 @@ fn run_sim(id: u32, p: Params, g: Geometries) -> Results {
p.clock_type,
);
let mut driver: SpirvDriver<Mat> = Driver::new_spirv(g.dim, p.geom.feat_size);
let mut driver: SpirvDriver<f32, Mat> = Driver::new_spirv(g.dim, p.geom.feat_size);
driver.set_steps_per_stim(1000);
if !driver.add_state_file(&*format!("{}/state.bc", prefix), 16000) {
// mu_r=881.33, starting at H=25 to H=75.
@@ -414,7 +414,7 @@ fn run_sim(id: u32, p: Params, g: Geometries) -> Results {
info!("loaded state file: skipping geometry calculations");
}
let add_drive_sine_pulse = |driver: &mut SpirvDriver<Mat>, region: &Torus, start: f32, duration: f32, amp: f32| {
let add_drive_sine_pulse = |driver: &mut SpirvDriver<f32, Mat>, region: &Torus, start: f32, duration: f32, amp: f32| {
let wave = Sinusoid1::from_wavelength(amp, duration * 2.0)
.half_cycle()
.shifted(start);
@@ -426,7 +426,7 @@ fn run_sim(id: u32, p: Params, g: Geometries) -> Results {
));
};
let add_drive_square_pulse = |driver: &mut SpirvDriver<Mat>, region: &Torus, start: f32, duration: f32, amp: f32| {
let add_drive_square_pulse = |driver: &mut SpirvDriver<f32, Mat>, region: &Torus, start: f32, duration: f32, amp: f32| {
let wave = Gated::new(amp, start, start+duration);
driver.add_stimulus(CurlStimulus::new(
region.clone(),
@@ -436,7 +436,7 @@ fn run_sim(id: u32, p: Params, g: Geometries) -> Results {
));
};
let add_drive_exp_pulse = |driver: &mut SpirvDriver<Mat>, region: &Torus, start: f32, duration: f32, amp: f32| {
let add_drive_exp_pulse = |driver: &mut SpirvDriver<f32, Mat>, region: &Torus, start: f32, duration: f32, amp: f32| {
let wave = Exp1::new_at(amp, start, 0.5*duration);
driver.add_stimulus(CurlStimulus::new(
region.clone(),
@@ -447,11 +447,11 @@ fn run_sim(id: u32, p: Params, g: Geometries) -> Results {
};
// step function: "permanently" increase the current by `amp`.
let _add_drive_step = |driver: &mut SpirvDriver<Mat>, region: &Torus, start: f32, amp: f32| {
let _add_drive_step = |driver: &mut SpirvDriver<f32, Mat>, region: &Torus, start: f32, amp: f32| {
add_drive_square_pulse(driver, region, start, 1.0 /* effectively infinite duration */, amp);
};
let add_drive_pulse = |ty: PulseType, driver: &mut SpirvDriver<Mat>, region: &Torus, start: f32, duration: f32, amp: f32| {
let add_drive_pulse = |ty: PulseType, driver: &mut SpirvDriver<f32, Mat>, region: &Torus, start: f32, duration: f32, amp: f32| {
match ty {
PulseType::Square => add_drive_square_pulse(driver, region, start, duration, amp),
PulseType::Sine => add_drive_sine_pulse(driver, region, start, duration, amp),