def dummycreate4(self): self.os = OpticalSystem(objectDistance=20.0) # reinit os #self.os.surfaces[1].shape.sdia.val = 1e10 def nfun(x, y, z): return 0.5*np.exp(-x**2 - 4.*y**2)+1.0#(2.5 - (x**2 + 100.0*y**4)/10.**2) def ndx(x, y, z): return -2.*x*0.5*np.exp(-x**2 - 4.*y**2)#-2*x/10.**2 def ndy(x, y, z): return -2.*4.*y*0.5*np.exp(-x**2 - 4.*y**2) #-100.0*4.0*y**3/10.**2 def ndz(x, y, z): return np.zeros_like(x) def boundarycheck(x, y, z): return np.ones_like(x, dtype=bool) self.os.insertSurface(1, Surface(surfShape.Conic(curv=-1./24.), thickness = 30.0, material=material.GrinMaterial(nfun, ndx, ndy, ndz, 0.01, 1e-3, boundarycheck), aperture=aperture.CircularAperture(5.0) ) ) self.os.insertSurface(2, Surface(surfShape.Conic(curv=1./24.), thickness = 10.0, aperture=aperture.CircularAperture(5.0) ) )
def dummycreate( self): # should only create the demo system, will be removed later self.os = OpticalSystem(objectDistance=2.0) # reinit os #self.os.surfaces[1].shape.sdia.val = 1e10 # radius of image plane may not be zero to be sure to catch all rays self.os.insertSurface( 1, Surface(surfShape.Conic(curv=1 / -5.922), thickness=3.0, material=material.ConstantIndexGlass(1.7))) # 0.55 self.os.insertSurface(2, Surface(surfShape.Conic(curv=1 / -3.160), thickness=5.0)) # 1.0 self.os.insertSurface( 3, Surface(surfShape.Conic(curv=1 / 15.884), thickness=3.0, material=material.ConstantIndexGlass(1.7))) # 1.3 self.os.insertSurface(4, Surface(surfShape.Conic(curv=1 / -12.756), thickness=3.0)) # 1.3 self.os.insertSurface(5, Surface(surfShape.Conic(), thickness=2.0)) # semidiam=1.01 # STOP self.os.insertSurface( 6, Surface(surfShape.Conic(curv=1 / 3.125), thickness=3.0, material=material.ConstantIndexGlass(1.5))) # semidiam=1.0 self.os.insertSurface(7, Surface(surfShape.Conic(curv=1 / 1.479), thickness=19.0)) # semidiam=1.0
def dummycreate2(self): self.os = OpticalSystem(objectDistance=20.0) # reinit os #self.os.surfaces[1].shape.sdia.val = 1e10 self.os.insertSurface( 1, Surface(surfShape.Conic(curv=-1. / 24.), thickness=-30.0, material=material.Mirror(), aperture=aperture.CircularAperture(5.0)))
def initDemoSystem(self): s = OpticalSystem() lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0), refname=s.rootcoordinatesystem.name) lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=2.0), refname=lc0.name) # objectDist lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2", decz=3.0), refname=lc1.name) lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf3", decz=5.0, tiltx=0.0*math.pi/180.0), refname=lc2.name) lc4 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf4", decz=3.0), refname=lc3.name) lc5 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf5", decz=3.0), refname=lc4.name) lc6 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf6", decz=2.0), refname=lc5.name) lc7 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf7", decz=3.0), refname=lc6.name) lc8 = s.addLocalCoordinateSystem(LocalCoordinates(name="image", decz=19.0), refname=lc7.name) objectsurf = Surface(lc0) surf1 = Surface(lc1, shape=surfShape.Conic(lc1, curv=1/-5.922)) surf2 = Surface(lc2, shape=surfShape.Conic(lc2, curv=1/-3.160)) surf3 = Surface(lc3, shape=surfShape.Conic(lc3, curv=1/15.884)) surf4 = Surface(lc4, shape=surfShape.Conic(lc4, curv=1/-12.756)) stopsurf = Surface(lc5) surf6 = Surface(lc6, shape=surfShape.Conic(lc6, curv=1/3.125)) surf7 = Surface(lc7, shape=surfShape.Conic(lc7, curv=1/1.479)) image = Surface(lc8) elem = OpticalElement(lc0, label="lenssystem") glass = material_isotropic.ConstantIndexGlass(lc0, n=1.7) glass2 = material_isotropic.ConstantIndexGlass(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)) s.addElement("lenssys", elem) return s
def __init__(self): self.outputstream = FreeCADOutputStream() self.stdout_backup = sys.stdout sys.stdout = self.outputstream self.surfaceviews = [] self.surfaceobs = [] self.rayobs = [] self.rayviews = [] self.intersectptsobs = [] self.aiminitialized = False self.fieldwaveinitialized = False self.fieldpoints = [[0., 0.], [0., 3.0]] self.wavelength = 0.55 self.shownumrays = 10 self.aimfinitestopdata = None self.aimy = None self.os = OpticalSystem()
from core.globalconstants import canonical_ey import math import core.helpers wavelength = 0.5876e-3 # definition of optical system #v = np.ones(3)# + 0.001*np.random.random(3) #myeps = np.diag(v) s = OpticalSystem() lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0), refname=s.rootcoordinatesystem.name) #air = AnisotropicMaterial(lc0, myeps) # tests for anisotropic mirror air = ConstantIndexGlass(lc0, 1.0) s.material_background = air lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="m1", decz=50.0, tiltx=-math.pi/8), refname=lc0.name) # objectDist lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="m2_stop", decz=-50.0, decy=-20, tiltx=math.pi/16), refname=lc1.name) lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="m3", decz=50.0, decy=-30, tiltx=3*math.pi/32), refname=lc2.name) lc4 = s.addLocalCoordinateSystem(LocalCoordinates(name="image1", decz=-50, decy=-15, tiltx=-math.pi/16), refname=lc3.name) lc5 = s.addLocalCoordinateSystem(LocalCoordinates(name="oapara", decz=-100, decy=-35), refname=lc4.name) lc5ap = s.addLocalCoordinateSystem(LocalCoordinates(name="oaparaap", decz=0, decy=35), refname=lc5.name) lc6 = s.addLocalCoordinateSystem(LocalCoordinates(name="image2", decz=55, tiltx=1*math.pi/32), refname=lc5.name) lc7 = s.addLocalCoordinateSystem(LocalCoordinates(name="image3", decz=5), refname=lc6.name)
from core.optical_system import OpticalSystem from core.ray import RayBundle from core.aperture import CircularAperture from core.localcoordinates import LocalCoordinates from core.globalconstants import canonical_ey import math import logging logging.basicConfig(level=logging.DEBUG) wavelength = 0.5876e-3 # definition of optical system s = OpticalSystem(name='os') lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="stop", decz=0.0), refname=s.rootcoordinatesystem.name) lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=-1.048), refname=lc0.name) # objectDist lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2", decz=4.0), refname=lc1.name) lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf3", decz=2.5), refname=lc2.name) lc4 = s.addLocalCoordinateSystem(LocalCoordinates(name="image", decz=97.2), refname=lc3.name) stopsurf = Surface(lc0, name="stopsurf") frontsurf = Surface(lc1, name="frontsurf", shape=surfShape.Conic(lc1, curv=1./62.8, name='conic1'), apert=CircularAperture(lc1, 12.7)) cementsurf = Surface(lc2, name="cementsurf", shape=surfShape.Conic(lc2, curv=-1./45.7, name='conic2'), apert=CircularAperture(lc2, 12.7)) rearsurf = Surface(lc3, name="rearsurf", shape=surfShape.Conic(lc3, curv=-1./128.2, name='conic3'), apert=CircularAperture(lc3, 12.7)) image = Surface(lc4, name="imagesurf")
from core.optical_element import OpticalElement from core.optical_system import OpticalSystem from core.surface import Surface from core.globalconstants import canonical_ey from core.optical_system_analysis import OpticalSystemAnalysis from core.surfShape_analysis import ShapeAnalysis wavelength = standard_wavelength logging.basicConfig(level=logging.DEBUG) # definition of optical system s = OpticalSystem() # objectDistance = 2.0 lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0), refname=s.rootcoordinatesystem.name) lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=2.0), refname=lc0.name) # objectDist lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2", decz=3.0), refname=lc1.name) lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf3", decz=5.0, tiltx=2.5 * math.pi / 180.0), refname=lc2.name) lc4 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf4", decz=3.0), refname=lc3.name) lc5 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf5", decz=3.0), refname=lc4.name)
logging.basicConfig(level=logging.DEBUG) import core.helpers 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("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(lc, myeps) # definition of optical system s = OpticalSystem(matbackground=crystal) lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0), refname=s.rootcoordinatesystem.name) lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="m1", decz=50.0, tiltx=-math.pi / 8), refname=lc0.name) # objectDist lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="m2_stop", decz=-50.0, decy=-20, tiltx=math.pi / 16), refname=lc1.name) lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="m3", decz=50.0, decy=-30,
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() 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