Пример #1
0
def createObjects():
    m = random.randint(1, 100)
    v = random.randint(1, 100)
    h = random.randint(1, 100)
    values = energy.Energy(m, v, h)
    values.set_ke()
    values.set_pe()
    ke = values.get_ke()
    pe = values.get_pe()
    return ke, pe
Пример #2
0
    def ExpansionMove(self, alpha):
        """
        Compute the minimum a-expansion configuration
        :param alpha: int
        :return: bool, whether the move is different from identity
        """
        nb = self.imSizeL[0] * self.imSizeL[1]
        e = energy.Energy(2 * nb, 12 * nb)

        # Build Graph
        # data and occlusion term
        for index, _ in np.ndenumerate(self.posIter):
            self.build_nodes(e, index, alpha)

        # smooth term
        for index, _ in np.ndenumerate(self.posIter):
            for neighbor in NEIGHBORS:
                coordP2 = coord_add(index, neighbor)
                if inRect(coordP2, self.imSizeL):
                    self.build_smoothness(e, index, coordP2, alpha)

        # uniqueness term
        for index, _ in np.ndenumerate(self.posIter):
            self.build_uniqueness(e, index, alpha)

        oldEnergy = self.currentEnergy
        # Max-flow, give the lowest-energy expansion move
        self.currentEnergy = e.minimize()

        # lower energy, accept the expansion move
        if self.currentEnergy < oldEnergy:
            self.update_disparity(e, alpha)
            # assert (self.ComputeEnergy() == self.currentEnergy)
            return True
        else:
            self.currentEnergy = oldEnergy

        return False
Пример #3
0
 def test_UnitlessLennardJones_factory(self):
     model = energy.Energy()
     coord = np.zeros((1, 3))
     energy_1 = model.calc_init_ener(coord, 1)
     self.assertEqual(energy_1, 0)
Пример #4
0
 def test_LennardJones_factory(self):
     model = energy.Energy('LJ')
     coord = np.array([[1, 2, 3], [0, 0, 0]])
     energy_1 = model.calc_init_ener(coord, 3)
     self.assertEqual(energy_1, -0.2187499999999999)
Пример #5
0
                        help='whether to plot the initial and final \
                            configurations. Specify "-p" to plot.')
    parser.add_argument('-o',
                        '--traj_file',
                        required=False,
                        default='traj_output.xyz',
                        help='The file name of the trajectory data file.')

    args_parse = parser.parse_args()

    return args_parse


if __name__ == "__main__":
    rc('font', **{
        'family': 'sans-serif',
        'sans-serif': ['DejaVu Sans'],
        'size': 10
    })
    # Set the font used for MathJax - more on this later
    rc('mathtext', **{'default': 'regular'})
    plt.rc('font', family='serif')

    args = initialize()
    new_system = SystemSetup(N_particles=args.N_particles,
                             reduced_rho=args.reduced_rho)
    energy = energy.Energy()
    sim = MonteCarlo(system=new_system, energy=energy, args=args)
    sim.MC_simulation()
    sys.exit(0)