diff --git a/.github/workflows/linux_build.yml b/.github/workflows/linux_build.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/macos_build.yml b/.github/workflows/macos_build.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.gitmodules b/.gitmodules old mode 100644 new mode 100755 diff --git a/.travis.yml b/.travis.yml old mode 100644 new mode 100755 diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 73ae030e..47d60cf0 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ include(cmake/StandardProjectSettings.cmake) # Link this 'library' to set the c++ standard / compile-time options requested add_library(project_options INTERFACE) -target_compile_features(project_options INTERFACE cxx_std_14) +target_compile_features(project_options INTERFACE cxx_std_17) set_target_properties(project_options PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ON) @@ -36,6 +36,9 @@ option(ENABLE_TESTING "Enable Test Builds" ON) # look for 3rd party packages include(cmake/pybind11.cmake) +#libtorch +include(cmake/NNgHMC.cmake) + find_package(blaze 3.6 REQUIRED) add_library(blaze_options INTERFACE) target_include_directories(blaze_options SYSTEM INTERFACE ${blaze_INCLUDE_DIRS}) diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/benchmarks/.gitignore b/benchmarks/.gitignore old mode 100644 new mode 100755 diff --git a/benchmarks/logdet.py b/benchmarks/logdet.py old mode 100644 new mode 100755 diff --git a/benchmarks/show.py b/benchmarks/show.py old mode 100644 new mode 100755 diff --git a/cmake/Cache.cmake b/cmake/Cache.cmake old mode 100644 new mode 100755 diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake old mode 100644 new mode 100755 diff --git a/cmake/Modules/Findblaze.cmake b/cmake/Modules/Findblaze.cmake old mode 100644 new mode 100755 diff --git a/cmake/NNgHMC.cmake b/cmake/NNgHMC.cmake new file mode 100755 index 00000000..c0d1f5f6 --- /dev/null +++ b/cmake/NNgHMC.cmake @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.0 FATAL_ERROR) +option(USE_NN "Enable gardient calculation with NN" ON) +list(APPEND CMAKE_PREFIX_PATH "/p/project/cjjsc37/john/libtorch") +if (USE_NN) + message(STATUS "Using NNgHMC") + find_package(Torch REQUIRED) + target_link_libraries(project_options INTERFACE "${TORCH_LIBRARIES}") + +endif () \ No newline at end of file diff --git a/cmake/StandardProjectSettings.cmake b/cmake/StandardProjectSettings.cmake old mode 100644 new mode 100755 diff --git a/cmake/pybind11.cmake b/cmake/pybind11.cmake old mode 100644 new mode 100755 diff --git a/docs/.gitignore b/docs/.gitignore old mode 100644 new mode 100755 diff --git a/docs/Makefile b/docs/Makefile old mode 100644 new mode 100755 diff --git a/docs/algorithm/.gitignore b/docs/algorithm/.gitignore old mode 100644 new mode 100755 diff --git a/docs/algorithm/Makefile b/docs/algorithm/Makefile old mode 100644 new mode 100755 diff --git a/docs/algorithm/hubbardFermiAction.tex b/docs/algorithm/hubbardFermiAction.tex old mode 100644 new mode 100755 diff --git a/docs/algorithm/references.bib b/docs/algorithm/references.bib old mode 100644 new mode 100755 diff --git a/docs/algorithm/settings.tex b/docs/algorithm/settings.tex old mode 100644 new mode 100755 diff --git a/docs/doxyfile.conf b/docs/doxyfile.conf old mode 100644 new mode 100755 diff --git a/docs/examples/NNgPytorchModel.py b/docs/examples/NNgPytorchModel.py new file mode 100644 index 00000000..511b1292 --- /dev/null +++ b/docs/examples/NNgPytorchModel.py @@ -0,0 +1,96 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F +from torch.utils.data import TensorDataset, DataLoader +from itertools import chain +from tqdm import tqdm +import numpy as np + + +# loading data for training +xx = np.load('trainingData_NN/inputs_4sites_U3.0B3.0Nt32.npy') +yy = np.load('trainingData_NN/targets_4sites_U3.0B3.0Nt32.npy') + + +input_dim = xx.shape[1] +hidden_dim = [2*input_dim] +output_dim = input_dim + + +class NNg(nn.Module): + def __init__(self, input_dim, hidden_dim, output_dim): + """ + Args: + input_dim: int for input dimension + hidden_dim: list of int for multiple hidden layers + output_dim: list of int for multiple output layers + """ + + # calling constructor of parent class + super().__init__() + + # defining the inputs to the first hidden layer + self.hid1 = nn.Linear(input_dim, hidden_dim[0]) + nn.init.normal_(self.hid1.weight, mean=0.0, std=0.01) + nn.init.zeros_(self.hid1.bias) + self.act1 = nn.ReLU() + + # defining the inputs to the output layer + self.hid2 = nn.Linear(hidden_dim[0], output_dim) + nn.init.xavier_uniform_(self.hid2.weight) + + def forward(self, X): + + # input and act for layer 1 + X = self.hid1(X) + X = self.act1(X) + + # input and act for layer 2 + X = self.hid2(X) + return X + + +epochs = 80 +batchsize = 150 +#converting to tensors +inputs, targets = torch.from_numpy(np.real(xx)).double(), torch.from_numpy(np.real(yy)).double() +train_ds = TensorDataset(inputs, targets) +# split the data into batches +train_dl = DataLoader(train_ds, batchsize, shuffle=False) +test_dl = DataLoader(train_ds, batchsize, shuffle=False) +model_torch = NNg(input_dim, hidden_dim, output_dim).double() +optimizer = torch.optim.Adam(model_torch.parameters(), weight_decay=1e-5) +criterion = nn.L1Loss() + +# iterate through all the epoch +for epoch in tqdm(range(epochs)): + # go through all the batches generated by dataloader + for i, (inputs, targets) in enumerate(train_dl): + # clear the gradients + optimizer.zero_grad() + # compute the model output + yhat = model_torch(inputs) + # calculate loss + loss = criterion(yhat, targets.type(torch.FloatTensor)) + # credit assignment + loss.backward() + # update model weights + optimizer.step() + # Print the progress + if (epoch+1) % 10 == 0: + print('Epoch [{}/{}], Loss: {:.4f}'.format(epoch + + 1, epochs, loss.item())) + +# load a sample data +#example_input, example_target = next(iter(train_dl)) +#run the tracing +#traced_script_module = torch.jit.trace(model_torch, example_input) +# save the converted model +#traced_script_module.save("NNg_model.pt") + +#scripting the model +script_module = torch.jit.script(model_torch) +script_module.save("NNgModel_del.pt") + + + diff --git a/docs/examples/bootStrapCorrelators.py b/docs/examples/bootStrapCorrelators.py new file mode 100644 index 00000000..1ec59282 --- /dev/null +++ b/docs/examples/bootStrapCorrelators.py @@ -0,0 +1,152 @@ +import h5py as h5 +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +import sys +import isle +import isle.drivers + +with h5.File(sys.argv[1],"r") as h5f: + rawP = h5f["correlation_functions/single_particle/destruction_creation/"][()] + weights = h5f["weights/actVal"][()] + +metadata = isle.h5io.readMetadata(sys.argv[1]) +lattice = metadata[0] +parameters = metadata[1] +BETA = parameters.beta +U = parameters.U +NBS = 100 +BSLENGTH=rawP.shape[0] +NCORR = rawP.shape[1] +NT=rawP.shape[3] +DELTA = BETA/NT + +print(f'U={U} beta={BETA} Nt={NT}') +print(f'# of corelators = {NCORR}') +# Ok, this next part is related to simulations that have a sign problem, which yours do not have at the moment. +# But you can still evaluate this part anyways, as it won't affect your results. I add it here anyways in +# case we decide in the near future to run on systems with a sign problem. +theta = -np.imag(weights) +allWeights = np.exp(1j*theta) + +# now the number of weights equals the total number of configurations +# but the number of measurements is not necessarily the same! +# I need to take this into account + +measFreq = int(weights.shape[0]/rawP.shape[0]) +print("# measurements were done every {}th configuration (that was stored)".format(measFreq)) + +weights = np.array([allWeights[i] for i in range(0,allWeights.shape[0],measFreq)]) +# now multiple correlators by their weights +for itr in range(rawP.shape[0]): + rawP[itr] *= weights[itr] + +# All data are stored in these arrays +corrRe = [[] for i in range(NCORR)] +errRe = [[] for i in range(NCORR)] +corrIm = [[] for i in range(NCORR)] +errIm = [[] for i in range(NCORR)] +tau = [ t*DELTA for t in range(NT)] + + +#bining the data +NBIN = 100 +NBS = 100 + +for nc in range(NCORR): + weightsBinned = [] + rawPBinned = [] + for i in range(int(rawP.shape[0]/NBIN)): + weightsBinned.append(np.mean(np.array([weights[i*NBIN+j] for j in range(NBIN)]))) + temp = np.array([0+0j for _ in range(NT)]) + for j in range(NBIN): + temp += rawP[i*NBIN+j,nc,nc] + temp /= NBIN + rawPBinned.append(temp) + + weightsBinned = np.array(weightsBinned) + rawPBinned = np.array(rawPBinned) + + avgCorrP = np.mean(rawPBinned,axis=0)/np.mean(weightsBinned) + + BSLENGTH = weightsBinned.shape[0] + bootstrapIndices = np.random.randint(0, BSLENGTH, [NBS, BSLENGTH]) + + + # now get error on correlators + RerrPxx = np.std(np.real(np.array([np.mean(np.array([rawPBinned[cfg] for cfg in bootstrapIndices[sample]])/np.mean(np.array([weightsBinned[cfg] for cfg in bootstrapIndices[sample]])), axis=0) for sample in range(NBS) ] )), axis=0) + + IerrPxx = np.std(np.imag(np.array([np.mean(np.array([rawPBinned[cfg] for cfg in bootstrapIndices[sample]])/np.mean(np.array([weightsBinned[cfg] for cfg in bootstrapIndices[sample]])), axis=0) for sample in range(NBS) ] )), axis=0) + + for t in range(NT): + corrRe[nc].append(avgCorrP[t].real) + errRe[nc].append(RerrPxx[t]) + corrIm[nc].append(avgCorrP[t].imag) + errIm[nc].append(IerrPxx[t]) + #print(t*DELTA,avgCorrP[t].real,RerrPxx[t],avgCorrP[t].imag,IerrPxx[t]) + + +dataG = open('ExactFiles/U3B4G.dat','r').readlines() +dataM = open('ExactFiles/U3B4M.dat','r').readlines() +exact_t_gamma = [] +exact_gamma_plus = [] +exact_gamma_minus = [] +exact_t_m = [] +exact_m_plus = [] +exact_m_minus = [] +for dat in dataG: + ss = dat.split() + exact_t_gamma.append(float(ss[0])) + exact_gamma_plus.append(float(ss[1])) + exact_gamma_minus.append(float(ss[2])) +for dat in dataM: + ss = dat.split() + exact_t_m.append(float(ss[0])) + exact_m_plus.append(float(ss[1])) + exact_m_minus.append(float(ss[2])) + +#Exact co-relators data +# exactData = open("ExactFiles/U4B6.dat").readlines() +# exT = [] +# exBonding = [] +# exAntiBonding = [] +# exAA = [] +# exAB = [] +# exBA = [] +# exBB = [] +# for i in range(len(exactData)): +# split = exactData[i].split() +# exT.append(float(split[0])) # tau +# exAntiBonding.append(float(split[1])) # anti-bonding +# exBonding.append(float(split[2])) # bonding +# exAA.append(float(split[3])) # cAA +# exAB.append(float(split[4])) # cAB +# exBA.append(float(split[5])) # cBA +# exBB.append(float(split[6])) # cBB + +# Now I just plot our the real parts of the correlators (the imaginary part should be MUCH smaller) +fig, ax = plt.subplots(1,1,figsize=(10,7.5)) +ax.set_yscale('log') +for nc in range(NCORR): + #print("error",nc,"=",errRe[nc]) + ax.errorbar(tau,corrRe[nc],yerr=errRe[nc],marker='o',label=f'corr{nc}') + +# ax.plot(exT,exBonding,'k--',label='exact') +# ax.plot(exT,exAntiBonding,'k--') +ax.plot(exact_t_gamma,exact_gamma_plus,'k--') +ax.plot(exact_t_gamma,exact_gamma_minus,'k--') +ax.plot(exact_t_m,exact_m_plus,'r--') +ax.plot(exact_t_m,exact_m_minus,'r--') + +ax.grid() +ax.set_xlabel(r'$\tau$') +ax.set_ylabel(r'$C(\tau)$') +ax.set_title(rf' Four sites $U={U}$ $\beta={BETA}$, $N_t={NT}$') +ax.legend() +plt.savefig('results/Exact4sitesNmd3_logU{}B{}NT{}.pdf'.format(U,BETA,NT)) + + + + + + diff --git a/docs/examples/changeEvolver.py b/docs/examples/changeEvolver.py old mode 100644 new mode 100755 diff --git a/docs/examples/create_training_data.py b/docs/examples/create_training_data.py new file mode 100644 index 00000000..c32bd7ff --- /dev/null +++ b/docs/examples/create_training_data.py @@ -0,0 +1,105 @@ +import numpy as np +import h5py as h5 +import sys +import matplotlib.pyplot as plt +from tqdm import tqdm +# Import base functionality of Isle. +import isle +# Import drivers (not included in above). +import isle.drivers + + +if len(sys.argv) > 1: + #HMC data file + HMC_data_file = str(sys.argv[1]) +else: + print("Please enter the h5 file") + sys.exit() + +hf = h5.File(HMC_data_file, 'r') + +LATTICE = "four_sites" +lat = isle.LATTICES[LATTICE] +Nt = 32 # number of time steps +lat.nt(Nt) + +PARAMS = isle.util.parameters( + beta=3.0, # inverse temperature + U=3.0, # on-site coupling + mu=0, # chemical potential + sigmaKappa=-1, # prefactor of kappa for holes / spin down + # (+1 only allowed for bipartite lattices) + + # Those three control which implementation of the action gets used. + # The values given here are the defaults. + # See documentation in docs/algorithm. + hopping=isle.action.HFAHopping.EXP, + basis=isle.action.HFABasis.PARTICLE_HOLE, + algorithm=isle.action.HFAAlgorithm.DIRECT_SINGLE +) + +def makeAction(lat, params): + # Import everything this function needs so it is self-contained. + import isle + import isle.action + + return isle.action.HubbardGaugeAction(params.tilde("U", lat)) \ + + isle.action.makeHubbardFermiAction(lat, + params.beta, + params.tilde("mu", lat), + params.sigmaKappa, + params.hopping, + params.basis, + params.algorithm) +#calculates the action +action = makeAction(lat,PARAMS) + + +#loading the trajectory indexes from actual HMC run +traj_index = [int(index) for index in np.array((hf['configuration']))] +check_index = [print("negative index") for i in traj_index if i < 0] + +############intialization################## +training_actualHMC = np.zeros((len(traj_index),lat.lattSize()))+ 0j +gradient_actualHMC = np.zeros((len(traj_index),lat.lattSize()))+ 0j +# action_HMC = np.zeros(len(traj_index)) + 0.j + +# training data from Gaussian distribution +num_samples = 10000 +training_gaus = np.zeros((num_samples,lat.lattSize())) + 0j +gradient_gaus = np.zeros((num_samples,lat.lattSize())) + 0j + +#stores data from Actual HMC and Gaussian distributions +xx = np.zeros((len(traj_index)+ num_samples,lat.lattSize())) + 0j +yy = np.zeros((len(traj_index)+ num_samples,lat.lattSize())) + 0j + + +#loading actual HMC phi's and calculating the force +with h5.File(HMC_data_file, "r") as h5f: + for i,index in tqdm(enumerate(traj_index)): + # get the configuration group with the given index + cfgGrp = hf["configuration"][str(index)] + training_actualHMC[i,:] , _ = cfgGrp["phi"][()], cfgGrp["actVal"][()] + gradient_actualHMC[i,:] = -action.force(isle.Vector(training_actualHMC[i,:]+0j)) + + + +#creating gaussian samples +for i in tqdm(range(num_samples)): + training_gaus[i,:] = np.random.normal(0,PARAMS.tilde("U", lat)**(1/2),lat.lattSize()) + gradient_gaus[i,:] = -action.force(isle.Vector(training_gaus[i,:]+0j)) + +# joining actual HMC and gaussian data +xx[:num_samples,:] = training_gaus[:num_samples,:] +xx[num_samples:,:] = training_actualHMC[:,:] +yy[:num_samples,:] = gradient_gaus[:num_samples,:] +yy[num_samples:,:] = gradient_actualHMC[:,:] + +#saving the training_data +np.save(f'trainingData_NN/tinputs_4sites_U{PARAMS.U}B{PARAMS.beta}Nt{Nt}',xx) +np.save(f'trainingData_NN/ttargets_4sites_U{PARAMS.U}B{PARAMS.beta}Nt{Nt}',yy) + +#plotting histogram of training_data +plt.hist(np.real(xx).flatten(),density=True,bins=30,label='training_gaus + HMC') +plt.legend() +plt.savefig(f'trainingData_NN/ttrainingData_4sites_U{PARAMS.U}B{PARAMS.beta}Nt{Nt}.pdf') \ No newline at end of file diff --git a/docs/examples/fullHMCEvolution.py b/docs/examples/fullHMCEvolution.py index 1875d077..7519f968 100644 --- a/docs/examples/fullHMCEvolution.py +++ b/docs/examples/fullHMCEvolution.py @@ -13,9 +13,9 @@ ### Specify input / output files # Write all data to this file. -OUTFILE = "hmc-example.out.h5" +OUTFILE = "trainingData_NN/HMC_run/TwositesU2B2Nt16.h5" # Name of the lattice. -LATTICE = "four_sites" +LATTICE = "two_sites" ### Specify parameters. # isle.util.parameters takes arbitrary keyword arguments, constructs a new dataclass, @@ -26,8 +26,8 @@ # Note that all objects stored in here must be representable in and constructible # from YAML. You need to register new handlers if you have custom types. PARAMS = isle.util.parameters( - beta=3, # inverse temperature - U=2, # on-site coupling + beta=6., # inverse temperature + U=4., # on-site coupling mu=0, # chemical potential sigmaKappa=-1, # prefactor of kappa for holes / spin down # (+1 only allowed for bipartite lattices) @@ -35,7 +35,7 @@ # Those three control which implementation of the action gets used. # The values given here are the defaults. # See documentation in docs/algorithm. - hopping=isle.action.HFAHopping.DIA, + hopping=isle.action.HFAHopping.EXP, basis=isle.action.HFABasis.PARTICLE_HOLE, algorithm=isle.action.HFAAlgorithm.DIRECT_SINGLE ) @@ -123,7 +123,7 @@ def main(): evolver = isle.evolver.ConstStepLeapfrog(hmcState.action, 1, 5, rng) # Produce configurations and save in intervals of 2 trajectories. # Place a checkpoint every 10 trajectories. - hmcState(evStage, evolver, 100, saveFreq=2, checkpointFreq=10) + hmcState(evStage, evolver, 10000, saveFreq=1, checkpointFreq=10) # That is it, clean up happens automatically. diff --git a/docs/examples/fullHMCEvolutionML.py b/docs/examples/fullHMCEvolutionML.py new file mode 100755 index 00000000..264590d2 --- /dev/null +++ b/docs/examples/fullHMCEvolutionML.py @@ -0,0 +1,133 @@ +""" +Example script to show how to set up the HMC driver for production including thermalization. +""" + +# All output should go through a logger for better control and consistency. +from logging import getLogger +import numpy as np +# Import base functionality of Isle. +import isle +# Import drivers (not included in above). +import isle.drivers + +# Name of the lattice. +LATTICE = "two_sites" + +### Specify parameters +# isle.util.parameters takes arbitrary keyword arguments, constructs a new dataclass, +# and stores the function arguments in an instance of it. +# The object is written to the output file and read back in by all subsequent processes. +# Use this to store all physical and model parameters and make them accessible later. +# +# Note that all objects stored in here must be representable in and constructible +# from YAML. You need to register new handlers if you have custom types. +PARAMS = isle.util.parameters( + beta=4., # inverse temperature + U=2., # on-site coupling + mu=0, # chemical potential + sigmaKappa=-1, # prefactor of kappa for holes / spin down + # (+1 only allowed for bipartite lattices) + + # Those three control which implementation of the action gets used. + # The values given here are the defaults. + # See documentation in docs/algorithm. + hopping=isle.action.HFAHopping.EXP, + basis=isle.action.HFABasis.PARTICLE_HOLE, + algorithm=isle.action.HFAAlgorithm.ML_APPROX_FORCE, + allowShortcut = False, + module_path="/p/project/cjjsc37/john/testing/isle/docs/examples/NNgHMC_models/NNgModel_2sitesU2B4Nt16.pt") +# Set the number of time slices. +# This is stored in isle.Lattice and does not go into the above object. +NT = 16 + +### Specify input / output files +# Write all data to this file. +OUTFILE = f"testNNgHMC_2sitesNmd3_U{PARAMS.U}B{PARAMS.beta}Nt{NT}.h5" + + +### Function to construct actions. +# This function has to construct and return all actions to be used in HMC. +# It is saved as source code to the output file and read back in by any +# subsequent process. It can therefore not rely on any external (global) state +# and must define / import everything it needs! +# +# Parameters: +# lat - An instance of isle.Lattice containing the hopping matrix +# and number of time steps. +# params - Dataclass instance of parameters, see above (PARAMS). +def makeAction(lat, params): + # Import everything this function needs so it is self-contained. + import isle + import isle.action + + return isle.action.makeHubbardFermiActionMLApprox(lat, + params.beta, + params.tilde("mu", lat), + params.sigmaKappa, + params.hopping, + params.basis, + params.algorithm, + params.allowShortcut,params.module_path, + params.tilde("U", lat)) + + +def main(): + # Initialize Isle. + # This sets up the command line interface, defines a barebones argument parser, + # and parses and returns parsed arguments. + # More complex parsers can be automatically defined or passed in manually. + # See, e.g., `hmcThermalization.py` or `measure.py` examples. + isle.initialize("default") + + # Get a logger. Use this instead of print() to output any and all information. + log = getLogger("HMC") + + # Load the spatial lattice. + # Note: This command loads a lattice that is distributed together with Isle. + # In order to load custom lattices from a file, use + # either isle.LATTICES.loadExternal(filename) + # or isle.fileio.yaml.loadLattice(filename) + lat = isle.LATTICES[LATTICE] + # Lattice files usually only contain information on the spatial lattice + # to be more flexible. Set the number of time slices here. + lat.nt(NT) + + # Set up a random number generator. + rng = isle.random.NumpyRNG(1075) + + # Set up a fresh HMC driver. + # It handles all HMC evolution as well as I/O. + # Last argument forbids the driver to overwrite any existing data. + hmcState = isle.drivers.hmc.newRun(lat, PARAMS, rng, makeAction, + OUTFILE, False) + + # Generate a random initial condition. + # Note that configurations must be vectors of complex numbers. + phi = isle.Vector(rng.normal(0, + PARAMS.tilde("U", lat)**(1/2), + lat.lattSize()) + +0j) + + # Run thermalization. + log.info("Thermalizing") + # Pick an evolver which linearly decreases the number of MD steps from 20 to 5. + # The number of steps (99) must be one less than the number of trajectories below. + evolver = isle.evolver.LinearStepLeapfrog(hmcState.action, (1, 1), (20, 5), 99, rng) + # Thermalize configuration for 100 trajectories without saving anything. + evStage = hmcState(phi, evolver, 100, saveFreq=0, checkpointFreq=0) + # Reset the internal counter so we start saving configs at index 0. + hmcState.resetIndex() + + # Run production. + log.info("Producing") + + # Pick a new evolver with a constant number of steps to get a reproducible ensemble. + evolver = isle.evolver.ConstStepLeapfrog(hmcState.action, 1,3, rng) + # Produce configurations and save in intervals of 2 trajectories. + # Place a checkpoint every 10 trajectories. + hmcState(phi, evolver,10000, saveFreq=1, checkpointFreq=10) + + # That is it, clean up happens automatically. + +if __name__ == "__main__": + main() diff --git a/docs/examples/hmcThermalization.py b/docs/examples/hmcThermalization.py old mode 100644 new mode 100755 diff --git a/docs/examples/measure.py b/docs/examples/measure.py old mode 100644 new mode 100755 diff --git a/docs/examples/mpiTuning.py b/docs/examples/mpiTuning.py old mode 100644 new mode 100755 diff --git a/docs/examples/tuning.py b/docs/examples/tuning.py old mode 100644 new mode 100755 diff --git a/docs/images/isle_logo.svg b/docs/images/isle_logo.svg old mode 100644 new mode 100755 diff --git a/docs/pages/evolvers.md b/docs/pages/evolvers.md old mode 100644 new mode 100755 diff --git a/docs/pages/examples.md b/docs/pages/examples.md old mode 100644 new mode 100755 diff --git a/docs/pages/file_layout.md b/docs/pages/file_layout.md old mode 100644 new mode 100755 diff --git a/docs/pages/meas.md b/docs/pages/meas.md old mode 100644 new mode 100755 diff --git a/pylintrc b/pylintrc old mode 100644 new mode 100755 diff --git a/requirements.txt b/requirements.txt old mode 100644 new mode 100755 diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 diff --git a/setup/__init__.py b/setup/__init__.py old mode 100644 new mode 100755 diff --git a/setup/build.py b/setup/build.py old mode 100644 new mode 100755 diff --git a/setup/cmake_extension.py b/setup/cmake_extension.py old mode 100644 new mode 100755 diff --git a/setup/configure.py b/setup/configure.py old mode 100644 new mode 100755 diff --git a/setup/docs.py b/setup/docs.py old mode 100644 new mode 100755 diff --git a/setup/predicate.py b/setup/predicate.py old mode 100644 new mode 100755 diff --git a/setup/version.py b/setup/version.py old mode 100644 new mode 100755 diff --git a/src/isle/__init__.py b/src/isle/__init__.py old mode 100644 new mode 100755 diff --git a/src/isle/action/__init__.py b/src/isle/action/__init__.py old mode 100644 new mode 100755 diff --git a/src/isle/checks.py b/src/isle/checks.py old mode 100644 new mode 100755 diff --git a/src/isle/cli.py b/src/isle/cli.py old mode 100644 new mode 100755 diff --git a/src/isle/collection.py b/src/isle/collection.py old mode 100644 new mode 100755 diff --git a/src/isle/cpp/CMakeLists.txt b/src/isle/cpp/CMakeLists.txt old mode 100644 new mode 100755 index b1057304..537a0088 --- a/src/isle/cpp/CMakeLists.txt +++ b/src/isle/cpp/CMakeLists.txt @@ -59,8 +59,9 @@ set(ISLE_VERSION_EXTRA CACHE STRING "Extra version info of Isle") configure_file(version.hpp.in version.hpp) target_include_directories(${LIBNAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) - target_include_directories(${LIBNAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) # add bindings code add_subdirectory(bind) + + diff --git a/src/isle/cpp/action/action.hpp b/src/isle/cpp/action/action.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/action/hubbardFermiAction.cpp b/src/isle/cpp/action/hubbardFermiAction.cpp old mode 100644 new mode 100755 index 6c50b952..c5731fc8 --- a/src/isle/cpp/action/hubbardFermiAction.cpp +++ b/src/isle/cpp/action/hubbardFermiAction.cpp @@ -297,6 +297,89 @@ namespace isle { return -1.i*forceDirectSquare(_hfm, -1.i*phi); } + + std::complex + HubbardFermiAction::eval( + const CDVector &phi) const { + + // evaluvates the fermi and gauge action + + if (_shortcutForHoles) { + const auto ldp = logdetM(_hfm, phi, Species::PARTICLE); + return -toFirstLogBranch(ldp + std::conj(ldp)) + + (phi, phi)/2./_utilde ; + } + else { + return -toFirstLogBranch(logdetM(_hfm, phi, Species::PARTICLE) + + logdetM(_hfm, phi, Species::HOLE)) + + (phi, phi)/2./_utilde; + } + } + CDVector + HubbardFermiAction::force( + const CDVector & phi) const{ + /// The Pytorch Model predicts the force (Gauge+Fermi) + + // auto b = at::zeros(phi.size(),at::dtype(at::kComplexDouble)); + // for (std::size_t i=0; i(phi[i]); + + // } + + auto b = torch::zeros(phi.size(), torch::TensorOptions().dtype(torch::kFloat64)); + for (std::size_t i=0; i inputs ; + inputs.push_back(b); + torch::Tensor output = _model.forward(inputs).toTensor(); + CDVector y (phi.size()) ; + + std::transform (output.data_ptr(),output.data_ptr()+phi.size(),y.begin(), + [](double x ){return std::complex(x,0);}); + + // std::transform (output.data_ptr>(),output.data_ptr>()+phi.size(),y.begin(), + // [](c10::complex x ){return std::complex(x);}); + // std::cout <<"force="<< std::setprecision(10)<< y << std::endl; + // std::cout << "---------------------" <::HubbardFermiAction( + const SparseMatrix &kappaTilde, + const double muTilde, const std::int8_t sigmaKappa, + const bool allowShortcut, const std::string model_path,const double utilde) + : _hfm{kappaTilde, muTilde, sigmaKappa}, + _kp{_hfm.K(Species::PARTICLE)}, + _kh{_hfm.K(Species::HOLE)}, + _shortcutForHoles{allowShortcut + && _internal::_holeShortcutPossible( + kappaTilde, muTilde, sigmaKappa)}, + _model(torch::jit::load(model_path)), + _utilde{utilde} + {} + + + + HubbardFermiAction::HubbardFermiAction( + const Lattice &lat, const double beta, + const double muTilde, const std::int8_t sigmaKappa, + const bool allowShortcut,const std::string model_path,const double utilde) + :_hfm{lat, beta, muTilde, sigmaKappa}, + _kp{_hfm.K(Species::PARTICLE)}, + _kh{_hfm.K(Species::HOLE)}, + _shortcutForHoles{allowShortcut + && _internal::_holeShortcutPossible( + lat.hopping(), muTilde, sigmaKappa)}, + _model(torch::jit::load(model_path)), + _utilde{utilde} + {} + + + // instantiate all the templates we need right here template class HubbardFermiAction; template class HubbardFermiAction; @@ -308,5 +391,7 @@ namespace isle { template class HubbardFermiAction; template class HubbardFermiAction; + template class HubbardFermiAction; + } // namespace action } // namespace isle diff --git a/src/isle/cpp/action/hubbardFermiAction.hpp b/src/isle/cpp/action/hubbardFermiAction.hpp old mode 100644 new mode 100755 index ffb1323e..c7f42fe3 --- a/src/isle/cpp/action/hubbardFermiAction.hpp +++ b/src/isle/cpp/action/hubbardFermiAction.hpp @@ -9,6 +9,10 @@ #include "../hubbardFermiMatrixDia.hpp" #include "../hubbardFermiMatrixExp.hpp" #include "../lattice.hpp" +#include +#include +#include + namespace isle { namespace action { @@ -22,7 +26,7 @@ namespace isle { /** * See documentation in docs/algorithm for more information. */ - enum class HFAAlgorithm { DIRECT_SINGLE, DIRECT_SQUARE }; + enum class HFAAlgorithm { DIRECT_SINGLE, DIRECT_SQUARE, ML_APPROX_FORCE}; /// \cond DO_NOT_DOCUMENT namespace _internal { @@ -43,6 +47,7 @@ namespace isle { const std::int8_t sigmaKappa); + template <> bool _holeShortcutPossible( const SparseMatrix &hopping, const double muTilde, @@ -120,6 +125,8 @@ namespace isle { lat.hopping(), muTilde, sigmaKappa)} { } + + HubbardFermiAction(const HubbardFermiAction &other) = default; HubbardFermiAction &operator=(const HubbardFermiAction &other) = default; HubbardFermiAction(HubbardFermiAction &&other) = default; @@ -139,6 +146,8 @@ namespace isle { const typename _internal::KMatrixType::type _kh; ///< Matrix K for holes. /// Can logdetM for holes be computed from logdetM from particles? const bool _shortcutForHoles; + //torch::jit::script::Module _model; + }; // For each specialization, forward declare specializations of eval @@ -169,6 +178,8 @@ namespace isle { HubbardFermiAction::force( const CDVector &phi) const; + + template <> std::complex HubbardFermiAction::eval( const CDVector &phi) const; @@ -206,6 +217,49 @@ namespace isle { extern template class HubbardFermiAction; extern template class HubbardFermiAction; + template<> + class HubbardFermiAction:public Action{ + public: + + + + /// Construct from individual parameters of HubbardFermiMatrix[Dia,Exp]. + HubbardFermiAction(const SparseMatrix &kappaTilde, + const double muTilde, const std::int8_t sigmaKappa, + const bool allowShortcut,const std::string model_path,const double utilde); + + + /// Construct from individual parameters of HubbardFermiMatrix[Dia,Exp]. + HubbardFermiAction(const Lattice &lat, const double beta, + const double muTilde, const std::int8_t sigmaKappa, + const bool allowShortcut,std::string model_path,const double utilde); + + + HubbardFermiAction(const HubbardFermiAction &other) = default; + HubbardFermiAction &operator=(const HubbardFermiAction &other) = default; + HubbardFermiAction(HubbardFermiAction &&other) = default; + HubbardFermiAction &operator=(HubbardFermiAction &&other) = default; + ~HubbardFermiAction() override = default; + + /// Evaluate the %Action for given auxilliary field phi. + std::complex eval(const CDVector &phi) const override; + + /// Calculate force for given auxilliary field phi. + CDVector force(const CDVector &phi) const override; + + private: + /// Stores all necessary parameters. + const typename _internal::HFM::type _hfm; + const typename _internal::KMatrixType::type _kp; ///< Matrix K for particles. + const typename _internal::KMatrixType::type _kh; ///< Matrix K for holes. + /// Can logdetM for holes be computed from logdetM from particles? + const bool _shortcutForHoles; + mutable torch::jit::script::Module _model; + double _utilde; + + + }; + } // namespace action } // namespace isle diff --git a/src/isle/cpp/action/hubbardGaugeAction.cpp b/src/isle/cpp/action/hubbardGaugeAction.cpp old mode 100644 new mode 100755 index 0489bdc1..fe38d624 --- a/src/isle/cpp/action/hubbardGaugeAction.cpp +++ b/src/isle/cpp/action/hubbardGaugeAction.cpp @@ -9,8 +9,9 @@ namespace isle { } Vector> HGA::force(const Vector> &phi) const { - return -phi/utilde; + return -phi/utilde; } + } // namespace action } // namespace isle diff --git a/src/isle/cpp/action/hubbardGaugeAction.hpp b/src/isle/cpp/action/hubbardGaugeAction.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/action/sumAction.cpp b/src/isle/cpp/action/sumAction.cpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/action/sumAction.hpp b/src/isle/cpp/action/sumAction.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/CMakeLists.txt b/src/isle/cpp/bind/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bind_action.cpp b/src/isle/cpp/bind/bind_action.cpp old mode 100644 new mode 100755 index 8c7fd76d..89fe4afb --- a/src/isle/cpp/bind/bind_action.cpp +++ b/src/isle/cpp/bind/bind_action.cpp @@ -34,6 +34,7 @@ namespace bind { ); } }; + void addAction(SumAction &sum, py::object &action) { try { @@ -97,17 +98,26 @@ namespace bind { ; } + + template void bindSpecificHFA(py::module &mod, const char * const name, A &action) { using HFA = HubbardFermiAction; - py::class_(mod, name, action) - .def(py::init, double, std::int8_t, bool>(), - "kappa"_a, "mu"_a, "sigmaKappa"_a, "allowShortcut"_a) - .def("eval", &HFA::eval) - .def("force", &HFA::force) - ; + if constexpr (ALGORITHM == HFAAlgorithm::ML_APPROX_FORCE) { + py::class_(mod, name, action) + .def(py::init,double, std::int8_t, bool, std::string,double>(), + "kappa"_a, "mu"_a, "sigmaKappa"_a, "allowShortcut"_a, "model_path"_a,"utilde"_a) + .def("eval", &HFA::eval) + .def("force", &HFA::force); + } else{ + py::class_(mod, name, action) + .def(py::init, double, std::int8_t, bool>(), + "kappa"_a, "mu"_a, "sigmaKappa"_a, "allowShortcut"_a) + .def("eval", &HFA::eval) + .def("force", &HFA::force); + } } /// Make a specific HubbardFermiAction controlled through run-time parameters. @@ -135,15 +145,15 @@ namespace bind { return py::cast(HubbardFermiAction(kappaTilde, muTilde, sigmaKappa, allowShortcut)); - } else { // HFAAlgorithm::DIRECT_SQUARE + } else if(algorithm == HFAAlgorithm::DIRECT_SQUARE){ return py::cast(HubbardFermiAction(kappaTilde, muTilde, sigmaKappa, allowShortcut)); + } else { + throw std::invalid_argument("makeHubbardFermiAction is not implemented for algorithm = HFAAlgorithm.ML_APPROX_FORCE"); } } - } - - else { // HFABasis::SPIN + } else { // HFABasis::SPIN if (hopping == HFAHopping::DIA) { if (algorithm == HFAAlgorithm::DIRECT_SINGLE) { return py::cast(HubbardFermiAction &kappaTilde, + const double muTilde, + const std::int8_t sigmaKappa, + const HFAHopping hopping, + const HFABasis basis, + const HFAAlgorithm algorithm, + const bool allowShortcut,const std::string model_path, + const double utilde) { + if (basis == HFABasis::PARTICLE_HOLE) { + if (hopping == HFAHopping::EXP) { + if (algorithm == HFAAlgorithm::ML_APPROX_FORCE) { + return py::cast(HubbardFermiAction(kappaTilde, muTilde, sigmaKappa, allowShortcut,model_path,utilde)); + } + else{ + throw std::invalid_argument("makeHubbardFermiActionMLApprox only for ML_APPROX_FORCE is defined "); + } + } + else{ + throw std::invalid_argument("makeHubbardFermiActionMLApprox only for EXP is defined "); + } + } + else{ + throw std::invalid_argument("makeHubbardFermiActionMLApprox only for Particle_HOLE is defined "); + } + } + /// Bind everything related to HubbardFermiActions. template void bindHubbardFermiAction(py::module &mod, A &action) { // bind enums py::enum_(mod, "HFAAlgorithm") .value("DIRECT_SINGLE", HFAAlgorithm::DIRECT_SINGLE) - .value("DIRECT_SQUARE", HFAAlgorithm::DIRECT_SQUARE); + .value("DIRECT_SQUARE", HFAAlgorithm::DIRECT_SQUARE) + .value("ML_APPROX_FORCE", HFAAlgorithm::ML_APPROX_FORCE); py::enum_(mod, "HFABasis") .value("PARTICLE_HOLE", HFABasis::PARTICLE_HOLE) @@ -195,6 +235,8 @@ namespace bind { bindSpecificHFA(mod, "HubbardFermiActionExpDirsquareOne", action); bindSpecificHFA(mod, "HubbardFermiActionExpDirsquareZero", action); + bindSpecificHFA(mod, "HubbardFermiActionExpMLApproxOne", action); + mod.def("makeHubbardFermiAction", makeHubbardFermiAction, "kappaTilde"_a, "muTilde"_a, "sigmaKappa"_a, @@ -219,6 +261,36 @@ namespace bind { "basis"_a=HFABasis::PARTICLE_HOLE, "algorithm"_a= HFAAlgorithm::DIRECT_SINGLE, "allowShortcut"_a=false); + + mod.def("makeHubbardFermiActionMLApprox", + makeHubbardFermiActionMLApprox, + "kappaTilde"_a, "muTilde"_a, "sigmaKappa"_a, + "hopping"_a=HFAHopping::EXP, + "basis"_a=HFABasis::PARTICLE_HOLE, + "algorithm"_a= HFAAlgorithm::ML_APPROX_FORCE, + "allowShortcut"_a=false, + "model_path"_a, + "utilde"_a); + + mod.def("makeHubbardFermiActionMLApprox", + [] (const Lattice &lattice, const double beta, + const double muTilde, const std::int8_t sigmaKappa, + const HFAHopping hopping, const HFABasis basis, + const HFAAlgorithm algorithm, const bool allowShortcut, + const std::string model_path,const double utilde) { + + return makeHubbardFermiActionMLApprox( + lattice.hopping()*beta/lattice.nt(), + muTilde, sigmaKappa, + hopping, basis, algorithm, allowShortcut,model_path,utilde); + }, + "lat"_a, "beta"_a,"muTilde"_a, "sigmaKappa"_a, + "hopping"_a=HFAHopping::EXP, + "basis"_a=HFABasis::PARTICLE_HOLE, + "algorithm"_a= HFAAlgorithm::ML_APPROX_FORCE, + "allowShortcut"_a=false, + "model_path"_a, + "utilde"_a); } } diff --git a/src/isle/cpp/bind/bind_action.hpp b/src/isle/cpp/bind/bind_action.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bind_core.hpp b/src/isle/cpp/bind/bind_core.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bind_hubbardFermiMatrix.cpp b/src/isle/cpp/bind/bind_hubbardFermiMatrix.cpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bind_hubbardFermiMatrix.hpp b/src/isle/cpp/bind/bind_hubbardFermiMatrix.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bind_integrator.cpp b/src/isle/cpp/bind/bind_integrator.cpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bind_integrator.hpp b/src/isle/cpp/bind/bind_integrator.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bind_lattice.cpp b/src/isle/cpp/bind/bind_lattice.cpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bind_lattice.hpp b/src/isle/cpp/bind/bind_lattice.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bind_math.cpp b/src/isle/cpp/bind/bind_math.cpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bind_math.hpp b/src/isle/cpp/bind/bind_math.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bind_version.cpp b/src/isle/cpp/bind/bind_version.cpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bind_version.hpp b/src/isle/cpp/bind/bind_version.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/bind/bindings.cpp b/src/isle/cpp/bind/bindings.cpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/cache.hpp b/src/isle/cpp/cache.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/core.hpp b/src/isle/cpp/core.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/hubbardFermiMatrixDia.cpp b/src/isle/cpp/hubbardFermiMatrixDia.cpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/hubbardFermiMatrixDia.hpp b/src/isle/cpp/hubbardFermiMatrixDia.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/hubbardFermiMatrixExp.cpp b/src/isle/cpp/hubbardFermiMatrixExp.cpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/hubbardFermiMatrixExp.hpp b/src/isle/cpp/hubbardFermiMatrixExp.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/integrator.cpp b/src/isle/cpp/integrator.cpp old mode 100644 new mode 100755 index a9840100..8aea593a --- a/src/isle/cpp/integrator.cpp +++ b/src/isle/cpp/integrator.cpp @@ -1,6 +1,8 @@ #include "integrator.hpp" #include +#include +#include using namespace std::complex_literals; @@ -15,13 +17,13 @@ namespace isle { const double direction) { const double eps = direction*length/static_cast(nsteps); - + // initial half step CDVector piOut = pi + blaze::real(action->force(phi))*(eps/2); // first step in phi explicit in order to init new variable CDVector phiOut = phi + piOut*eps; - + // bunch of full steps for (std::size_t i = 0; i < nsteps-1; ++i) { piOut += blaze::real(action->force(phiOut))*eps; @@ -30,7 +32,7 @@ namespace isle { // last half step piOut += blaze::real(action->force(phiOut))*(eps/2); - + const std::complex actVal = action->eval(phiOut); return std::make_tuple(std::move(phiOut), std::move(piOut), actVal); } diff --git a/src/isle/cpp/integrator.hpp b/src/isle/cpp/integrator.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/lattice.cpp b/src/isle/cpp/lattice.cpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/lattice.hpp b/src/isle/cpp/lattice.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/logging/CMakeLists.txt b/src/isle/cpp/logging/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/isle/cpp/logging/logging.cpp b/src/isle/cpp/logging/logging.cpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/logging/logging.hpp b/src/isle/cpp/logging/logging.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/math.hpp b/src/isle/cpp/math.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/memory.hpp b/src/isle/cpp/memory.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/species.hpp b/src/isle/cpp/species.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/tmp.hpp b/src/isle/cpp/tmp.hpp old mode 100644 new mode 100755 diff --git a/src/isle/cpp/version.hpp.in b/src/isle/cpp/version.hpp.in old mode 100644 new mode 100755 diff --git a/src/isle/cpp_wrappers.py b/src/isle/cpp_wrappers.py old mode 100644 new mode 100755 diff --git a/src/isle/drivers/__init__.py b/src/isle/drivers/__init__.py old mode 100644 new mode 100755 diff --git a/src/isle/drivers/hmc.py b/src/isle/drivers/hmc.py old mode 100644 new mode 100755 index 0d5a9da8..eeea3cf8 --- a/src/isle/drivers/hmc.py +++ b/src/isle/drivers/hmc.py @@ -252,7 +252,7 @@ def _stride(values): def _loadIndices(fname): """! - Load all configuration anc checkpoint indices from a file. + Load all configuration and checkpoint indices from a file. """ with h5.File(str(fname), "r") as h5f: configurations = sorted(map(int, h5f["configuration"].keys())) diff --git a/src/isle/drivers/meas.py b/src/isle/drivers/meas.py old mode 100644 new mode 100755 index 70c08ff1..2642d4a0 --- a/src/isle/drivers/meas.py +++ b/src/isle/drivers/meas.py @@ -21,7 +21,7 @@ class Measure: Assumes that configurations are stored in the default format as written by e.g. the driver isle.drivers.hmc.HMC. - Measurement results can be written to a new file or to the iput file. + Measurement results can be written to a new file or to the input file. The driver checks for conflicts should the output file already exist and removes conflicting entries iff it is initialized with `overwrite==True`. This assumes that the measurements only write to the file under their `savePath` diff --git a/src/isle/evolver/__init__.py b/src/isle/evolver/__init__.py old mode 100644 new mode 100755 diff --git a/src/isle/evolver/alternator.py b/src/isle/evolver/alternator.py old mode 100644 new mode 100755 diff --git a/src/isle/evolver/autotuner.py b/src/isle/evolver/autotuner.py old mode 100644 new mode 100755 diff --git a/src/isle/evolver/evolver.py b/src/isle/evolver/evolver.py old mode 100644 new mode 100755 diff --git a/src/isle/evolver/hubbard.py b/src/isle/evolver/hubbard.py old mode 100644 new mode 100755 diff --git a/src/isle/evolver/leapfrog.py b/src/isle/evolver/leapfrog.py old mode 100644 new mode 100755 index 36e5fb41..eb453080 --- a/src/isle/evolver/leapfrog.py +++ b/src/isle/evolver/leapfrog.py @@ -48,15 +48,17 @@ def evolve(self, stage): stage.logWeights["logdetJ"] = logdetJ # do MD integration - pi = Vector(self.rng.normal(0, 1, len(stage.phi))+0j) + pi = Vector(self.rng.normal(0, 1, len(stage.phi))+0j) + phiMD1, pi1, actValMD1 = leapfrog(phiMD, pi, self.action, self.length, self.nstep) # transform to MC manifold phi1, actVal1, logdetJ1 = forwardTransform(self.transform, phiMD1, actValMD1) - + # accept/reject on MC manifold - energy0 = stage.sumLogWeights()+np.linalg.norm(pi)**2/2 - energy1 = actVal1+logdetJ1+np.linalg.norm(pi1)**2/2 + energy0 = stage.sumLogWeights()+0.5*np.linalg.norm(pi)**2 + energy1 = actVal1+logdetJ1+0.5*np.linalg.norm(pi1)**2 + trajPoint = self.selector.selectTrajPoint(energy0, energy1) self.trajPoints.append(trajPoint) @@ -160,9 +162,10 @@ def evolve(self, stage): phiMD, logdetJ = backwardTransform(self.transform, stage) if self.transform is not None and "logdetJ" not in stage.logWeights: stage.logWeights["logdetJ"] = logdetJ - + # do MD integration pi = Vector(self.rng.normal(0, 1, len(stage.phi))+0j) + phiMD1, pi1, actValMD1 = leapfrog(phiMD, pi, self.action, next(self._lengthIter), int(next(self._nstepIter))) @@ -170,8 +173,10 @@ def evolve(self, stage): phi1, actVal1, logdetJ1 = forwardTransform(self.transform, phiMD1, actValMD1) # accept/reject on MC manifold - energy0 = stage.sumLogWeights()+np.linalg.norm(pi)**2/2 + energy0 = stage.sumLogWeights()+0.5*np.linalg.norm(pi)**2 energy1 = actVal1+logdetJ1+np.linalg.norm(pi1)**2/2 + + trajPoint = self.selector.selectTrajPoint(energy0, energy1) self.trajPoints.append(trajPoint) diff --git a/src/isle/evolver/manager.py b/src/isle/evolver/manager.py old mode 100644 new mode 100755 diff --git a/src/isle/evolver/selector.py b/src/isle/evolver/selector.py old mode 100644 new mode 100755 index 2b3d6606..97f0cfbe --- a/src/isle/evolver/selector.py +++ b/src/isle/evolver/selector.py @@ -39,6 +39,6 @@ def selectTrajectory(self, energy0, data0, energy1, data1): \return `(energy0, data0, 0)` if `energy0` was selected, otherwise `(energy1, data1, 1)`. """ - + return (energy1, data1, 1) if self.selectTrajPoint(energy0, energy1) == 1 \ else (energy0, data0, 0) diff --git a/src/isle/evolver/stage.py b/src/isle/evolver/stage.py old mode 100644 new mode 100755 diff --git a/src/isle/evolver/transform/__init__.py b/src/isle/evolver/transform/__init__.py old mode 100644 new mode 100755 diff --git a/src/isle/evolver/transform/constantShift.py b/src/isle/evolver/transform/constantShift.py old mode 100644 new mode 100755 diff --git a/src/isle/evolver/transform/identity.py b/src/isle/evolver/transform/identity.py old mode 100644 new mode 100755 diff --git a/src/isle/evolver/transform/transform.py b/src/isle/evolver/transform/transform.py old mode 100644 new mode 100755 diff --git a/src/isle/fileio.py b/src/isle/fileio.py old mode 100644 new mode 100755 diff --git a/src/isle/h5io.py b/src/isle/h5io.py old mode 100644 new mode 100755 diff --git a/src/isle/meas/__init__.py b/src/isle/meas/__init__.py old mode 100644 new mode 100755 diff --git a/src/isle/meas/chiralCondensate.py b/src/isle/meas/chiralCondensate.py old mode 100644 new mode 100755 diff --git a/src/isle/meas/collectWeights.py b/src/isle/meas/collectWeights.py old mode 100644 new mode 100755 diff --git a/src/isle/meas/determinantCorrelators.py b/src/isle/meas/determinantCorrelators.py old mode 100644 new mode 100755 diff --git a/src/isle/meas/logdet.py b/src/isle/meas/logdet.py old mode 100644 new mode 100755 diff --git a/src/isle/meas/measurement.py b/src/isle/meas/measurement.py old mode 100644 new mode 100755 diff --git a/src/isle/meas/onePointFunctions.py b/src/isle/meas/onePointFunctions.py old mode 100644 new mode 100755 diff --git a/src/isle/meas/polyakov.py b/src/isle/meas/polyakov.py old mode 100644 new mode 100755 diff --git a/src/isle/meas/propagator.py b/src/isle/meas/propagator.py old mode 100644 new mode 100755 diff --git a/src/isle/meas/singleParticleCorrelator.py b/src/isle/meas/singleParticleCorrelator.py old mode 100644 new mode 100755 diff --git a/src/isle/meas/spinSpinCorrelator.py b/src/isle/meas/spinSpinCorrelator.py old mode 100644 new mode 100755 diff --git a/src/isle/meas/totalPhi.py b/src/isle/meas/totalPhi.py old mode 100644 new mode 100755 diff --git a/src/isle/memoize.py b/src/isle/memoize.py old mode 100644 new mode 100755 diff --git a/src/isle/meta.py b/src/isle/meta.py old mode 100644 new mode 100755 diff --git a/src/isle/plotting.py b/src/isle/plotting.py old mode 100644 new mode 100755 diff --git a/src/isle/random.py b/src/isle/random.py old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/c20.yml b/src/isle/resources/lattices/c20.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/c60_ipr.yml b/src/isle/resources/lattices/c60_ipr.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/diamond.yml b/src/isle/resources/lattices/diamond.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/four_sites.yml b/src/isle/resources/lattices/four_sites.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/four_sites_square.yml b/src/isle/resources/lattices/four_sites_square.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/graphene_7_5.yml b/src/isle/resources/lattices/graphene_7_5.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/icosahedron.yml b/src/isle/resources/lattices/icosahedron.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/one_site.yml b/src/isle/resources/lattices/one_site.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/pentagon.yml b/src/isle/resources/lattices/pentagon.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/ribbon_3agnr7.yml b/src/isle/resources/lattices/ribbon_3agnr7.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/tetrahedron.yml b/src/isle/resources/lattices/tetrahedron.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/triangle.yml b/src/isle/resources/lattices/triangle.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/tube_3-3_1.yml b/src/isle/resources/lattices/tube_3-3_1.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/tube_3-3_5.yml b/src/isle/resources/lattices/tube_3-3_5.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/tube_4-2_2.yml b/src/isle/resources/lattices/tube_4-2_2.yml old mode 100644 new mode 100755 diff --git a/src/isle/resources/lattices/two_sites.yml b/src/isle/resources/lattices/two_sites.yml old mode 100644 new mode 100755 diff --git a/src/isle/scripts/__init__.py b/src/isle/scripts/__init__.py old mode 100644 new mode 100755 diff --git a/src/isle/scripts/base_command.py b/src/isle/scripts/base_command.py old mode 100644 new mode 100755 diff --git a/src/isle/scripts/continuation.py b/src/isle/scripts/continuation.py old mode 100644 new mode 100755 diff --git a/src/isle/scripts/show.py b/src/isle/scripts/show.py old mode 100644 new mode 100755 diff --git a/src/isle/util.py b/src/isle/util.py old mode 100644 new mode 100755 diff --git a/src/isle/yamlio.py b/src/isle/yamlio.py old mode 100644 new mode 100755 index 51feb274..08d13a7c --- a/src/isle/yamlio.py +++ b/src/isle/yamlio.py @@ -119,5 +119,6 @@ def loadLattice(fname): yaml.add_constructor("!HFAAlgorithm", lambda loader, node: \ {"DIRECT_SINGLE": HFAAlgorithm.DIRECT_SINGLE, - "DIRECT_SQUARE": HFAAlgorithm.DIRECT_SQUARE}[loader.construct_scalar(node)], + "DIRECT_SQUARE": HFAAlgorithm.DIRECT_SQUARE, + "ML_APPROX_FORCE":HFAAlgorithm.ML_APPROX_FORCE}[loader.construct_scalar(node)], Loader=yaml.SafeLoader) diff --git a/tests/.gitignore b/tests/.gitignore old mode 100644 new mode 100755 diff --git a/tests/__init__.py b/tests/__init__.py old mode 100644 new mode 100755 diff --git a/tests/core.py b/tests/core.py old mode 100644 new mode 100755 diff --git a/tests/cpp/CMakeLists.txt b/tests/cpp/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/tests/cpp/test_main.cpp b/tests/cpp/test_main.cpp old mode 100644 new mode 100755 diff --git a/tests/rand.py b/tests/rand.py old mode 100644 new mode 100755 diff --git a/tests/test_collection.py b/tests/test_collection.py old mode 100644 new mode 100755 diff --git a/tests/test_cpp.py b/tests/test_cpp.py old mode 100644 new mode 100755 diff --git a/tests/test_hubbardFermiAction.py b/tests/test_hubbardFermiAction.py old mode 100644 new mode 100755 diff --git a/tests/test_hubbardFermiMatrix.py b/tests/test_hubbardFermiMatrix.py old mode 100644 new mode 100755 diff --git a/tests/test_lattice.py b/tests/test_lattice.py old mode 100644 new mode 100755 diff --git a/tests/test_matrix.py b/tests/test_matrix.py old mode 100644 new mode 100755 diff --git a/tests/test_memoize.py b/tests/test_memoize.py old mode 100644 new mode 100755 diff --git a/tests/test_sumaction.py b/tests/test_sumaction.py old mode 100644 new mode 100755 diff --git a/tests/test_vector.py b/tests/test_vector.py old mode 100644 new mode 100755