Skip to content
Snippets Groups Projects
Commit c183872e authored by Udo Eisenbarth's avatar Udo Eisenbarth :speech_balloon:
Browse files

Update further examples to just produce opm files.

parent 7c8a291c
No related branches found
No related tags found
No related merge requests found
Pipeline #7704 passed
use std::io::Write;
use std::{fs::File, path::Path};
use std::path::Path;
use opossum::{
analyzer::AnalyzerEnergy,
error::OpossumError,
lightdata::{DataEnergy, LightData},
nodes::{Detector, Dummy, NodeGroup, Source},
nodes::{Dummy, EnergyMeter, NodeGroup, Source},
optical::Optical,
spectrum::create_he_ne_spectrum,
OpticScenery,
......@@ -33,18 +31,11 @@ fn main() -> Result<(), OpossumError> {
group.set_property("inverted", true.into()).unwrap();
let i_g = scenery.add_node(group);
let i_d = scenery.add_node(Detector::default());
let i_d = scenery.add_node(EnergyMeter::default());
scenery.connect_nodes(i_s, "out1", i_g, "out1")?;
scenery.connect_nodes(i_g, "in1", i_d, "in1")?;
let path = "group_reverse.dot";
let mut output = File::create(path).unwrap();
write!(output, "{}", scenery.to_dot("")?).unwrap();
let mut analyzer = AnalyzerEnergy::new(&scenery);
analyzer.analyze()?;
scenery.report(Path::new(""));
scenery.save_to_file(Path::new("group_reverse.opm"))?;
Ok(())
}
use opossum::error::OpossumError;
use opossum::nodes::{BeamSplitter, Dummy, NodeGroup};
use opossum::OpticScenery;
use std::fs::File;
use std::io::Write;
use std::path::Path;
fn main() -> Result<(), OpossumError> {
let mut scenery = OpticScenery::new();
scenery.set_description("Node Group test section".into());
......@@ -39,10 +38,7 @@ fn main() -> Result<(), OpossumError> {
// set_output_port
scenery.connect_nodes(scene_g1, "out1", scene_g2, "in1")?;
println!("{}", serde_yaml::to_string(&scenery).unwrap());
let path = "graph_group.dot";
let mut output = File::create(path).unwrap();
write!(output, "{}", scenery.to_dot("LR")?).unwrap();
scenery.save_to_file(Path::new("group_test.opm"))?;
Ok(())
}
use std::io::Write;
use std::{fs::File, path::Path};
use opossum::optical::Optical;
use opossum::{
analyzer::AnalyzerEnergy,
error::OpossumError,
lightdata::{DataEnergy, LightData},
nodes::{BeamSplitter, EnergyMeter, Source},
spectrum::create_he_ne_spectrum,
OpticScenery,
};
use std::path::Path;
fn main() -> Result<(), OpossumError> {
let mut scenery = OpticScenery::new();
......@@ -37,19 +34,7 @@ fn main() -> Result<(), OpossumError> {
scenery.connect_nodes(i_bs, "input1", i_d1, "in1")?;
scenery.connect_nodes(i_bs, "input2", i_d2, "in1")?;
let serialized = serde_json::to_string_pretty(&scenery).unwrap();
let path = "inverse_beam_splitter_test.opm";
let mut output = File::create(path).unwrap();
write!(output, "{}", serialized).unwrap();
scenery.report(Path::new("./"));
println!("");
let mut analyzer = AnalyzerEnergy::new(&scenery);
print!("Analyze...");
analyzer.analyze()?;
println!("Sucessful");
println!("");
scenery.report(Path::new("./"));
scenery.save_to_file(Path::new("inverse_beam_splitter.opm"))?;
Ok(())
}
use opossum::nodes::{RealLens, Source};
use opossum::{nodes::Detector, OpticScenery};
use std::fs::File;
use std::io::Write;
use opossum::lightdata::{DataEnergy, LightData};
use opossum::nodes::{EnergyMeter, RealLens, Source};
use opossum::spectrum::create_he_ne_spectrum;
use opossum::OpticScenery;
use std::path::Path;
use opossum::error::OpossumError;
fn main() -> Result<(), OpossumError> {
let mut scenery = OpticScenery::new();
scenery.set_description("Lens Ray-trace test".into());
let src = scenery.add_node(Source::default());
let src = scenery.add_node(Source::new(
"Source",
LightData::Energy(DataEnergy {
spectrum: create_he_ne_spectrum(1.0),
}),
));
let l1 = scenery.add_node(RealLens::default()); // Lens 1
let l2 = scenery.add_node(RealLens::default()); // Lens 2
let det = scenery.add_node(Detector::default());
let det = scenery.add_node(EnergyMeter::default());
scenery.connect_nodes(src, "out1", l1, "in1")?;
scenery.connect_nodes(l1, "out1", l2, "in1")?;
scenery.connect_nodes(l2, "out1", det, "in1")?;
let path = "lens_system.dot";
let mut output = File::create(path).unwrap();
write!(output, "{}", scenery.to_dot("")?).unwrap();
scenery.save_to_file(Path::new("lens_system.opm"))?;
Ok(())
}
use opossum::{error::OpossumError, optical::OpticGraph};
fn main() -> Result<(), OpossumError> {
let optic_graph = OpticGraph::default();
let serialized = serde_yaml::to_string(&optic_graph).unwrap();
println!("serialized:\n{}", serialized);
let restored_ref = serde_yaml::from_str::<OpticGraph>(&serialized).unwrap();
println!("restored:\n{:?}", restored_ref);
Ok(())
}
use std::{cell::RefCell, rc::Rc};
use opossum::{error::OpossumError, nodes::Dummy, optical::OpticRef};
fn main() -> Result<(), OpossumError> {
let optic_ref = OpticRef(Rc::new(RefCell::new(Dummy::default())));
let serialized = serde_yaml::to_string(&optic_ref).unwrap();
println!("serialized:\n{}", serialized);
let restored_ref = serde_yaml::from_str::<OpticRef>(&serialized).unwrap();
println!("restored:\n{:?}", restored_ref);
Ok(())
}
use opossum::analyzer::AnalyzerEnergy;
use opossum::error::OpossumError;
use opossum::nodes::{BeamSplitter, Dummy};
use opossum::OpticScenery;
use std::fs::File;
use std::io::Write;
use std::path::Path;
fn main() -> Result<(), OpossumError> {
println!("PHELIX uOPA opticscenery example");
let mut scenery = OpticScenery::new();
scenery.set_description("PHELIX uOPA");
......@@ -160,16 +156,7 @@ fn main() -> Result<(), OpossumError> {
// scenery.connect_nodes(pump_bs_node1, pump_kepler_node1);
// scenery.connect_nodes(pump_kepler_node1, dichroic_node1);
let path = "uOPA.dot";
let mut output = File::create(path).unwrap();
write!(output, "{}", scenery.to_dot("")?).unwrap();
let path = "uOPA_PreAmp.dot";
let mut output = File::create(path).unwrap();
write!(output, "{}", scenery_2.to_dot("")?).unwrap();
let mut analyzer = AnalyzerEnergy::new(&scenery);
analyzer.analyze()?;
scenery.save_to_file(Path::new("uOPA.opm"))?;
scenery_2.save_to_file(Path::new("uOPA_PreAmp.opm"))?;
Ok(())
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment