Ejemplo n.º 1
0
from pyrateoptics.raytracer.optical_element import OpticalElement
from pyrateoptics.raytracer.surface import Surface
from pyrateoptics.raytracer.optical_system import OpticalSystem

from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates
from pyrateoptics.raytracer.globalconstants import degree

from pyrateoptics import draw, raytrace

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

# definition of optical system
s = OpticalSystem.p(name='os')

lc0 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="stop", decz=1.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf1", decz=10.0),
                                 refname=lc0.name)
lc2 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf2",
                                                    decz=5.0,
                                                    tiltx=10 * math.pi /
                                                    180.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="image",
                                                    decz=-5.0,
                                                    tiltx=-10 * math.pi /
                                                    180.0),
                                 refname=lc2.name)
Ejemplo n.º 2
0
from pyrateoptics.core.base_ui import UIInterfaceClassWithOptimizableVariables
from pyrateoptics.core.serializer import Serializer


from pyrateoptics.raytracer.globalconstants import degree
from pyrateoptics import raytrace, draw

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

wave_red = 0.700e-3
wave_blue = 0.470e-3

# definition of optical system
s = OpticalSystem.p()

dropletradius = 0.1

lc0 = s.addLocalCoordinateSystem(
            LocalCoordinates.p(name="stop", decz=0.0),
            refname=s.rootcoordinatesystem.name)
lccomprism = s.addLocalCoordinateSystem(
            LocalCoordinates.p(name="dropletcenter", decz=2.*dropletradius),
            refname=lc0.name)

lc1 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf1",
                                                    decz=-dropletradius),
                                 refname=lccomprism.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(
            LocalCoordinates.p(name="surf2", decz=dropletradius),
Ejemplo n.º 3
0
    ShapeAnalysis

from pyrateoptics.sampling2d.raster import RandomGrid

from pyrateoptics.optimize.optimize import Optimizer
from pyrateoptics.optimize.optimize_backends import (ScipyBackend,
                                                     Newton1DBackend,
                                                     ParticleSwarmBackend,
                                                     SimulatedAnnealingBackend)

wavelength = standard_wavelength

logging.basicConfig(level=logging.DEBUG)

# definition of optical system
s = OpticalSystem.p()  # objectDistance = 2.0

lc0 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf1", decz=2.0),
                                 refname=lc0.name)
# objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf2", decz=3.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf3",
                                                    decz=5.0,
                                                    tiltx=2.5 * degree),
                                 refname=lc2.name)
lc4 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf4", decz=3.0),
                                 refname=lc3.name)
lc5 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf5", decz=3.0),
Ejemplo n.º 4
0
 def create():
     s = OpticalSystem.p()
     return s
Ejemplo n.º 5
0
    OpticalSystemAnalysis

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

rnd_data1 = np.random.random((3, 3))  # np.eye(3)
rnd_data2 = np.random.random((3, 3))  # np.zeros((3, 3))#
lc = LocalCoordinates.p("1")
myeps = np.eye(3) + 0.1 * rnd_data1 + 0.01 * complex(0, 1) * rnd_data2
# aggressive complex choice of myeps
# myeps = np.eye(3) + 0.01*np.random.random((3, 3))
crystal = AnisotropicMaterial.p(lc, myeps)

# definition of optical system
s = OpticalSystem.p(matbackground=crystal)

lc0 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="m1",
                                                    decz=50.0,
                                                    tiltx=-math.pi / 8),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="m2_stop",
                                                    decz=-50.0,
                                                    decy=-20,
                                                    tiltx=math.pi / 16),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="m3",
                                                    decz=50.0,
                                                    decy=-30,
Ejemplo n.º 6
0
    def __init__(self, doc, name):
        self.__doc = doc
        obj = doc.addObject("App::FeaturePython", name)
        self.__obj = obj
        obj.Proxy = self

        self.__NameOSGroup = Group_OS_Label + "_" + uuidToName(uuid.uuid4())
        self.__NameSurfaceGroup = Group_Surface_Label + "_" + uuidToName(
            uuid.uuid4())
        self.__NameFunctionsGroup = Group_Functions_Label + "_" + uuidToName(
            uuid.uuid4())
        self.__NameCoordinatesGroup = Group_Coordinates_Label + "_" + uuidToName(
            uuid.uuid4())

        self.__group = doc.addObject("App::DocumentObjectGroup",
                                     self.__NameOSGroup)
        self.__group.addObject(obj)

        self.__surfacegroup = doc.addObject("App::DocumentObjectGroup",
                                            self.__NameSurfaceGroup)
        self.__functionsgroup = doc.addObject("App::DocumentObjectGroup",
                                              self.__NameFunctionsGroup)
        self.__coordinatesgroup = doc.addObject("App::DocumentObjectGroup",
                                                self.__NameCoordinatesGroup)

        self.__group.addObject(self.__surfacegroup)
        self.__group.addObject(self.__functionsgroup)
        self.__group.addObject(self.__coordinatesgroup)

        self.__functionsgroup.Label = Group_Functions_Label + "_" + name
        self.__surfacegroup.Label = Group_Surface_Label + "_" + name
        self.__coordinatesgroup.Label = Group_Coordinates_Label + "_" + name
        self.__group.Label = Group_OS_Label + "_" + name

        # TODO: all properties are not really operational

        # group links

        obj.addProperty("App::PropertyString", "NameOSGroup", "Groups",
                        "Name of OS Group").NameOSGroup = self.__NameOSGroup
        obj.addProperty("App::PropertyString", "NameFunctionsGroup", "Groups",
                        "Name of Functions Group"
                        ).NameFunctionsGroup = self.__NameFunctionsGroup
        obj.addProperty(
            "App::PropertyString", "NameSurfaceGroup", "Groups",
            "Name of Surface Group").NameSurfaceGroup = self.__NameSurfaceGroup
        obj.addProperty("App::PropertyString", "NameCoordinatesGroup",
                        "Groups", "Name of Coordinates Group"
                        ).NameCoordinatesGroup = self.__NameCoordinatesGroup

        obj.setEditorMode("NameOSGroup", 1)  # readonly
        obj.setEditorMode("NameFunctionsGroup", 1)  # readonly
        obj.setEditorMode("NameSurfaceGroup", 1)  # readonly
        obj.setEditorMode("NameCoordinatesGroup", 1)  # readonly

        # OS Properties

        obj.addProperty("App::PropertyPythonObject", "osclass", "OS",
                        "os class interface").osclass = OpticalSystem.p()

        obj.addProperty("App::PropertyPythonObject", "coords", "OS",
                        "os coords interface").coords = LC(
                            None, obj.osclass.rootcoordinatesystem, doc,
                            self.__coordinatesgroup)
        obj.addProperty("App::PropertyFloatList", "wavelengths", "OS",
                        "wavelengths list").wavelengths = [550.0e-6]
        obj.addProperty("App::PropertyLinkList", "surfaces", "OS",
                        "surface list").surfaces = []

        # Field properties

        obj.addProperty("App::PropertyPythonObject", "fieldpoints", "Field",
                        "Field points").fieldpoints = np.array([[0, 0]])
        obj.addProperty(
            "App::PropertyPythonObject", "fieldpointsbool", "Field",
            "Field points used?").fieldpointsbool = np.array([True],
                                                             dtype=bool)
        obj.addProperty("App::PropertyEnumeration",
                        "fieldtype",
                        "Field",
                        "Type of field?").fieldtype = \
                                ["ObjectHeight",
                                 "ObjectChiefAngle",
                                 "ParaxialImageHeight"]

        # Aiming properties

        obj.addProperty("App::PropertyInteger", "stopposition", "Aiming",
                        "Which surface is stop?").stopposition = 0
        obj.addProperty("App::PropertyEnumeration",
                        "pupiltype",
                        "Aiming",
                        "Type of pupil?").pupiltype = \
                                        ["EntrancePupilDiameter",
                                        "EntrancePupilRadius",
                                        "StopDiameter",
                                        "StopRadius",
                                        "ExitPupilDiameter",
                                        "ExitPupilRadius",
                                        "InfiniteConjugateImageSpaceFNumber",
                                        "InfiniteConjugateObjectSpaceFNumber",
                                        "WorkingImageSpaceFNumber",
                                        "WorkingObjectSpaceFNumber",
                                        "ObjectSpaceNA",
                                        "ImageSpaceNA"]
        obj.addProperty("App::PropertyDistance", "pupilsize", "Aiming",
                        "Pupil size?").pupilsize = 1.0
        obj.addProperty("App::PropertyEnumeration",
                        "rastertype",
                        "Aiming",
                        "Type of pupil rasterization?").rastertype = \
                                                            ["RectGrid",
                                                             "HexGrid",
                                                             "RandomGrid",
                                                             "PoissonDiskSampling",
                                                             "MeridionalFan",
                                                             "SagitalFan",
                                                             "ChiefAndComa",
                                                             "Single"]
        # TODO: -> text file
        obj.addProperty("App::PropertyInteger", "numrays", "Aiming",
                        "How many rays to be drawn?").numrays = 10
Ejemplo n.º 7
0
    def initDemoSystem(self):
        s = OpticalSystem.p()

        lc0 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="object",
                                                            decz=0.0),
                                         refname=s.rootcoordinatesystem.name)
        lc1 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf1",
                                                            decz=2.0),
                                         refname=lc0.name)  # objectDist
        lc2 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf2",
                                                            decz=3.0),
                                         refname=lc1.name)
        lc3 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf3",
                                                            decz=5.0,
                                                            tiltx=0.0 *
                                                            math.pi / 180.0),
                                         refname=lc2.name)
        lc4 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf4",
                                                            decz=3.0),
                                         refname=lc3.name)
        lc5 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf5",
                                                            decz=3.0),
                                         refname=lc4.name)
        lc6 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf6",
                                                            decz=2.0),
                                         refname=lc5.name)
        lc7 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf7",
                                                            decz=3.0),
                                         refname=lc6.name)
        lc8 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="image",
                                                            decz=19.0),
                                         refname=lc7.name)

        objectsurf = Surface.p(lc0)
        surf1 = Surface.p(lc1,
                          shape=Conic.p(lc1, curv=1 / -5.922),
                          aperture=CircularAperture.p(lc1, maxradius=10.0))
        surf2 = Surface.p(lc2,
                          shape=Conic.p(lc2, curv=1 / -3.160),
                          aperture=CircularAperture.p(lc2, maxradius=10.0))
        surf3 = Surface.p(lc3,
                          shape=Conic.p(lc3, curv=1 / 15.884),
                          aperture=CircularAperture.p(lc3, maxradius=10.0))
        surf4 = Surface.p(lc4,
                          shape=Conic.p(lc4, curv=1 / -12.756),
                          aperture=CircularAperture.p(lc4, maxradius=10.0))
        stopsurf = Surface.p(lc5,
                             aperture=CircularAperture.p(lc5, maxradius=10.0))
        surf6 = Surface.p(lc6,
                          shape=Conic.p(lc6, curv=1 / 3.125),
                          aperture=CircularAperture.p(lc6, maxradius=10.0))
        surf7 = Surface.p(lc7,
                          shape=Conic.p(lc7, curv=1 / 1.479),
                          aperture=CircularAperture.p(lc7, maxradius=10.0))
        image = Surface.p(lc8)

        elem = OpticalElement.p(lc0, name="lenssystem")

        glass = material_isotropic.ConstantIndexGlass.p(lc0, n=1.7)
        glass2 = material_isotropic.ConstantIndexGlass.p(lc0, n=1.5)

        elem.addMaterial("glass", glass)
        elem.addMaterial("glass2", glass2)

        elem.addSurface("object", objectsurf, (None, None))
        elem.addSurface("surf1", surf1, (None, "glass"))
        elem.addSurface("surf2", surf2, ("glass", None))
        elem.addSurface("surf3", surf3, (None, "glass"))
        elem.addSurface("surf4", surf4, ("glass", None))
        elem.addSurface("stop", stopsurf, (None, None))
        elem.addSurface("surf6", surf6, (None, "glass2"))
        elem.addSurface("surf7", surf7, ("glass2", None))
        elem.addSurface("image", image, (None, None))

        for mysurf in elem.surfaces.values():
            print(mysurf.aperture.annotations)

        s.addElement("lenssys", elem)

        return s