def compute_estimate_async(): """Submit calculations to a running server instance""" from openforcefield.typing.engines import smirnoff setup_timestamp_logging() # Load in the data set of interest. data_set = ThermoMLDataSet.from_file(get_data_filename('properties/single_dielectric.xml')) # Load in the force field to use. force_field = smirnoff.ForceField(get_data_filename('forcefield/smirnoff99Frosst.offxml')) # new_property_0 = copy.deepcopy(data_set.properties['COCCO{1.0}'][0]) # new_property_0.thermodynamic_state.temperature -= 2.0 * unit.kelvin # new_property_0.id = str(uuid4()) # # data_set.properties['COCCO{1.0}'].append(new_property_0) # # new_property_1 = copy.deepcopy(data_set.properties['COCCO{1.0}'][0]) # new_property_1.thermodynamic_state.temperature += 2.0 * unit.kelvin # new_property_1.id = str(uuid4()) # # data_set.properties['COCCO{1.0}'].append(new_property_1) # Modify the submission options submission_options = PropertyEstimatorOptions() workflow_options = PropertyWorkflowOptions(PropertyWorkflowOptions.ConvergenceMode.RelativeUncertainty, relative_uncertainty_fraction=100000) submission_options.workflow_options = { 'Density': workflow_options, 'Dielectric': workflow_options, 'EnthalpyOfMixing': workflow_options } # submission_options.allowed_calculation_layers = ['SimulationLayer'] submission_options.allowed_calculation_layers = ['ReweightingLayer'] # Create the client object. property_estimator = client.PropertyEstimatorClient() # Submit the request to a running server. request = property_estimator.request_estimate(data_set, force_field, submission_options) logging.info('Request info: {}'.format(str(request))) # Wait for the results. result = request.results(synchronous=True) logging.info('The server has returned a response: {}'.format(result.json()))
def compute_estimate_sync(): """Submit calculations to a running server instance""" from openforcefield.typing.engines import smirnoff setup_timestamp_logging() # Load in the data set of interest. data_set = ThermoMLDataSet.from_file(get_data_filename('properties/single_density.xml')) # Load in the force field to use. force_field = smirnoff.ForceField(get_data_filename('forcefield/smirnoff99Frosst.offxml')) # Create the client object. property_estimator = client.PropertyEstimatorClient() # Submit the request to a running server, and wait for the results. result = property_estimator.request_estimate(data_set, force_field) logging.info('The server has returned a response: {}'.format(result))
def main(): setup_timestamp_logging() # Load in the force field force_field_path = 'smirnoff99Frosst-1.1.0.offxml' force_field_source = SmirnoffForceFieldSource.from_path(force_field_path) # Load in the data set containing a single dielectric # property. with open('pure_data_set.json') as file: data_set = PhysicalPropertyDataSet.parse_json(file.read()) data_set.filter_by_property_types('DielectricConstant') # Set up the server object which run the calculations. setup_server(backend_type=BackendType.LocalGPU, max_number_of_workers=1, port=8001) # Request the estimates. property_estimator = client.PropertyEstimatorClient( client.ConnectionOptions(server_port=8001)) options = PropertyEstimatorOptions() options.allowed_calculation_layers = ['SimulationLayer'] options.workflow_options = { 'DielectricConstant': { 'SimulationLayer': WorkflowOptions(WorkflowOptions.ConvergenceMode.NoChecks), 'ReweightingLayer': WorkflowOptions(WorkflowOptions.ConvergenceMode.NoChecks) } } parameter_gradient_keys = [ ParameterGradientKey(tag='vdW', smirks='[#6X4:1]', attribute='epsilon'), ParameterGradientKey(tag='vdW', smirks='[#6X4:1]', attribute='rmin_half') ] request = property_estimator.request_estimate( property_set=data_set, force_field_source=force_field_source, options=options, parameter_gradient_keys=parameter_gradient_keys) # Wait for the results. results = request.results(True, 5) # Save the result to file. with open('dielectric_simulation.json', 'wb') as file: json_results = json.dumps(results, sort_keys=True, indent=2, separators=(',', ': '), cls=TypedJSONEncoder) file.write(json_results.encode('utf-8')) # Attempt to reweight the cached data. options.allowed_calculation_layers = ['ReweightingLayer'] request = property_estimator.request_estimate( property_set=data_set, force_field_source=force_field_source, options=options, parameter_gradient_keys=parameter_gradient_keys) # Wait for the results. results = request.results(True, 5) # Save the result to file. with open('dielectric_reweight.json', 'wb') as file: json_results = json.dumps(results, sort_keys=True, indent=2, separators=(',', ': '), cls=TypedJSONEncoder) file.write(json_results.encode('utf-8'))
def main(): setup_timestamp_logging() # Load in the force field force_field_path = 'smirnoff99Frosst-1.1.0.offxml' force_field_source = SmirnoffForceFieldSource.from_path(force_field_path) # Create a data set containing three solvation free energies. data_set = _create_data_set() # Set up the compute backend which will run the calculations. working_directory = 'working_directory' storage_directory = 'storage_directory' queue_resources = QueueWorkerResources( number_of_threads=1, number_of_gpus=1, preferred_gpu_toolkit=QueueWorkerResources.GPUToolkit.CUDA, per_thread_memory_limit=5 * unit.gigabyte, wallclock_time_limit="05:59") worker_script_commands = [ 'conda activate propertyestimator', 'module load cuda/10.1' ] calculation_backend = DaskLSFBackend( minimum_number_of_workers=1, maximum_number_of_workers=3, resources_per_worker=queue_resources, queue_name='gpuqueue', setup_script_commands=worker_script_commands, adaptive_interval='1000ms', adaptive_class=CustomAdaptive) # Set up a backend to cache simulation data in. storage_backend = LocalFileStorage(storage_directory) # Spin up the server object. PropertyEstimatorServer(calculation_backend=calculation_backend, storage_backend=storage_backend, port=8005, working_directory=working_directory) # Request the estimates. property_estimator = client.PropertyEstimatorClient( client.ConnectionOptions(server_port=8005)) options = PropertyEstimatorOptions() options.allowed_calculation_layers = ['SimulationLayer'] workflow_options = WorkflowOptions( WorkflowOptions.ConvergenceMode.NoChecks) options.workflow_options = { 'SolvationFreeEnergy': { 'SimulationLayer': workflow_options } } options.workflow_schemas = { 'SolvationFreeEnergy': { 'SimulationLayer': _get_fixed_lambda_schema(workflow_options) } } request = property_estimator.request_estimate( property_set=data_set, force_field_source=force_field_source, options=options) # Wait for the results. results = request.results(True, 5) # Save the result to file. with open('solvation_free_energy_simulation.json', 'wb') as file: json_results = json.dumps(results, sort_keys=True, indent=2, separators=(',', ': '), cls=TypedJSONEncoder) file.write(json_results.encode('utf-8'))