Add plot method for BaseSolution
I made this model and wanted to perform two beam traces:
l laser P=10
s sltoPMC laser.p1 PMC.p1 L=1
bs PMC R=1 T=0 alpha=0.1
s sPMCtoSM1 PMC.p2 SM1.p1 L=0.637
bs SM1 R=1 T=0 alpha=0.1 Rc=2.0
s sSM1toSM2 SM1.p2 SM2.p1 L=11.4
bs SM2 R=1 T=0 alpha=0.1 Rc=24.0
s sSM2toSM3 SM2.p2 SM3.p1 L=11.5
bs SM3 R=1 T=0 alpha=45
s sSM3toSM4 SM3.p2 SM4.p1 L=0.5
bs SM4 R=1 T=0 alpha=45
s sSM4toBS SM4.p2 BS.p1 L=0.5
bs BS T=0.5 L=1.5e-5 alpha=45
s sBStoITMX BS.p2 ITMXAR.p1 L=0.525
m ITMXAR R=0.0 L=0.0 Rc=-1.776
s sITMXARtoITMXHR ITMXAR.p2 ITMXHR.p1 L=0.02446 nr=1.449631
m ITMXHR T=0.00822 L=1.5e-05 phi=90.0 Rc=-5.7
s sXarm ITMXHR.p2 ETMX.p1 L=11.3673
m ETMX T=1.5e-05 L=0.0 phi=90.01218045112782 Rc=5.7
s sBStoITMY BS.p3 ITMYAR.p1 L=0.475
m ITMYAR R=0.0 L=0.0 Rc=-1.776
s sITMYARtoITMYHR ITMYAR.p2 ITMYHR.p1 L=0.02446 nr=1.449631
m ITMYHR T=0.00822 L=1.5e-05 Rc=-5.7
s sYarm ITMYHR.p2 ETMY.p1 L=11.3673
m ETMY T=1.5e-05 L=0.0 phi=-0.012180451127819547 Rc=5.7
s sDP BS.p4 tpout.p1 L=1.0
nothing tpout
cav cavXARM ITMXHR.p2
cav cavYARM ITMYHR.p2
pd pd1 tpout.p2
series(
propagate_beam(from_node=laser.p1, to_node=ETMX.p1),
propagate_beam(from_node=laser.p1, to_node=ETMY.p1)
)
With the CLI, running kat3 mymodel.kat
it just prints the following:
Solution:
- Solution Tree
○ series
├──● propagation - PropagationSolution
╰──● propagation - PropagationSolution
This is because the CLI tries to call solution.plot(show=True)
on the solution if plot()
exists. But since series()
produces a BaseSolution
, which doesn't have a plot()
, there is no plot.
This MR adds a plot method to BaseSolution
which plots its children in turn. Some extra logic lets users specify keyword arguments for individual childrens' plot methods, and global methods. In general we should clean up the solution plotting API (see #191).
The result is that the CLI calls plot
on the BaseSolution
representing the series
, and yields the two propagation plots:
I thought I'd make this an MR in case @daniel-brown has other plans for how to handle series()
and parallel()
results long term.