diff --git a/examples/beam_combine_test.rs b/examples/beam_combine_test.rs index 9e787c48a058c6302e86d4cf5ef07e5e4405cbfe..eda3b8209a604d4fd199d3578f439c18d73ea273 100644 --- a/examples/beam_combine_test.rs +++ b/examples/beam_combine_test.rs @@ -6,8 +6,8 @@ use opossum::{ error::OpossumError, lightdata::{DataEnergy, LightData}, nodes::{BeamSplitter, Detector, FilterType, IdealFilter, Source}, - OpticScenery, spectrum::{create_he_ne_spectrum, create_nd_glass_spectrum, Spectrum}, + OpticScenery, }; fn main() -> Result<(), OpossumError> { diff --git a/examples/filter_test.rs b/examples/filter_test.rs index 1f7f4ee960d5214b0dd25ebbb1844f9d576c80e4..978e5cb0bac2a31ac5a1f52a3b35a8c7c29e1a75 100644 --- a/examples/filter_test.rs +++ b/examples/filter_test.rs @@ -6,8 +6,8 @@ use opossum::{ error::OpossumError, lightdata::{DataEnergy, LightData}, nodes::{BeamSplitter, Detector, FilterType, IdealFilter, Source}, - OpticScenery, spectrum::{create_he_ne_spectrum, Spectrum}, + OpticScenery, }; fn main() -> Result<(), OpossumError> { diff --git a/examples/group_test.rs b/examples/group_test.rs index ecf1a17490844d148ff20e10c305ec0a2488af39..6f55ce3fb9daee3a1a8d07fd94ec6db358d9e38d 100644 --- a/examples/group_test.rs +++ b/examples/group_test.rs @@ -7,8 +7,8 @@ use opossum::{ lightdata::{DataEnergy, LightData}, nodes::{BeamSplitter, Detector, Dummy, NodeGroup, Source}, optic_node::OpticNode, - OpticScenery, spectrum::create_he_ne_spectrum, + OpticScenery, }; fn main() -> Result<(), OpossumError> { diff --git a/src/analyzer.rs b/src/analyzer.rs index aca57780a46d467693c5808e295f29a659fcf7a7..f4447897af65e7f08796f29c18dc1281ed44f757 100644 --- a/src/analyzer.rs +++ b/src/analyzer.rs @@ -1,3 +1,4 @@ +//! Optical Analyzers use crate::{error::OpossumError, optic_scenery::OpticScenery}; type Result<T> = std::result::Result<T, OpossumError>; diff --git a/src/error.rs b/src/error.rs index 3eac8bc3e3f24e8ba8ef75d757308154bdf5ddc5..9cc88ac688468eb4fd3b7a59f6e1582d26df3015 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,12 +1,14 @@ -//! Opossum specfic error structure +//! Opossum specfic error structures use std::{error::Error, fmt::Display}; +/// Errors that can be returned by various OPOSSUM functions. #[derive(Debug, Clone)] pub enum OpossumError { /// error while setting up an `OpticScenery` OpticScenery(String), /// error while setting up an `OpticGroup`. The reasons are similar to [`OpossumError::OpticScenery`] OpticGroup(String), + /// (mostly internal) errors while dealing with optical ports. OpticPort(String), /// mostly runtime errors occuring during the analysis of a scenery Analysis(String), diff --git a/src/lib.rs b/src/lib.rs index 35fa39a97734fe3b0e7bcae332a3cedcdcd9aa56..d8828a60effdcf9781b5ec07635ac280ad060870 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ -//! This is the documentation for the OPOSSUM software package. OPOSSUM stands for OPen-source Optics Simulation Software and Unified Modeller. +//! This is the documentation for the **OPOSSUM** software package. **OPOSSUM** stands for +//! **Op**en-source **O**ptics **S**imulation **S**oftware and **U**nified **M**odeller. //! mod light; pub mod lightdata; @@ -17,4 +18,4 @@ pub mod error; pub mod spectrum; -pub use optic_scenery::OpticScenery; \ No newline at end of file +pub use optic_scenery::OpticScenery; diff --git a/src/light.rs b/src/light.rs index f3df4dbe4c921f4414c0916b07632eebd2548f32..7bc5dc865ba05963d0a9f9686753c84b48c4119e 100644 --- a/src/light.rs +++ b/src/light.rs @@ -1,5 +1,5 @@ //! Data structure for the graph edges. -//! +//! //! [`Light`] represents the information / data flowing from one node to another node. It contains information about //! the respective source an target port names this edge connects as well as the actual light information (stored as //! [`LightData`]). diff --git a/src/lightdata.rs b/src/lightdata.rs index 1387aa5b7778ddfc1bd96b40550ecf65e6910f1f..e514311ce6cae225e43d739ec3ec17fe7ee61738 100644 --- a/src/lightdata.rs +++ b/src/lightdata.rs @@ -8,7 +8,7 @@ use crate::spectrum::Spectrum; /// Data structure defining the light properties. The actuals data type used depends on the /// [`AnalyzerType`](crate::analyzer::AnalyzerType). For example, an energy analysis ([`LightData::Energy`]) only /// contains a [`Spectrum`] information, while a geometric analysis ([`LightData::Geometric]) constains a set of optical -/// ray data. +/// ray data. #[derive(Debug, Clone)] pub enum LightData { /// data type used for energy analysis. diff --git a/src/nodes/beam_splitter.rs b/src/nodes/beam_splitter.rs index b95b75d855f7f68c60943f1cc199e5bcc458820c..e220ea6cfd16c6d710665de0ba5a628ae9040426 100644 --- a/src/nodes/beam_splitter.rs +++ b/src/nodes/beam_splitter.rs @@ -13,6 +13,14 @@ type Result<T> = std::result::Result<T, OpossumError>; #[derive(Debug)] /// An ideal beamsplitter node with a given splitting ratio. +/// +/// ## Optical Ports +/// - Inputs +/// - `input1` +/// - `input2` +/// - Outputs +/// - `out1_trans1_refl2` +/// - `out2_trans2_refl1` pub struct BeamSplitter { ratio: f64, } diff --git a/src/nodes/detector.rs b/src/nodes/detector.rs index 5be9a44a5737aa0a86d5a68f358a0c760d560c1b..96878ce328ea9eb739e14db1633bb5460089f0f9 100644 --- a/src/nodes/detector.rs +++ b/src/nodes/detector.rs @@ -12,6 +12,12 @@ type Result<T> = std::result::Result<T, OpossumError>; /// This node represents an universal detector. /// /// Any [`LightData`] coming in will be stored internally for later display / export. So far it only has one input (in1). +/// +/// ## Optical Ports +/// - Inputs +/// - `in1` +/// - Outputs +/// - none pub struct Detector { light_data: Option<LightData>, } diff --git a/src/nodes/dummy.rs b/src/nodes/dummy.rs index 95d8b34a0c2fb8ab30d68963c940757b15029cce..ef52210dc30c6f1236a2422752d3379342764b5e 100644 --- a/src/nodes/dummy.rs +++ b/src/nodes/dummy.rs @@ -8,10 +8,16 @@ use crate::optic_ports::OpticPorts; type Result<T> = std::result::Result<T, OpossumError>; #[derive(Debug)] -/// A fake / dummy component without any functions. +/// A fake / dummy component without any optical functionality. /// /// Any [`LightResult`] is directly forwarded without any modification. It is mainly used for /// development and debugging purposes. +/// +/// ## Optical Ports +/// - Inputs +/// - `front` +/// - Outputs +/// - `rear` pub struct Dummy; impl Optical for Dummy { diff --git a/src/nodes/group.rs b/src/nodes/group.rs index e6ddd028895a6b24fb1600c6baa69f7d93259c21..02e7777ffc9b0d39b2f6204f72806cce61af0d3f 100644 --- a/src/nodes/group.rs +++ b/src/nodes/group.rs @@ -20,7 +20,14 @@ type Result<T> = std::result::Result<T, OpossumError>; #[derive(Default, Debug, Clone)] /// A node that represents a group of other [`OpticNode`]s arranges in a subgraph. /// -/// All unconnected input and output ports of this subgraph form the ports of this [`NodeGroup`]. +/// All unconnected input and output ports of this subgraph could be used as ports of +/// this [`NodeGroup`]. For this, port mapping is neccessary (see below). +/// +/// ## Optical Ports +/// - Inputs +/// - defined by [`map_input_port`](NodeGroup::map_input_port()) function. +/// - Outputs +/// - defined by [`map_output_port`](NodeGroup::map_output_port()) function. pub struct NodeGroup { g: DiGraph<Rc<RefCell<OpticNode>>, Light>, input_port_map: HashMap<String, (NodeIndex, String)>, diff --git a/src/nodes/ideal_filter.rs b/src/nodes/ideal_filter.rs index 97ca025ecc20e12712a45a6205c979428cf69c3e..8d68c8d0db4c57b4fc160e4b25b5abaa9dd31fb6 100644 --- a/src/nodes/ideal_filter.rs +++ b/src/nodes/ideal_filter.rs @@ -18,6 +18,12 @@ pub enum FilterType { } #[derive(Debug)] /// An ideal filter with given transmission or optical density. +/// +/// ## Optical Ports +/// - Inputs +/// - `front` +/// - Outputs +/// - `rear` pub struct IdealFilter { filter_type: FilterType, } diff --git a/src/nodes/reference.rs b/src/nodes/reference.rs index 7500dd32124470185a792f3091a8d53b5c2a3ffb..ae1d493428929021ccfb41474924515bff316d87 100644 --- a/src/nodes/reference.rs +++ b/src/nodes/reference.rs @@ -12,6 +12,12 @@ type Result<T> = std::result::Result<T, OpossumError>; /// A virtual component referring to another existing component. /// /// This node type is necessary in order to model resonators (loops) or double-pass systems. +/// +/// ## Optical Ports +/// - Inputs +/// - input ports of the referenced [`OpticNode`] +/// - Outputs +/// - output ports of the referenced [`OpticNode`] pub struct NodeReference { reference: Weak<RefCell<OpticNode>>, } diff --git a/src/nodes/source.rs b/src/nodes/source.rs index 6dc0a5cf0d72f461a3cd336ec825aa598d5ec803..dc4da3750f4346b3d421b5a05da47fc3ce7932a1 100644 --- a/src/nodes/source.rs +++ b/src/nodes/source.rs @@ -13,6 +13,12 @@ type Result<T> = std::result::Result<T, OpossumError>; /// This node represents a source of light. /// /// Hence it has only one output port (out1) and no input ports. Source nodes usually are the first nodes of an optic scenery. +/// +/// ## Optical Ports +/// - Inputs +/// - none +/// - Outputs +/// - `out1` #[derive(Default)] pub struct Source { light_data: Option<LightData>, diff --git a/src/optic_node.rs b/src/optic_node.rs index 9d989b7ba87272b4fb900d15474bf0c36b04a6ec..97806375a7d6fb0a6ab654a20529035c15313116 100644 --- a/src/optic_node.rs +++ b/src/optic_node.rs @@ -99,7 +99,7 @@ pub trait Optical { OpticPorts::default() } /// Perform an analysis of this element. The type of analysis is given by an [`AnalyzerType`]. - /// + /// /// This function is normally only called by [`OpticScenery::analyze()`](crate::optic_scenery::OpticScenery::analyze()). /// /// # Errors diff --git a/src/optic_scenery.rs b/src/optic_scenery.rs index 7f78c30c0e360443be9c3e51d6187ce9bbe877f2..607f0b39b38cb0eac7c7449b508722130fc204f1 100644 --- a/src/optic_scenery.rs +++ b/src/optic_scenery.rs @@ -16,7 +16,7 @@ use petgraph::Direction::{Incoming, Outgoing}; type Result<T> = std::result::Result<T, OpossumError>; /// Overall optical model and additional metatdata. -/// +/// /// All optical elements ([`OpticNode`]s) have to be added to this structure in order /// to be considered for an analysis. #[derive(Default, Debug, Clone)]