Skip to main content

Crate csx

Crate csx 

Source
Expand description

§csx

Pure Rust continuous-structure geometry and material modeling, compatible with CSXCAD and openEMS.

A ContinuousStructure holds named Propertys (materials, metals, excitations, probes, …). Each property owns Primitives describing where it applies; overlapping primitives are resolved by priority. The structure also carries a RectilinearGrid (the FDTD mesh), a ParameterSet for parametric models and the background material.

use csx::primitives::{BoxShape, Cylinder};
use csx::properties::Material;
use csx::{ContinuousStructure, CoordSystem, Primitive, Property, TypeMask, Vec3};

let mut model = ContinuousStructure::new();
model.parameters.set("h", 1.6);

// FR4 substrate, its thickness given by the parameter `h`.
let fr4 = model.add_property(Property::material("FR4", Material::new(4.3, 0.0)));
model.add_primitive(fr4, Primitive::new(BoxShape {
    start: [-10.0, -10.0, 0.0].into(),
    stop: csx::ScalarPoint(["10".into(), "10".into(), "h".into()]),
}))?;

// A metal via with higher priority.
let pec = model.add_property(Property::metal("via"));
model.add_primitive(pec, Primitive::new(Cylinder::new([0.0, 0.0, 0.0], [0.0, 0.0, 1.6], 0.3))
    .with_priority(10))?;

model.update()?; // evaluate parametric values

let hit = model.property_at(Vec3::new(5.0, 0.0, 0.8), CoordSystem::Cartesian, TypeMask::ANY);
assert_eq!(hit.unwrap().property.name, "FR4");
let hit = model.property_at(Vec3::new(0.1, 0.0, 0.8), CoordSystem::Cartesian, TypeMask::ANY);
assert_eq!(hit.unwrap().property.name, "via");

§Module overview

§Conventions

Details: coords and expr.

§Stability

Enums and option/result structs that are expected to grow (errors, shape and property kinds, type ids, *Options, …) are #[non_exhaustive]: match them with a wildcard arm and build options from Default plus their with_* builders.

This is a clean-room implementation written from public documentation and the observable file format only.

Re-exports§

pub use coords::CoordSystem;
pub use error::Error;
pub use error::Result;
pub use grid::RectilinearGrid;
pub use io::xml::OpenEmsDocument;
pub use math::BoundingBox;
pub use math::Mat4;
pub use math::Vec3;
pub use param::Parameter;
pub use param::ParameterSet;
pub use param::Scalar;
pub use param::ScalarPoint;
pub use primitives::Primitive;
pub use primitives::Shape;
pub use properties::Axis;
pub use properties::Material;
pub use properties::Property;
pub use properties::PropertyKind;
pub use properties::PropertyType;
pub use properties::TypeMask;
pub use structure::BackgroundMaterial;
pub use structure::ContinuousStructure;
pub use structure::Hit;
pub use structure::Medium;
pub use structure::PropertyId;
pub use structure::ValidationIssue;
pub use transform::Transform;
pub use transform::TransformOp;

Modules§

coords
Coordinate systems and conversions.
discretize
Sampling of a structure onto its rectilinear grid (FDTD discretisation).
error
Error type.
expr
Mathematical expressions.
fdtd
openEMS simulation settings: time stepping, excitation signal and boundary conditions (the <FDTD> element of an openEMS file).
grid
Rectilinear grids (mesh lines).
io
File formats.
math
Basic linear algebra: 3-vectors, affine 4×4 matrices and bounding boxes.
mesh
Automatic mesh-line generation.
param
Parameters and parametric scalar values.
prelude
The most commonly used types, for glob import:
primitives
Geometric primitives.
properties
Properties: what a region of space is (material, metal, excitation, probe, …). Every property owns the primitives describing where it is.
structure
The continuous structure: the complete geometry and material model.
tessellate
Surface tessellation of primitives.
transform
Affine transformations of primitives.