Пример #1
0
 def __init__(self,
              R,
              origin=vector3.new(0, 0, 0),
              direction=vector3.new(0, 0, 1)):
     self.R2 = R**2
     self.origin = origin
     self.direction = direction
Пример #2
0
 def __init__(self,
              focalPoint,
              origin=vector3.new(0, 0, 0),
              directionX=vector3.new(1, 0, 0),
              directionY=vector3.new(0, 1, 0)):
     self.C = 1 / 4 / focalPoint
     self.origin = origin
     self.directionX = directionX
     self.directionY = directionY
Пример #3
0
def Cylinder(R, origin=vector3.new(0, 0, 0), reverse=False):
    def result(pos):
        posR = pos - origin

        return (posR[0] * posR[0] + posR[1] * posR[1] - R * R < 0) ^ reverse

    return result
Пример #4
0
def dopantInClad(dopant, N, diameter, q, lightL, darkL, ll):
    generator = components.SolarGenerator(params.solarIrradiance, ll, vector3.new(0, -1, 0), vector3.new(2*diameter, 0, 0), vector3.new(0, 0, lightL), origin=vector3.new(-2*diameter/2, diameter+1e-5, 0));

    cint1 = constraints.Interval(0, lightL+darkL);
    cint2 = constraints.Cylinder(diameter/2);
    cint3 = constraints.Cylinder(diameter*q/2);
    cint4 = lambda pos: cint1(pos) and cint3(pos);
    cint5 = lambda pos: cint1(pos) and cint2(pos) and not cint3(pos);
    collector = components.Collector(interphases.PlaneInterphase(vector3.new(0, 0, 1), origin=vector3.new(0, 0, lightL+darkL)), len(ll), cint=cint2);
    cmp1 = components.Refractor(interphases.CylinderInterphase(diameter/2), "air", "PMMA", ll, cint=cint1);
    cmp2 = components.Refractor(interphases.CylinderInterphase(diameter*q/2), "PMMA", "PMMA", ll, cint=cint1);
    cmp3 = components.Attenuation("PMMA", ll, cint=cint4);
    cmp4 = components.DyeDopant(dopant, N, ll, cint=cint5);
    cmp5 = components.Attenuation("PMMA", ll, cint=cint5);
    cmpList = [collector, cmp1, cmp2, cmp3, cmp4, cmp5];

    return generator, collector, cmpList;
Пример #5
0
def noClad(dopant, N, diameter, lightL, darkL, ll):
    generator = components.SolarGenerator(params.solarIrradiance, ll, vector3.new(0, -1, 0), vector3.new(2*diameter, 0, 0), vector3.new(0, 0, lightL), origin=vector3.new(-2*diameter/2, diameter+1e-5, 0));

    cint1 = constraints.Interval(0, lightL+darkL);
    cint2 = constraints.Cylinder(diameter/2);
    cint3 = constraints.join(cint1, cint2);
    #cint4 = constraints.Interval(-math.inf, 0, axis=1);
    collector = components.Collector(interphases.PlaneInterphase(vector3.new(0, 0, 1), origin=vector3.new(0, 0, lightL+darkL)), len(ll), cint=cint2);
    cmp1 = components.Refractor(interphases.CylinderInterphase(diameter/2), "air", "PMMA", ll, cint=cint1);
    cmp2 = components.Attenuation("PMMA", ll, cint=cint3);
    cmp3 = components.DyeDopant("Rh6G", 1.5e22, ll, cint=cint3);
    #cmp4 = components.Mirror(interphases.PlaneInterphase(vector3.new(0, 1, 0), origin=vector3.new(0, -diameter/2-1e-6, 0)));
    #cmp4 = components.Mirror(interphases.ParabolaInterphase(3*diameter/4, origin=vector3.new(0, -diameter/2-1e-6, 0)));
    #cmp4 = components.Mirror(interphases.CylinderInterphase(diameter), cint=cint4);
    #cmp5 = components.Mirror(interphases.PlaneInterphase(vector3.new(0, 0, 1)), cint=cint2);
    #cmpList = [collector, cmp1, cmp2, cmp3, cmp4, cmp5];
    cmpList = [collector, cmp1, cmp2, cmp3];

    return generator, collector, cmpList;
Пример #6
0
 def __init__(self, solarFunc, ll, direction, vec1, vec2, origin=vector3.new(0, 0, 0)):
     dLL = ll[1]-ll[0];
     self.solarDist = list(map(lambda ll: solarFunc(ll)*dLL, ll));
     self.solarConstant = sum(self.solarDist);
     self.direction = direction;
     self.vec1 = vec1;
     self.vec2 = vec2;
     self.incomingPower = self.solarConstant*vector3.norm(vec1)*vector3.norm(vec2);
     self.origin = origin;
     self.generatedPower = [0]*len(ll);
Пример #7
0
    def process(self, ray, ds):
        if self.constraint(ray.pos):
            # Generate random direction after spontaneous emission
            rand1 = 2*math.pi*random();
            rand2 = 2*random()-1;
            ray.vel = vector3.new(sqrt(1-pow(rand2,2))*cos(rand1), sqrt(1-pow(rand2,2))*sin(rand1), rand2);

            # Generate new wavelength using emission spectrum
            oldK = ray.k;
            ray.k = self.generateLambda();

            # Change photon power (Stokes shift)
            ray.power = ray.power*self.ll[oldK]/self.ll[ray.k];

            # Quantum yield: some spontaneous emissions are lost due to
            # nonradiative decay
            if random() > self.quantumYield:
                ray.loopOn = False;
Пример #8
0
import vector3
import basics
import constraints
import interphases
import components
import sims

diameter = 1e-3
L = 0.1

ll = sims.generateLambdas(440e-9, 740e-9, 101)

cmp1 = components.Refractor(interphases.CylinderInterphase(diameter / 2),
                            "air", "PMMA", ll)
cmp1.setConstraint(constraints.Interval(0, L))
cmp1.process(
    basics.Ray(vector3.new(0, diameter / 2, -L), vector3.new(0, 0.8, 0.6), 4,
               1), 1e-5)

collector = components.Collector(
    interphases.PlaneInterphase(vector3.new(0, 0, 1)), len(ll))
collector.setConstraint(constraints.Cylinder(diameter / 2))
print(
    collector.process(
        basics.Ray(vector3.new(0, 0, L), vector3.new(0, -0.8, 0.6), 4, 0.5),
        1e-5))
print(sum(collector.finalPower))
Пример #9
0
 def __init__(self, normalVector, origin=vector3.new(0, 0, 0)):
     self.normalVector = normalVector
     self.origin = origin