2

I'm wanting to create a custom component using the pst-optexp package. So far, I've figured out how to make a two-port custom component that shows the internal structure, but I can't figure out how to make a three-port custom component that shows the internal structure.

Perhaps the solution is to do something like makeatletter and makeatother. I was able to use this to get the square wave for the function generator, but I don't have enough LaTeX mana to cast that sort of wizardry on the \optdipolecomp.

enter image description here

enter image description here

\documentclass[border=12pt]{standalone}
\usepackage{pstricks}
\usepackage{pst-optexp}
\usepackage{auto-pst-pdf}


\makeatletter
    \def\elecsynthesizer@custom{%
    \psline(-0.25,0)(-0.25,0.15)(0,.15)%
    (0,-.15)(0.25,-.15)(.25,0)}
\makeatother

\begin{document}

    \begin{pspicture}[showgrid](-2, 2)(12,-12)

    \def\loopRadius{1}
    \def\loopAngleOne{135}
    \def\loopAngleTwo{45}

    \pnode(5.5,-6){loopCenter}
    \pnode([nodesep=\loopRadius,angle=135]loopCenter){loopTop}
    \pnode([nodesep=\loopRadius,angle=-135]loopCenter){loopBottom}

    \addtopsstyle{Fiber}{linecolor=red}
    \psset{fiber=none}
    \newpsstyle{OptCircArrow}{arrows=<-,unit=.6}



    \def\phasemodulatorcomp{%

        \psframe(-.7,-0.4)(.7,0.4)
        \psline(-.7,0)(-.2,0)(.1,.3)(.7,.3)
        \psline(-.2,0)(.1,-.3)(.7,-.3)}

%%%%%%%%%%%%%%%%%%% DOES NOT SHOW THE INTERNAL STRUCTURE, BUT HAS TWO PORTS 
    \newpsobject{mioc}{fiberbox}{fiberboxcount=1x2,fiberboxsize=1.5 0.8, extnode=b,showifcnodes }


%%%%%%%%%%%%%%%%%% SHOWS THE INTERNAL STRUCTURE, BUT ONLY HAS ONE PORT ON EACH SIDE
    %\newpsobject{mioc}{optdipole}{optdipolesize=1.5 0.8,optdipolecomp={\phasemodulatorcomp}, extnode=b,showifcnodes }

    \pnodes(3,0){A}(6,0){B}


    \pnode(0,0){A}
    \pnode([nodesep=5,angle=-90]A){B}
    \pnode([nodesep=1,angle=-90]B){circ}
    \pnode([nodesep=2,angle=0]circ){miocLoc}
    \pnode([nodesep=3,angle=-90]circ){detectorLoc}

    \optbox     [position=start,compname=laser,labelref=relative,labeloffset=0](A)(B){laser}
    \optisolator[position=.4,compname=isolator](A)(B)
    \optbox     [position=.8,extnode=b,compname=EOM,labelref=relative,labeloffset=0](A)(B){EOM}

    \pnode(\oenodeExt{EOM}){pmr}

    \pnode([nodesep=10,angle=0]pmr){E}

    \optbox[compname=noiseGen,position=start,labeloffset=0,labelref=relative](E)(pmr){noise}
    \optamp[position=.1,compname=preamp1](E)(pmr){+12 dB}
    \optamp[position=.3,compname=preamp2](E)(pmr){+12 dB}
    \optbox[position=.5,compname=attenuators](E)(pmr){-7 dB}
    \optamp[position=.7,compname=preamp3](E)(pmr){+12 dB}
    \optamp[position=.9,compname=amp](E)(pmr){+14 dB}

    \drawwire{noiseGen}{preamp1}{preamp2}{attenuators}{preamp3}{amp}(pmr)

    \optcirculator[optcircangle=180 0,compname=circulator](detectorLoc)(B)(miocLoc)

    \drawfiber{laser}{isolator}{EOM}{circulator}



    \mioc[position=end,compname=mioc,labeloffset=0](circ)(miocLoc){MIOC}
    \drawfiber[startnode=2,fiberangleA=-90]{circulator}{mioc}


    \drawfiber[startnode=2,fiberangleB=\loopAngleTwo]{mioc}(loopTop)
    \drawfiber[startnode=3,fiberangleB=-\loopAngleTwo]{mioc}(loopBottom)
    \psarc[linecolor=red]{-}(loopCenter){\loopRadius}{-\loopAngleOne}{\loopAngleOne}




    \optdetector[compname=detector,dettype=diode,extnode=b](circ)(detectorLoc)

    \pnode(\oenodeExt{detector}){detectorExit}
    \pnode([nodesep=4,angle=0]detectorExit){liaLoc}
    \optbox[position=end,compname=lia,extnode=t,labeloffset=0](detectorExit)(\oenodeExt{mioc}|liaLoc){LIA}

    \elecsynthesizer[position=.5,synthtype=custom](\oenodeExt{mioc})(\oenodeExt{lia})

    \drawwire(detectorExit){lia}
    \drawfiber{circulator}{detector}
    \pnode([nodesep=2,angle=0]liaLoc){output}
    \cnodeput([nodesep=1,angle=0]output){output2}{output}
    \drawwire[arrows=->]{lia}(output)

    \end{pspicture}
%
\end{document}
2

In order to draw a fiberbox with custom internal structure you must define your own macro to call \fiberbox with changed \fiberbox@comp. The internal macro fiberbox@comp simply draws the fiberbox rectangle. Here, you already have access to the fiberbox's input and output nodes which you use with \oenode{1}{}:

\documentclass[border=12pt]{standalone}
\usepackage{pst-optexp}
\usepackage{auto-pst-pdf}

\makeatletter
\def\phasemodulatorcomp{%
  \pcdiag[angleB=180, arm=0.6](\oenode{1}{})(\oenode{2}{})
  \pcdiag[angleB=180, arm=0.6](\oenode{1}{})(\oenode{N}{})}

\def\mioc{%
   \let\fiberbox@comp@orig\fiberbox@comp
   \def\fiberbox@comp{\fiberbox@comp@orig\phasemodulatorcomp}
   \fiberbox}
\makeatother

\begin{document}
\begin{pspicture}(6,2)
  \addtopsstyle{Fiber}{linecolor=red}
  \pnode(0,1){In}
  \pnode(2,1){Out}
  \mioc[fiberboxcount=1x2, fiberboxsize=1.5 0.8, extnode=b,showifcnodes, position=end,compname=mioc](In)(Out){MIOC}
  \drawfiber{}([Xnodesep=1, offset=0.4]\oenode{2}{})
  \drawfiber{}([Xnodesep=1, offset=-0.4]\oenode{3}{})
  \pccurve[style=Fiber, ncurv=1.2]([Xnodesep=1, offset=0.4]\oenode{2}{})([Xnodesep=1, offset=-0.4]\oenode{3}{})
\end{pspicture}
\end{document}

enter image description here

That makes me think of adding a parameter fiberboxcomp or similar which would allow you to define the "derived" fiberbox with it's internal structure with \newpsobject. Maybe it would be worth doing this also for the elecsynthesizer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.