예제 #1
0
def example1():
    """1. Defining fiber layers"""
    factory = FiberFactory()

    factory.name = "Name of your fiber"
    factory.author = "Your Name"
    factory.description = "Description of your fiber"

    print('crdate:', datetime.datetime.fromtimestamp(
          int(factory.crdate)).strftime('%Y-%m-%d %H:%M:%S'))
    print('tstamp:', datetime.datetime.fromtimestamp(
          int(factory.tstamp)).strftime('%Y-%m-%d %H:%M:%S'))

    # Default parameters
    factory.addLayer()
    # Comp material: molar fraction
    factory.addLayer(pos=0, name="core", geometry="StepIndex", radius=4e-6,
                     material="SiO2GeO2", x=0.1)
    # Comp material: index and wavelength
    factory.addLayer(pos=1, name="trench", radius=6e-6, material="SiO2F",
                     index=1.441, wl=1550e-9)

    # Getting information from layers
    print('Name of layer 0:', factory.layers[0].name)
    print('Radius of layer 1:', factory.layers[1].radius)
    factory.layers[2].name = "cladding"
    print('Name of layer 2:', factory.layers[2].name)
예제 #2
0
 def testSetAttributes(self):
     f = FiberFactory()
     f.name = "smf28"
     f.author = "Charles Brunet"
     f.description = "Single mode fiber"
     f.addLayer()
     f.layers[0].name = "core"
     self.assertEqual(f.name, "smf28")
     self.assertEqual(f.author, "Charles Brunet")
     self.assertEqual(f.description, "Single mode fiber")
     self.assertEqual(f.layers[0].name, "core")
예제 #3
0
 def testSetAttributes(self):
     f = FiberFactory()
     f.name = "smf28"
     f.author = "Charles Brunet"
     f.description = "Single mode fiber"
     f.addLayer()
     f.layers[0].name = "core"
     self.assertEqual(f.name, "smf28")
     self.assertEqual(f.author, "Charles Brunet")
     self.assertEqual(f.description, "Single mode fiber")
     self.assertEqual(f.layers[0].name, "core")