/**
         * Find the distance to the conduction band in Cm when the energy is set to the
         * provided level.
         *
         * @param energy - energy level used to evaluate the structure.
         *
         * @return thickness - distance to conduction band in Cm.
         */
        public Length DistanceToConductionBand(Energy energy)
        {
            // find between which points the energy of interest lies
            // if energy is above all the points return 0 distance
            if (EvalPoints.All(p => ConductionBandEnergy(p) <= energy))
            {
                return(Length.Zero);
            }

            EvalPoint abovePoint  = null;
            EvalPoint belowPoint  = null;
            var       aboveEnergy = Energy.FromElectronVolts(1E10);
            var       belowEnergy = Energy.FromElectronVolts(-1E10);

            // a ridiculus start energy if we
            // find a point above the energy it will definately be lower than this value.
            foreach (var p in EvalPoints)
            {
                var cbEnergy = ConductionBandEnergy(p);
                if (cbEnergy > energy && cbEnergy < aboveEnergy)
                {
                    aboveEnergy = cbEnergy;
                    abovePoint  = p;
                }

                if (cbEnergy < energy && cbEnergy > belowEnergy)
                {
                    belowEnergy = cbEnergy;
                    belowPoint  = p;
                }
            }

            // if we didn't find a point in energy below the input energy then tunnel through whole dielectric
            if (belowPoint == null)
            {
                return(Thickness);
            }

            // make sure that we have above and below points
            if (belowPoint == null || abovePoint == null)
            {
                // we did something wrong
                return(null);                // negative thickness so we know something is wrong
            }

            // interpolate cross points
            var slope = (aboveEnergy - belowEnergy).ToPotential()
                        / (abovePoint.Location - belowPoint.Location);
            var intercept = aboveEnergy.ToPotential() - slope * abovePoint.Location;
            var distance  = (energy.ToPotential() - intercept) / slope;

            return(distance);
        }
示例#2
0
        public void Evaluate()
        {
            var phiS           = SurfacePotential;
            var storePotential = EvalPoints[0].Potential;

            // First remove all the points
            EvalPoints.Clear();

            // Find the thickness through integration
            // Integrate from 0 to the surface potential
            // Integrate 2000 times so change stepSize depending on the surface potential
            var stepSize = phiS / 20;

            stepSize = phiS > ElectricPotential.Zero ?
                       ElectricPotential.Abs(stepSize) : -ElectricPotential.Abs(stepSize);

            var previousValue     = 1 / GetElectricField(phiS).VoltsPerMeter;
            var runningThickness  = Length.Zero;
            var previousThickness = Length.Zero;

            var point = new EvalPoint
            {
                Location      = runningThickness,
                ChargeDensity = GetChargeY(phiS),
                ElectricField = new ElectricField(1 / previousValue),
                Potential     = phiS
            };

            EvalPoints.Add(point);

            for (var i = 1; ElectricPotential.Abs(phiS - stepSize * i)
                 > ElectricPotential.FromMillivolts(1) && i < 10000; i++)
            {
                var potentialValue = phiS - stepSize * i;
                var value          = 1 / GetElectricField(potentialValue).VoltsPerMeter;
                previousThickness = runningThickness;
                runningThickness += new Length(((previousValue + value) / 2) * stepSize.Volts);

                if (double.IsNaN(runningThickness.Meters))
                {
                    Debug.WriteLine("Por que Nan??");
                }

                point = new EvalPoint
                {
                    Location      = runningThickness,
                    ChargeDensity = GetChargeY(potentialValue) * 1E-8,
                    ElectricField = new ElectricField(1 / value),
                    Potential     = potentialValue
                };

                EvalPoints.Add(point);
                previousValue = value;
            }

            // Now add the offset in potential
            var checkCharge = ChargeDensity.Zero; // check and see if the charges add up

            foreach (var checkPoint in EvalPoints)
            {
                checkPoint.Potential = checkPoint.Potential + storePotential;
                checkPoint.Potential = checkPoint.Potential - phiS;
                checkCharge         += checkPoint.ChargeDensity;
            }
        }
 /**
  * The energy value for the valance band at the given point's location.
  *
  * @param index - index value for the point to evaluate.
  *
  * @return energy - energy value at the specified point.
  */
 public Energy ValenceBandEnergy(EvalPoint p)
 {
     return(-p.Potential - ElectronAffinity - BandGap);
 }
 /**
  * The energy value for the conduction band at the given point's location.
  *
  * @param index - index value for the point to evaluate.
  *
  * @return energy - energy value at the specified point.
  */
 public Energy ConductionBandEnergy(EvalPoint p)
 {
     return(-p.Potential - ElectronAffinity);
 }