Esempio n. 1
0
File: hdWE.py Progetto: enzyx/hdWE
if(MD_PACKAGE == "langevin"):
    from lib.langevin_module import MD_module
    md_module = MD_module(CONFIGFILE, DEBUG)
if(MD_PACKAGE == "gromacs"):
    print("Sorry, support for gromacs is not implemented yet.")
    sys.exit(-1)

# Initiate the reweighter
if REWEIGHTING_RANGE > 0:
    reweighter = reweighting.Reweighting( reweighting_range = REWEIGHTING_RANGE )

# Initiate iterations
if APPEND == True:
    # load the last two iterations if existing for proper function of
    # cleanup module
    if logger.getLastIterationId() > 1: 
        iterations = logger.loadLastIterations(N=2)
    else:
        logger.loadLastIterations(N=1)
    # Load the previous iterations to restore the rate matrices for the reweighter module
    if REWEIGHTING_RANGE > 0 and iterations[-1].getId() <= REWEIGHTING_MAX_ITERATION:
        print('Loading previous iterations to restore rate matrix for reweighting...')
        for iteration_counter_tmp in range(1,iterations[-1].getId() + 1):
            iteration_tmp = logger.loadIteration(iteration_counter_tmp)
            reweighter.storeRateMatrix(iteration_tmp)
        iteration_tmp = []
            
    if APPEND_NEW_CONFIG:
        iterations[-1].boundaries    = INITIAL_BOUNDARIES
        iterations[-1].sample_region = INITIAL_SAMPLE_REGION
        iterations[-1].target_number_of_segments  = INITIAL_TARGET_NUMBER_OF_SEGMENTS
Esempio n. 2
0
    help="Segment MD propagation time tau used in hdWE simulations.")
parser.add_argument(
    '-p',
    '--plot',
    dest="plot",
    required=False,
    default=False,
    action="store_true",
    help="Plot probabilities from start state per bin and iteration")
# Initialize
args = parser.parse_args()
first_iteration = 0
last_iteration = args.last_iteration
logger = Logger(args.logdir)
if last_iteration < 0:
    last_iteration = logger.getLastIterationId()
# get the bin Ids of start state and target state
start_state = args.start_state
target_state = args.target_state
last_iteration_tmp = logger.loadIteration(last_iteration)
found_target_state = False
for this_bin in last_iteration_tmp.bins:
    if all(this_bin.getCoordinateIds() == start_state):
        start_state_id = this_bin.getId()
    if all(this_bin.getCoordinateIds() == target_state):
        target_state_id = this_bin.getId()
        found_target_state = True
if found_target_state == False:
    target_state_id = 1e99
    print('Warning: Target state not found in given iterations')
Esempio n. 3
0
                    help="Output filename")
parser.add_argument("--probability",
                    dest="probability",
                    action="store_true",
                    default=False)

# Initialize
print(
    '\033[1mCalculating Bin Free Energies\033[0m (Free Energy is given in kcal/mol at 298K).'
)
args = parser.parse_args()
last_iteration = args.last_iteration
first_iteration = args.first_iteration
logger = Logger(args.logdir)
if last_iteration < 0:
    last_iteration = logger.getLastIterationId()

n_iterations = last_iteration - first_iteration + 1

#initialize bin probability evolution array with size of last frame number_of_bins
iteration = logger.loadIterations(logger.getLastIterationId(),
                                  logger.getLastIterationId())[0]
n_bins = iteration.getNumberOfBins()
bin_probabilities = numpy.zeros(
    [n_iterations, iteration.getNumberOfBins(), 2], float)
for i in range(0, len(bin_probabilities[:, 0, 0])):
    for j in range(0, len(bin_probabilities[0, :, 0])):
        for k in range(0, 2):
            bin_probabilities[i, j, k] = 0

for i in range(first_iteration, last_iteration):