multi_core_inverter: abstractions to allow swapping out float impl and backend

This commit is contained in:
2022-07-28 13:20:26 -07:00
parent de0f3d9654
commit 26efc12c21

View File

@@ -37,12 +37,15 @@
//! ```
use coremem::geom::{Coord as _, Meters, Torus};
use coremem::sim::spirv::{SpirvSim, WgpuBackend};
use coremem::real::{self, Real as _};
use coremem::sim::spirv::{self, SpirvSim};
use coremem::sim::units::Seconds;
use coremem::mat::{Ferroxcube3R1MH, IsoConductorOr, IsomorphicConductor};
use coremem::Driver;
type Mat = IsoConductorOr<f32, Ferroxcube3R1MH>;
type R = real::R32;
type Mat = IsoConductorOr<R, Ferroxcube3R1MH>;
type Backend = spirv::WgpuBackend;
fn main() {
coremem::init_logging();
@@ -73,14 +76,14 @@ fn main() {
let s = |n| Torus::new_xy(Meters::new(sx(n), sy, sz), s_major, s_minor);
let coupling = |n| Torus::new_xz(Meters::new(couplingx(n), sy, sz), coupling_major, coupling_minor);
let wire_mat = IsomorphicConductor::new(1e6);
let wire_mat = IsomorphicConductor::new(1e6f32.cast::<R>());
let ferro_mat = wire_mat;
// let ferro_mat = Ferroxcube3R1MH::new(); // uncomment when ready to simulate for real
let mut driver = Driver::new(SpirvSim::<f32, Mat, WgpuBackend>::new(
let mut driver = Driver::new(SpirvSim::<R, Mat, Backend>::new(
sim_bounds.to_index(feat_size), feat_size,
));
driver.add_classical_boundary(sim_padding);
driver.add_classical_boundary_explicit::<R, _>(sim_padding);
driver.fill_region(&drive0, wire_mat);
driver.fill_region(&sense3, wire_mat);
for core in 0..4 {