Esempio n. 1
0
 def testMinima(self):
     """
     Test the correct computation of all local minima
     for a bistable potential.
     """
     #Predict result
     x0, curv, mask = fixedPoints(
         numpy.array([self.LAMBDA]), kappa1=self.kappa1
         )
     expectedResult = DC.FieldContainer(
         numpy.extract(curv[0]>0,x0[0]),
         unit = self.xField.unit,
         longname = 'position of the local minima of electric potential',
         shortname = 'x_0'
         )
     #Retrieve result from worker
     w = MRA.MRA(None)
     w.paramScale.value = "1.0m"
     result = w.mra(self.V)
     #Testing
     i = numpy.array(range(self.n))
     index = numpy.logical_and(self.u > 0.7, self.u < 0.72)
     index = MRA.findMinima(self.V.data, 5)
     numpy.testing.assert_array_almost_equal(
         result[r'x_{min}'].data, expectedResult.data, 4
         )
Esempio n. 2
0
 def testRoots(self):
     """
     Test the correct computation of all local extrema
     for a bistable potential.
     """
     #Prepare dimensions
     self.prepareDimensions()
     lambField = DC.FieldContainer(
         self.lambDim,
         unit='1 V / m**3',
         longname='parameter',
         shortname='\lambda'
         )
     xField = DC.FieldContainer(
         self.xDim[0],
         unit='1 m',
         longname='position',
         shortname='x'
         )
     #Prepare potential
     V = []
     for i in xrange(len(lambField.data)):
         u = xField.data
         V.append(
             -lambField.data[i] / 2 * u ** 2 + u ** 4 / 4 - u * self.kappa1
             )
     self.V = DC.FieldContainer(
         numpy.array(V), unit='1 V', dimensions=[lambField, xField],
         longname = 'electric potential',
         shortname = r'\varphi'
         )
     #Predict result
     x0, curv, mask = fixedPoints(lambField.data, kappa1=self.kappa1)
     x0 = numpy.where(curv > 0, x0, numpy.NaN)
     data = x0[:, ::2]
     dims = [DC.generateIndex(0, 2), lambField]
     expectedResult = DC.FieldContainer(
         data.transpose(),
         unit=xField.unit,
         mask=numpy.isnan(data).transpose(),
         dimensions=dims,
         longname='position of the local extrema of electric potential',
         shortname='x_0'
         )
     #Configure worker
     w = MRA.MRA(None)
     w.paramScale.value = "1.0m"
     #Retrieve result from worker
     result = copy.deepcopy(w.mra(self.V))['x_{min}']
     result.error=None
     self.test(result,expectedResult,1e-2,1e-2)
Esempio n. 3
0
 def testMinima(self):
     """Test the correct computation of all local minima for a bistable potential."""
     #Predict result
     x0,curv,mask = fixedPoints(numpy.array([self.LAMBDA]),kappa1=self.kappa1)
     expectedResult = DC.FieldContainer(numpy.extract(curv[0]>0,x0[0]),
                                        unit = self.xField.unit,
                                        longname = 'position of the local minima of electric potential',
                                        shortname = 'x_0')
     #Retrieve result from worker
     w = EF.ExtremumFinder(None)
     w.paramExtremum.value=u'minima'
     result = w.locate(self.V)
     #Testing
     DC.assertEqual(result,expectedResult)
Esempio n. 4
0
 def testRoots(self):
     """
     Test the correct computation of all local extrema
     for a bistable potential.
     """
     #Prepare dimensions
     self.prepareDimensions()
     lambField = DC.FieldContainer(self.lambDim,
                                   unit='1 V / m**3',
                                   longname='parameter',
                                   shortname='\lambda')
     xField = DC.FieldContainer(self.xDim[0],
                                unit='1 m',
                                longname='position',
                                shortname='x')
     #Prepare potential
     V = []
     for i in xrange(len(lambField.data)):
         u = xField.data
         V.append(-lambField.data[i] / 2 * u**2 + u**4 / 4 -
                  u * self.kappa1)
     self.V = DC.FieldContainer(numpy.array(V),
                                unit='1 V',
                                dimensions=[lambField, xField],
                                longname='electric potential',
                                shortname=r'\varphi')
     #Predict result
     x0, curv, mask = fixedPoints(lambField.data, kappa1=self.kappa1)
     x0 = numpy.where(curv > 0, x0, numpy.NaN)
     data = x0[:, ::2]
     dims = [DC.generateIndex(0, 2), lambField]
     expectedResult = DC.FieldContainer(
         data.transpose(),
         unit=xField.unit,
         mask=numpy.isnan(data).transpose(),
         dimensions=dims,
         longname='position of the local extrema of electric potential',
         shortname='x_0')
     #Configure worker
     w = MRA.MRA(None)
     w.paramScale.value = "1.0m"
     #Retrieve result from worker
     result = copy.deepcopy(w.mra(self.V))['x_{min}']
     result.error = None
     self.test(result, expectedResult, 1e-2, 1e-2)
Esempio n. 5
0
 def testRoots(self):
     """Test the correct computation of all local extrema for a bistable potential."""
     #Prepare dimensions
     self.prepareDimensions()
     lambField = DC.FieldContainer(self.lambDim,
                                   unit='1 V / m**3',
                                   longname='parameter',
                                   shortname='\lambda')
     xField = DC.FieldContainer(self.xDim[0],
                                unit='1 m',
                                longname='position',
                                shortname='x')
     #Prepare potential
     V = []
     for i in xrange(len(lambField.data)):
         u = xField.data
         V.append(-lambField.data[i] / 2 * u**2 + u**4 / 4 -
                  u * self.kappa1)
     self.V = DC.FieldContainer(numpy.array(V),
                                unit='1 V',
                                dimensions=[lambField, xField],
                                longname='electric potential',
                                shortname=r'\varphi')
     #Predict result
     x0, curv, mask = fixedPoints(lambField.data, kappa1=self.kappa1)
     error = 1.0 / curv.transpose()
     error[:] = numpy.nan
     data = x0.transpose()
     expectedResult = DC.FieldContainer(
         data,
         unit=xField.unit,
         mask=numpy.isnan(data),
         dimensions=[DC.generateIndex(0, 3), lambField],
         longname='position of the local extrema of electric potential',
         shortname='x_0')
     #Configure worker
     w = EF.ExtremumFinder(None)
     w.paramExtremum.value = u'both'
     #Retrieve result from worker
     result = w.locate(self.V)
     self.test(result, expectedResult)
Esempio n. 6
0
 def testMaxima(self):
     """
     Test the correct computation of all local maxima
     for a bistable potential.
     """
     #Predict result
     x0, curv, mask = fixedPoints(numpy.array([self.LAMBDA]),
                                  kappa1=self.kappa1)
     expectedResult = DC.FieldContainer(
         numpy.extract(curv[0] > 0, x0[0]),
         unit=self.xField.unit,
         longname='position of the local minima of electric potential',
         shortname='x_0')
     #Retrieve result from worker
     w = MRA.MRA(None)
     w.paramScale.value = "1.0m"
     V = copy.deepcopy(self.V)
     V.data *= -1
     result = w.mra(V)
     #Testing
     numpy.testing.assert_array_almost_equal(result[r'x_{max}'].data,
                                             expectedResult.data, 4)
Esempio n. 7
0
 def testMinima(self):
     """
     Test the correct computation of all local minima
     for a bistable potential.
     """
     #Predict result
     x0, curv, mask = fixedPoints(numpy.array([self.LAMBDA]),
                                  kappa1=self.kappa1)
     expectedResult = DC.FieldContainer(
         numpy.extract(curv[0] > 0, x0[0]),
         unit=self.xField.unit,
         longname='position of the local minima of electric potential',
         shortname='x_0')
     #Retrieve result from worker
     w = MRA.MRA(None)
     w.paramScale.value = "1.0m"
     result = w.mra(self.V)
     #Testing
     i = numpy.array(range(self.n))
     index = numpy.logical_and(self.u > 0.7, self.u < 0.72)
     index = MRA.findMinima(self.V.data, 5)
     numpy.testing.assert_array_almost_equal(result[r'x_{min}'].data,
                                             expectedResult.data, 4)
Esempio n. 8
0
 def testRoots(self):
     """Test the correct computation of all local extrema for a bistable potential."""
     #Prepare dimensions
     self.prepareDimensions()
     lambField = DC.FieldContainer(self.lambDim,
                                   unit = '1 V / m**3',
                                   longname='parameter',
                                   shortname='\lambda')
     xField = DC.FieldContainer(self.xDim[0],
                                unit = '1 m',
                                longname = 'position',
                                shortname = 'x')
     #Prepare potential
     V = []
     for i in xrange(len(lambField.data)):
         u = xField.data
         V.append(-lambField.data[i]/2* u**2 + u**4/4-u*self.kappa1)
     self.V = DC.FieldContainer(numpy.array(V),unit='1 V',dimensions=[lambField,xField],
                                longname = 'electric potential',
                                shortname=r'\varphi')
     #Predict result
     x0,curv,mask = fixedPoints(lambField.data,kappa1=self.kappa1)
     error = 1.0/curv.transpose()
     error[:] =numpy.nan
     data = x0.transpose()
     expectedResult = DC.FieldContainer(data,
                                        unit = xField.unit,
                                        mask = numpy.isnan(data),
                                        dimensions=[DC.generateIndex(0,3),lambField],
                                        longname = 'position of the local extrema of electric potential',
                                        shortname = 'x_0')
     #Configure worker
     w = EF.ExtremumFinder(None)
     w.paramExtremum.value=u'both'
     #Retrieve result from worker
     result = w.locate(self.V)
     self.test(result,expectedResult)
Esempio n. 9
0
 def testMaxima(self):
     """
     Test the correct computation of all local maxima
     for a bistable potential.
     """
     #Predict result
     x0, curv, mask = fixedPoints(
         numpy.array([self.LAMBDA]), kappa1=self.kappa1
         )
     expectedResult = DC.FieldContainer(
         numpy.extract(curv[0] > 0, x0[0]),
         unit = self.xField.unit,
         longname = 'position of the local minima of electric potential',
         shortname = 'x_0')
     #Retrieve result from worker
     w = MRA.MRA(None)
     w.paramScale.value = "1.0m"
     V = copy.deepcopy(self.V)
     V.data*=-1
     result = w.mra(V)
     #Testing
     numpy.testing.assert_array_almost_equal(
         result[r'x_{max}'].data,expectedResult.data, 4
         )