Stimulus: parameterize over R.

this saves us from a `mem::transmute` in the sim code to get
`Fields<R>`.
This commit is contained in:
2022-08-22 00:37:34 -07:00
parent e32d500f8c
commit 24b82037b4
9 changed files with 315 additions and 285 deletions

View File

@@ -437,7 +437,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 Driver<_>, region: &Torus, start: f32, duration: f32, amp: f32| {
let add_drive_sine_pulse = |driver: &mut Driver<f32, _, _>, region: &Torus, start: f32, duration: f32, amp: f32| {
let wave = Sinusoid::from_wavelength(amp, duration * 2.0)
.half_cycle()
.shifted(start);
@@ -447,7 +447,7 @@ fn run_sim(id: u32, p: Params, g: Geometries) -> Results {
));
};
let add_drive_square_pulse = |driver: &mut Driver<_>, region: &Torus, start: f32, duration: f32, amp: f32| {
let add_drive_square_pulse = |driver: &mut Driver<f32, _, _>, region: &Torus, start: f32, duration: f32, amp: f32| {
let wave = Gated::new(amp, start, start+duration);
driver.add_stimulus(ModulatedVectorField::new(
CurlVectorField::new(region.clone()),
@@ -455,7 +455,7 @@ fn run_sim(id: u32, p: Params, g: Geometries) -> Results {
));
};
let add_drive_exp_pulse = |driver: &mut Driver<_>, region: &Torus, start: f32, duration: f32, amp: f32| {
let add_drive_exp_pulse = |driver: &mut Driver<f32, _, _>, region: &Torus, start: f32, duration: f32, amp: f32| {
let wave = Exp::new_at(amp, start, 0.5*duration);
driver.add_stimulus(ModulatedVectorField::new(
CurlVectorField::new(region.clone()),
@@ -464,11 +464,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 Driver<_>, region: &Torus, start: f32, amp: f32| {
let _add_drive_step = |driver: &mut Driver<f32, _, _>, 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 Driver<_>, region: &Torus, start: f32, duration: f32, amp: f32| {
let add_drive_pulse = |ty: PulseType, driver: &mut Driver<f32, _, _>, 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),