def create_cemented_doublet(power=0., bending=0., th=None, sd=1., glasses=('N-BK7,Schott', 'N-F2,Schott'), **kwargs): from opticalglass.spectral_lines import get_wavelength from opticalglass import glass wvls = np.array([get_wavelength(w) for w in ['d', 'F', 'C']]) gla_a = gfact.create_glass(glasses[0]) rndx_a = gla_a.calc_rindex(wvls) Va, PcDa = glass.calc_glass_constants(*rndx_a) gla_b = gfact.create_glass(glasses[1]) rndx_b = gla_b.calc_rindex(wvls) Vb, PcDb = glass.calc_glass_constants(*rndx_b) power_a, power_b = achromat(power, Va, Vb) if th is None: th = sd/4 t1 = 3*th/4 t2 = th/4 if power_a < 0: t1, t2 = t2, t1 lens_a = lens_from_power(power=power_a, bending=bending, th=t1, sd=sd, med=gla_a) cv1, cv2, t1, indx_a, sd = lens_a # cv1 = power_a/(rndx_a[0] - 1) # delta_cv = -cv1/2 # cv1 += delta_cv # cv2 = delta_cv # cv3 = power_b/(1 - rndx_b[0]) + delta_cv indx_b = rndx_b[0] cv3 = (power_b/(indx_b-1) - cv2)/((t2*cv2*(indx_b-1)/indx_b) - 1) s1 = Surface(profile=Spherical(c=cv1), max_ap=sd, delta_n=(rndx_a[0] - 1)) s2 = Surface(profile=Spherical(c=cv2), max_ap=sd, delta_n=(rndx_b[0] - rndx_a[0])) s3 = Surface(profile=Spherical(c=cv3), max_ap=sd, delta_n=(1 - rndx_b[0])) g1 = Gap(t=t1, med=gla_a) g2 = Gap(t=t2, med=gla_b) g_tfrm = np.identity(3), np.array([0., 0., 0.]) ifc_list = [] ifc_list.append([0, s1, g1, 1, g_tfrm]) ifc_list.append([1, s2, g2, 1, g_tfrm]) ifc_list.append([2, s3, None, 1, g_tfrm]) ce = CementedElement(ifc_list) tree = ce.tree() return [[s1, g1, None, rndx_a, 1], [s2, g2, None, rndx_b, 1], [s3, None, None, 1, 1]], [ce], tree
def create_lens(power=0., bending=0., th=None, sd=1., med=None, **kwargs): if med is None: med = Glass() lens = lens_from_power(power=power, bending=bending, th=th, sd=sd, med=med) cv1, cv2, th, rndx, sd = lens s1 = Surface(profile=Spherical(c=cv1), max_ap=sd, delta_n=(rndx - 1)) s2 = Surface(profile=Spherical(c=cv2), max_ap=sd, delta_n=(1 - rndx)) g = Gap(t=th, med=med) le = Element(s1, s2, g, sd=sd) tree = le.tree() return [[s1, g, None, rndx, 1], [s2, None, None, 1, 1]], [le], tree
def create_lens(power=0., bending=0., th=None, sd=1., med=None): if med is None: med = Glass() rndx = med.rindex('d') cv1 = power / (2 * (rndx - 1)) cv2 = -power / (2 * (rndx - 1)) s1 = Surface(profile=Spherical(c=cv1), max_ap=sd, delta_n=(rndx - 1)) s2 = Surface(profile=Spherical(c=cv2), max_ap=sd, delta_n=(1 - rndx)) if th is None: th = sd / 5 g = Gap(t=th, med=med) le = Element(s1, s2, g, sd=sd) return [[s1, g, None, rndx, 1], [s2, None, None, 1, 1]], [le]
def compute_principle_points(self, seq): """ Returns paraxial p and q rays, plus partial first order data. Args: seq: a sequence containing interfaces and gaps to be traced. for each iteration, the sequence should return a list containing: **Intfc, Gap, Trfm, Index, Z_Dir** Returns: (p_ray, q_ray, (efl, pp1, ppk, ffl, bfl)) - p_ray: [ht, slp, aoi], [1, 0, -] - q_ray: [ht, slp, aoi], [0, 1, -] - efl: effective focal length - pp1: distance of front principle plane from 1st interface - ppk: distance of rear principle plane from last interface - ffl: front focal length - bfl: back focal length """ n_0 = seq[0][mc.Indx] z_dir_before = seq[0][mc.Zdir] n_k = seq[-1][mc.Indx] z_dir_k = seq[-1][mc.Zdir] path = [[Surface(), Gap(), None, n_0, z_dir_before]] path.extend(seq[1:]) pp_info = fo.compute_principle_points(iter(path), n_0=z_dir_before * n_0, n_k=z_dir_k * n_k) return pp_info
def create_mirror(c=0.0, r=None, cc=0.0, ec=None, power=None, profile=None, sd=None, **kwargs): '''Create a sequence and element for a mirror. Args: c: vertex curvature r: vertex radius of curvature cc: conic constant ec: 1 + cc power: optical power of the mirror sd: semi-diameter profile: Spherical or Conic type, or a profile instance ''' delta_n = kwargs['delta_n'] if 'delta_n' in kwargs else -2 if power: cv = power / delta_n elif r: cv = 1.0 / r else: cv = c if ec: k = ec - 1.0 else: k = cc if profile is Spherical: prf = Spherical(c=cv) elif profile is Conic: prf = Conic(c=cv, cc=k) elif profile is not None: prf = profile else: if k == 0.0: prf = Spherical(c=cv) else: prf = Conic(c=cv, cc=k) m = Surface(profile=prf, interact_mode='reflect', max_ap=sd, delta_n=delta_n, **kwargs) ele_kwargs = {'label': kwargs['label']} if 'label' in kwargs else {} me = Mirror(m, sd=sd, **ele_kwargs) tree = me.tree() return [[m, None, None, 1, -1]], [me], tree
def compute_principle_points(self, node, seq): n_0 = seq[0][mc.Indx] z_dir_before = seq[0][mc.Zdir] n_k = seq[-1][mc.Indx] z_dir_k = seq[-1][mc.Zdir] path = [[Surface(), Gap(), None, n_0, z_dir_before]] path.extend(seq[1:]) pp_info = fo.compute_principle_points(iter(path), n_0=z_dir_before * n_0, n_k=z_dir_k * n_k) return pp_info
def create_dummy_plane(sd=1., **kwargs): s = Surface(**kwargs) se = DummyInterface(s, sd=sd) tree = se.tree() return [[s, None, None, 1, +1]], [se], tree