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

Fixed switched axis labels for HitMap.

Fixed some missing statements in ghost focus analysis for Wedge.
Add Wedge to ghot_focus example.
parent 36ed49b3
No related branches found
No related tags found
No related merge requests found
use opossum::{ use opossum::{
analyzers::{AnalyzerType, GhostFocusConfig}, analyzers::{AnalyzerType, GhostFocusConfig},
coatings::CoatingType, coatings::CoatingType,
degree,
error::OpmResult, error::OpmResult,
joule, millimeter, joule, millimeter,
nodes::{round_collimated_ray_source, Lens, NodeGroup, SpotDiagram}, nodes::{round_collimated_ray_source, Lens, NodeGroup, SpotDiagram, Wedge},
optic_node::OpticNode, optic_node::{Alignable, OpticNode},
optic_ports::PortType, optic_ports::PortType,
refractive_index::RefrIndexConst,
OpmDocument, OpmDocument,
}; };
use std::path::Path; use std::path::Path;
...@@ -33,14 +35,27 @@ fn main() -> OpmResult<()> { ...@@ -33,14 +35,27 @@ fn main() -> OpmResult<()> {
lens.set_coating(&PortType::Input, "front", &CoatingType::Fresnel)?; lens.set_coating(&PortType::Input, "front", &CoatingType::Fresnel)?;
lens.set_coating(&PortType::Output, "rear", &CoatingType::Fresnel)?; lens.set_coating(&PortType::Output, "rear", &CoatingType::Fresnel)?;
let i_l = scenery.add_node(lens)?; let i_l = scenery.add_node(lens)?;
let mut wedge = Wedge::new(
"wedge",
millimeter!(20.0),
degree!(10.0),
&RefrIndexConst::new(1.5)?,
)?
.with_tilt(degree!(0.0, 5.0, 0.0))?;
wedge.set_coating(&PortType::Input, "front", &CoatingType::Fresnel)?;
wedge.set_coating(&PortType::Input, "front", &CoatingType::Fresnel)?;
let i_w=scenery.add_node(wedge)?;
let i_sd2 = scenery.add_node(SpotDiagram::default())?; let i_sd2 = scenery.add_node(SpotDiagram::default())?;
scenery.connect_nodes(i_src, "out1", i_sd, "in1", millimeter!(20.0))?; scenery.connect_nodes(i_src, "out1", i_sd, "in1", millimeter!(20.0))?;
scenery.connect_nodes(i_sd, "out1", i_l, "front", millimeter!(80.0))?; scenery.connect_nodes(i_sd, "out1", i_l, "front", millimeter!(80.0))?;
scenery.connect_nodes(i_l, "rear", i_sd2, "in1", millimeter!(70.0))?; scenery.connect_nodes(i_l, "rear", i_w, "front", millimeter!(70.0))?;
scenery.connect_nodes(i_w, "rear", i_sd2, "in1", millimeter!(70.0))?;
let mut doc = OpmDocument::new(scenery); let mut doc = OpmDocument::new(scenery);
let mut config = GhostFocusConfig::default(); let mut config = GhostFocusConfig::default();
config.set_max_bounces(2); config.set_max_bounces(1);
doc.add_analyzer(AnalyzerType::GhostFocus(config)); doc.add_analyzer(AnalyzerType::GhostFocus(config));
doc.save_to_file(Path::new("./opossum/playground/ghost_focus.opm")) doc.save_to_file(Path::new("./opossum/playground/ghost_focus.opm"))
} }
...@@ -358,7 +358,6 @@ impl Lens { ...@@ -358,7 +358,6 @@ impl Lens {
let reflected_front = rays.refract_on_surface(&mut self.front_surf, Some(&ambient_idx))?; let reflected_front = rays.refract_on_surface(&mut self.front_surf, Some(&ambient_idx))?;
self.front_surf.set_forward_rays_cache(reflected_front); self.front_surf.set_forward_rays_cache(reflected_front);
rays.merge(self.front_surf.backwards_rays_cache()); rays.merge(self.front_surf.backwards_rays_cache());
if let Some(aperture) = self.ports().aperture(&PortType::Input, "rear") { if let Some(aperture) = self.ports().aperture(&PortType::Input, "rear") {
rays.apodize(aperture)?; rays.apodize(aperture)?;
if let AnalyzerType::RayTrace(config) = analyzer_type { if let AnalyzerType::RayTrace(config) = analyzer_type {
......
...@@ -72,6 +72,7 @@ impl Default for Wedge { ...@@ -72,6 +72,7 @@ impl Default for Wedge {
.create_property("wedge", "wedge angle", None, Angle::zero().into()) .create_property("wedge", "wedge angle", None, Angle::zero().into())
.unwrap(); .unwrap();
let mut ports = OpticPorts::new(); let mut ports = OpticPorts::new();
ports.add(&PortType::Input, "front").unwrap(); ports.add(&PortType::Input, "front").unwrap();
ports.add(&PortType::Output, "rear").unwrap(); ports.add(&PortType::Output, "rear").unwrap();
node_attr.set_ports(ports); node_attr.set_ports(ports);
...@@ -192,6 +193,13 @@ impl Wedge { ...@@ -192,6 +193,13 @@ impl Wedge {
let ambient_idx = self.ambient_idx(); let ambient_idx = self.ambient_idx();
let mut rays = incoming_rays; let mut rays = incoming_rays;
self.front_surf.set_isometry(iso); self.front_surf.set_isometry(iso);
self.front_surf.set_coating(
self.node_attr()
.ports()
.coating(&PortType::Input, "front")
.unwrap()
.clone(),
);
let thickness_iso = Isometry::new_along_z(thickness)?; let thickness_iso = Isometry::new_along_z(thickness)?;
let wedge_iso = Isometry::new( let wedge_iso = Isometry::new(
Point3::origin(), Point3::origin(),
...@@ -199,7 +207,14 @@ impl Wedge { ...@@ -199,7 +207,14 @@ impl Wedge {
)?; )?;
let isometry = iso.append(&thickness_iso).append(&wedge_iso); let isometry = iso.append(&thickness_iso).append(&wedge_iso);
self.rear_surf.set_isometry(&isometry); self.rear_surf.set_isometry(&isometry);
if let Some(aperture) = self.ports().aperture(&PortType::Input, "rear") { self.rear_surf.set_coating(
self.node_attr()
.ports()
.coating(&PortType::Output, "rear")
.unwrap()
.clone(),
);
if let Some(aperture) = self.ports().aperture(&PortType::Output, "front") {
rays.apodize(aperture)?; rays.apodize(aperture)?;
if let AnalyzerType::RayTrace(config) = analyzer_type { if let AnalyzerType::RayTrace(config) = analyzer_type {
rays.invalidate_by_threshold_energy(config.min_energy_per_ray())?; rays.invalidate_by_threshold_energy(config.min_energy_per_ray())?;
...@@ -211,11 +226,10 @@ impl Wedge { ...@@ -211,11 +226,10 @@ impl Wedge {
self.rear_surf.set_forward_rays_cache(reflected_rear); self.rear_surf.set_forward_rays_cache(reflected_rear);
rays.merge(self.rear_surf.backwards_rays_cache()); rays.merge(self.rear_surf.backwards_rays_cache());
rays.set_refractive_index(refri)?; rays.set_refractive_index(refri)?;
let reflected_front = rays.refract_on_surface(&mut self.front_surf, Some(&ambient_idx))?; let reflected_front = rays.refract_on_surface(&mut self.front_surf, Some(&ambient_idx))?;
self.front_surf.set_forward_rays_cache(reflected_front); self.front_surf.set_forward_rays_cache(reflected_front);
rays.merge(self.front_surf.backwards_rays_cache()); rays.merge(self.front_surf.backwards_rays_cache());
if let Some(aperture) = self.ports().aperture(&PortType::Output, "front") { if let Some(aperture) = self.ports().aperture(&PortType::Input, "rear") {
rays.apodize(aperture)?; rays.apodize(aperture)?;
if let AnalyzerType::RayTrace(config) = analyzer_type { if let AnalyzerType::RayTrace(config) = analyzer_type {
rays.invalidate_by_threshold_energy(config.min_energy_per_ray())?; rays.invalidate_by_threshold_energy(config.min_energy_per_ray())?;
......
...@@ -82,8 +82,8 @@ impl Plottable for HitMap { ...@@ -82,8 +82,8 @@ impl Plottable for HitMap {
let y_prefix = get_prefix_for_base_unit(y_max); let y_prefix = get_prefix_for_base_unit(y_max);
let x_prefix = get_prefix_for_base_unit(x_max); let x_prefix = get_prefix_for_base_unit(x_max);
plt_type.set_plot_param(&PlotArgs::YLabel(format!("x position ({y_prefix}m)")))?; plt_type.set_plot_param(&PlotArgs::XLabel(format!("x position ({y_prefix}m)")))?;
plt_type.set_plot_param(&PlotArgs::XLabel(format!("y position ({x_prefix}m)")))?; plt_type.set_plot_param(&PlotArgs::YLabel(format!("y position ({x_prefix}m)")))?;
let mut plt_series = Vec::<PlotSeries>::with_capacity(1); let mut plt_series = Vec::<PlotSeries>::with_capacity(1);
let x_vals = xy_pos let x_vals = xy_pos
......
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