Skip to content
Snippets Groups Projects
Commit cf354005 authored by Thomas Sebastian Bakaj's avatar Thomas Sebastian Bakaj
Browse files

testing updates

parent 44e3cb37
Branches
Tags v0.1.2
No related merge requests found
Pipeline #1038784 passed
%% Cell type:code id: tags:
``` python
import sys
from pathlib import Path
sys_path = Path('..')
sys.path.append(str(sys_path.resolve()))
```
%% Cell type:code id: tags:
``` python
import tofhed
from tofhed.commander import *
from tofhed.hinuma import *
from pathlib import Path
```
%% Cell type:code id: tags:
``` python
#path_xyz = Path('_temp/random207.extxyz')
path_xyz = Path('_temp/010.xyz')
```
%% Cell type:code id: tags:
``` python
frames = tofhed.utils.read(path_xyz)
```
%% Cell type:code id: tags:
``` python
tofhed.utils.view(frames)
```
%% Output
<Popen: returncode: None args: ['/Users/thomson/MODES/02_venv/.venv/bin/pyth...>
%% Cell type:code id: tags:
``` python
from tofhed.commander import *
path_xyz = '700K_CuH2_100.extxyz'
path_settings = 'settings.toml'
data = DataBase() # Create new database in memory
file = data.files.import_ase(path_xyz, init_frame_number=1, note='700K_CuH2_100 Example from Felix', import_positions=False)
system = file.newest_system()
# settings = data.settings.new_settings(settings_dict)
settings = data.settings.new_settings_from_toml(path_settings)
experiment = data.experiments.new_experiment(settings.setting_id,
system_id=system.system_id,
note='Initial experiment')
base_types_dict = experiment.set_base_types() # Using the settings from the experiment (in this case 'chemical_elements')
# Automatically sets the surfaces based on the base type algorithm in the settings
surfaces = experiment.set_new_surfaces()
surfaces
```
%% Output
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[1], line 9
5 path_settings = 'settings.toml'
7 data = DataBase() # Create new database in memory
----> 9 file = data.files.import_ase(path_xyz, init_frame_number=1, note='700K_CuH2_100 Example from Felix', import_positions=False)
11 system = file.newest_system()
13 # settings = data.settings.new_settings(settings_dict)
File ~/MODES/01_code/tofhed/tofhed/commander/db_files.py:49, in DBFiles.import_ase(self, path, init_frame_number, frame_range, is_sequence, sequence_id, sequence_order, note, write_split, import_positions)
45 def import_ase(self, path, init_frame_number, frame_range=(0,-1),
46 is_sequence=False, sequence_id=None, sequence_order=None,
47 note='', write_split=100000, import_positions=True):
---> 49 check_path(path)
51 frames = read(path)
52 file_id = self._import_from_frames(frames, path, init_frame_number,
53 frame_range=frame_range, is_sequence=is_sequence,
54 sequence_id=sequence_id, sequence_order=sequence_order,
55 note=note, write_split=write_split,
56 import_positions=import_positions)
File ~/MODES/01_code/tofhed/tofhed/functions.py:47, in check_path(path)
45 def check_path(path):
46 if not Path(path).exists():
---> 47 raise FileNotFoundError(f'File {path} does not exist')
49 return True
FileNotFoundError: File 700K_CuH2_100.extxyz does not exist
%% Cell type:code id: tags:
``` python
settings_dict = {
'approach_cutoff': 4.0, # Cutoff for event detection
'bond_cutoff': 4.0, # Cutoff for bond detection
'hinuma_cutoff': 4.2, # Cutoff for Hinuma algorithm
'mic': True, # Using minimum image convention
'fudge_factor': 1.7, # Fudge factor for bond/connection detection
'zero_vec_tolerance': 0.000001, # Tolerance for zero vector
'init_frame_number': 5, # Frame number to use for initialisation
'xyz_filter': None, #'z_filter', # Optional filter function for the hinuma algorithm
'solid_angle_limit': round(3.14 * 0.8, 3), # Solid angle limit to be considered as a surface atoms
'duration_cutoff': 5, # Cutoff for duration of events
# 'base_type_algorithm': 'hinuma', # Selecting the base type alghoritm
# 'max_molecule_size': 5, # Maximum number of atoms in a molecule
'base_type_algorithm': 'chemical_elements',
'chemical_elements': 'H C O N', # String of chemical elements separated by spaces
#'base_type_algorithm': 'chemical_tag',
#'chemical_tag': 2, # String of chemical elements separated by spaces
}
```
%% Cell type:code id: tags:
``` python
data = DataBase() # Create new database in memory
file = data.files.import_ase(path_xyz, init_frame_number=1, note='Test', import_positions=False)
system = file.newest_system()
settings = data.settings.new_settings(settings_dict)
experiment = data.experiments.new_experiment(settings.setting_id,
system_id=system.system_id,
note='Initial experiment')
base_types_dict = experiment.set_base_types() # Using the settings from the experiment (in this case 'hinuma')
# Automatically sets the surfaces based on the base type algorithm in the settings
surfaces = experiment.set_new_surfaces()
```
%% Output
sequence_ids: []
long_experiments {}
[0, 999]
sequence_ids: []
long_experiments {}
all_ids is None at convert_surface_classifier
%% Cell type:code id: tags:
``` python
tofhed.analysis.debug_view_surfaces(experiment)
```
%% Cell type:code id: tags:
``` python
settings.solid_angle_limit
```
%% Output
2.512
%% Cell type:code id: tags:
``` python
hinuma_surface = set(experiment.surface_groups[1].surface_atom_ids)
surface_tag = 1
tag_surface = set([atom_id for atom_id, tag in system.init_tags.items() if tag == surface_tag])
false_positives = hinuma_surface.difference(tag_surface)
false_negatives = tag_surface.difference(hinuma_surface)
false_positives, false_negatives
```
%% Output
(set(), set())
%% Cell type:code id: tags:
``` python
atom_id = system.atoms.number_to_id[34]
atom_id
```
%% Output
35
%% Cell type:code id: tags:
``` python
experiment.hinumas[1].solid_angles[atom_id]/(3.14)
```
%% Output
0.7120869817076638
%% Cell type:code id: tags:
``` python
experiment.hinumas[1].connections[atom_id]
```
%% Output
{3, 14, 25, 27, 31, 32, 33, 35, 37, 38, 41, 43, 44, 45, 47, 56, 57}
%% Cell type:code id: tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment