keyword
stringclasses
7 values
repo_name
stringlengths
8
98
file_path
stringlengths
4
244
file_extension
stringclasses
29 values
file_size
int64
0
84.1M
line_count
int64
0
1.6M
content
stringlengths
1
84.1M
language
stringclasses
14 values
3D
antecede/EZSpecificity
Datasets/Structure/structure.py
.py
14,060
369
import os import pickle import lmdb import torch from torch.utils.data import Dataset from tqdm.auto import tqdm from easydict import EasyDict import yaml import sys import ray root_dir = "/projects/bbto/suyufeng/enzyme_specificity" sys.path.append(f"{root_dir}/src") from Datasets.utils import get_paths, check_paths_exist from Datasets.Structure.protein_ligand import PDBProtein, parse_sdf_file_mol, get_zero_protein_feature from Datasets.Structure.utils import StructureComplexData, torchify_dict # @ray.remote def _single_str_process(item): (index, config, reaction, protein, label, structure_index) = item print("Start processing {}".format(structure_index)) if not os.path.exists(os.path.join(config.data.pdb_dir, f'{structure_index}.pdb')) or not os.path.exists(os.path.join(config.data.ligand_dir, f'{structure_index}.sdf')): return (1, None) try: pocket_fn = os.path.join(config.data.pdb_dir, f'{structure_index}.pdb') ligand_fn = os.path.join(config.data.ligand_dir, f'{structure_index}.sdf') pocket_dict = PDBProtein(pocket_fn).to_dict_atom() ligand_dict = parse_sdf_file_mol(ligand_fn, heavy_only=True) data = StructureComplexData.from_protein_ligand_dicts( protein_dict=torchify_dict(pocket_dict), ligand_dict=torchify_dict(ligand_dict), ) assert data.protein_pos.size(0) > 0 data.protein_filename = protein data.ligand_filename = reaction data.y = torch.tensor(float(label)) return (0, (index, structure_index, data)) except: return (2, None) def _str_process(config, df): processed_path = config.data.structure_processed_path db = lmdb.open( processed_path, map_size=10*(1024*1024*1024), # 10GB create=True, subdir=False, readonly=False, # Writable ) # index = parse_pdbbind_index_file(self.index_path) parameters = [] num_skipped_exist = 0 num_skipped_parse = 0 for index, (reaction, protein, label, structure_index) in tqdm(enumerate(zip(df['reaction'].values, df['enzyme'].values, df["label"].values, df['structure_index'].values))): structure_index = int(structure_index) if not os.path.exists(os.path.join(config.data.pdb_dir, f'{structure_index}.pdb')) or not os.path.exists(os.path.join(config.data.ligand_dir, f'{structure_index}.sdf')): continue parameters.append((index, config, reaction, protein, label, structure_index)) from multiprocessing.pool import Pool # with db.begin(write=True, buffers=True) as txn: # with Pool(60) as pool: # for index, (cnt, item) in enumerate(pool.imap_unordered(_single_str_process, parameters)): # print(f"Processing str {index}") # if cnt == 0: # (index, structure_index, data) = item # txn.put( # key=str(structure_index).encode(), # value=pickle.dumps(data) # ) # else: # if cnt == 1: # num_skipped_exist += 1 # print(f"non-existed skipped #{num_skipped_exist}: {structure_index}") # else: # num_skipped_parse += 1 # print(f"parse failed skipped #{num_skipped_parse}: {structure_index}") for index, parameter in enumerate(parameters): print(f"Processing str {index}") (cnt, item) = _single_str_process(parameter) if cnt == 0: (index, structure_index, data) = item with db.begin(write=True, buffers=True) as txn: txn.put( key=str(structure_index).encode(), value=pickle.dumps(data) ) else: if cnt == 1: num_skipped_exist += 1 print(f"non-existed skipped #{num_skipped_exist}: {structure_index}") else: num_skipped_parse += 1 print(f"parse failed skipped #{num_skipped_parse}: {structure_index}") print('num_skipped: ', num_skipped_exist, num_skipped_parse) # @ray.remote(num_cpus=1) def _single_seq_process(item): from rdkit import Chem from rdkit.Chem import AllChem try: index, smile = item mol = Chem.MolFromSmiles(smile) mol = Chem.AddHs(mol) AllChem.EmbedMolecule(mol,AllChem.ETKDG()) mol = Chem.RemoveHs(mol) pocket_dict = get_zero_protein_feature() ligand_dict = parse_sdf_file_mol(None, mol, heavy_only=True) data = StructureComplexData.from_protein_ligand_dicts( protein_dict=torchify_dict(pocket_dict), ligand_dict=torchify_dict(ligand_dict), ) data.protein_filename = None data.ligand_filename = index return index, data except: return index, None def _seq_process(config, df): processed_path = config.data.sequence_processed_path db = lmdb.open( processed_path, map_size=10*(1024*1024*1024), # 10GB create=True, subdir=False, readonly=False, # Writable ) parameters = [] for index, ligand in tqdm(enumerate(df['substrates'].values)): parameters.append((index, ligand)) from multiprocessing.pool import Pool # with db.begin(write=True, buffers=True) as txn: # with Pool(60) as pool: # for index, (id, data) in enumerate(pool.imap_unordered(_single_seq_process, parameters)): # print(f"Processing seq {index}") # if data is not None: # txn.put( # key=str(id).encode(), # value=pickle.dumps(data) # ) with db.begin(write=True, buffers=True) as txn: for index, parameter in enumerate(parameters): print(f"Processing seq {index}") (id, data) = _single_seq_process(parameter) if data is not None: txn.put( key=str(id).encode(), value=pickle.dumps(data) ) class StructureDataset(Dataset): def __init__(self, config, df, transform=None, is_train=False): super().__init__() self.dbs = None self.df = df self.config = config self.complex_dbs = None self.ligand_dbs = None self.valid_idx = None self.high_quality_id_dicts = None self.db_key_dict = None self.idx_valid_dict = {} if is_train and self.config.data.full_data: self.fake_sequence_ratio = self.config.data.fake_sequence_ratio else: self.fake_sequence_ratio = 0.0 self.transform = transform if check_paths_exist(config.data.structure_processed_path): assert "processed_path is not initialized" self._get_valid_idx() def _get_high_quality_id_dicts(self): self.high_quality_id_dicts = [] for path in get_paths(self.config.data.high_quality_id_path): try: fin = open(path, "r") self.high_quality_id_dicts.append({int(line.strip()):True for line in fin}) fin.close() except: self.high_quality_id_dicts.append(None) def check_high_quality(self, dataset_id, index): if self.high_quality_id_dicts is None: self._get_high_quality_id_dicts() return ((self.high_quality_id_dicts[dataset_id] is None) or (index in self.high_quality_id_dicts[dataset_id])) def _check_valid_idx(self, idx): structure_index = int(self.df['structure_index'].values[idx]) dataset_id = self.df['dataset_id'].values[idx] reaction = self.df['reaction'].values[idx] # if self.check_high_quality(dataset_id, structure_index): # return flag_complex = str(structure_index).encode() in self.db_key_dict[f"complex_{dataset_id}"] if not self.config.data.full_data: self.idx_valid_dict[idx] = (flag_complex, False) return flag_complex & self.check_high_quality(dataset_id, structure_index) flag_ligand = str(reaction).encode() in self.db_key_dict[f"ligand_{dataset_id}"] self.idx_valid_dict[idx] = (flag_complex, flag_ligand) return flag_complex | flag_ligand def _get_valid_idx(self): import numpy as np if self.complex_dbs is None or self.ligand_dbs is None: self._connect_db() cnt = 0 self.valid_idx = [] # unavailable_structure_indexs = [] for idx in range(self.df.index.shape[0]): if self._check_valid_idx(idx): self.valid_idx.append(idx) else: cnt += 1 # unavailable_structure_indexs.append(int(self.df['structure_index'].values[idx])) # unavailable_structure_indexs = list(set(unavailable_structure_indexs)) # np.savetxt("unavailable_structure_indexs.txt", unavailable_structure_indexs) print(f"#Invalid structures: {cnt}") def _add_key_dict(self, name, db): if db is None: return with db.begin() as txn: keys = list(txn.cursor().iternext(values=False)) self.db_key_dict[name] = {k: i for i, k in enumerate(keys)} return def _connect_db(self): assert self.complex_dbs is None, 'A connection has already been opened.' self.db_key_dict = {} self.complex_dbs = [lmdb.open( path, map_size=10*(1024*1024*1024), # 10GB create=False, subdir=False, readonly=True, lock=False, readahead=False, meminit=False, ) for path in get_paths(self.config.data.structure_processed_path)] self.ligand_dbs = [] for path in get_paths(self.config.data.sequence_processed_path): if os.path.exists(path): self.ligand_dbs.append(lmdb.open( path, map_size=10*(1024*1024*1024), # 10GB create=False, subdir=False, readonly=True, lock=False, readahead=False, meminit=False, )) else: self.ligand_dbs.append(None) for i, db in enumerate(self.complex_dbs): self._add_key_dict(f"complex_{i}", db) for i, db in enumerate(self.ligand_dbs): self._add_key_dict(f"ligand_{i}", db) def __len__(self): if self.valid_idx is None: self._get_valid_idx() return len(self.valid_idx) def getitem_with_real_idx(self, idx): import random if self.complex_dbs is None or self.ligand_dbs is None: self._connect_db() structure_index = int(self.df['structure_index'].values[idx]) dataset_id = self.df['dataset_id'].values[idx] reaction = self.df['reaction'].values[idx] flag_no_structure = False try: if self.config.data.no_structure == True: flag_no_structure = True except Exception as e: pass complex_random_value = random.random() if flag_no_structure else 1.0 if ((self.check_high_quality(dataset_id, structure_index) and complex_random_value > self.fake_sequence_ratio) or (not self.idx_valid_dict[idx][1])) and self.idx_valid_dict[idx][0]: with self.complex_dbs[dataset_id].begin(write=False) as txn: data = txn.get(str(structure_index).encode()) if data is None: print(f"None: {structure_index}") print(self.idx_valid_dict[idx]) data = pickle.loads(data) data.str_tag = 'complex' data.sample_weight = torch.tensor(float(self.config.data.sample_weight[0])) data.mask_use_complex = torch.tensor([1.0] * (data.ligand_pos.size(0) + data.protein_pos.size(0))) data.mask_use_ligand = torch.tensor([0.0] * (data.ligand_pos.size(0) + data.protein_pos.size(0))) else: with self.ligand_dbs[dataset_id].begin(write=False) as txn: data = txn.get(str(reaction).encode()) data = pickle.loads(data) data.str_tag = 'ligand' data.sample_weight = torch.tensor(float(self.config.data.sample_weight[1])) data.mask_use_complex = torch.tensor([0.0] * (data.ligand_pos.size(0) + data.protein_pos.size(0))) data.mask_use_ligand = torch.tensor([1.0] * (data.ligand_pos.size(0) + data.protein_pos.size(0))) data.id = idx if self.transform is not None: data = self.transform(data) return data def __getitem__(self, idx): if self.valid_idx is None: self._get_valid_idx() idx = self.valid_idx[idx] return self.getitem_with_real_idx(idx) # def __cat_dim__(self, key, value, *args, **kwargs): # super().__cat_dim__(key, value, *args, **kwargs) # def __inc__(self, key, value, *args, **kwargs): # super().__inc__(key, value, *args, **kwargs) if __name__ == '__main__': import pandas as pd def load_config(path): with open(path, 'r') as f: return EasyDict(yaml.safe_load(f)) # for family_name in ["Duf", "Esterase", "Gt_acceptor", "Nitrilase", "Phosphatase", "Thiolase"]: for family_name in ['2023_brenda']: config = load_config(f"{root_dir}/src/Configs/dataset/{family_name}.yml") df = pd.read_csv(config.data_df_path) _str_process(config, df) df = pd.read_csv(config.ligand_df_path) _seq_process(config, df) # Path: src/Datasets/Structure/structure.py
Python
3D
antecede/EZSpecificity
Datasets/Structure/preprocess.ipynb
.ipynb
482,058
9,671
{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import glob\n", "import sys\n", "from tqdm import tqdm\n", "import os\n", "\n", "root_dir = \"/projects/bbhh/suyufeng/enzyme_specificity\"\n", "\n", "sys.path.append(f\"{root_dir}/src\")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Extract pocket" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 534213/534213 [00:00<00:00, 3772109.20it/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "9313\n", "-73.414 -39.919 -5.745 168.62899768130035\n", "-73.324 -40.714 -6.344 168.91626334074527\n", "-74.345 -39.566 -5.841 169.34219913831282\n", "-73.299 -40.23 -4.802 168.58465881568227\n", "-72.411 -38.877 -6.088 167.31871831029542\n", "-71.545 -39.32 -5.855 166.69159956338532\n", "-72.474 -37.615 -5.218 166.808058924022\n", "-71.448 -37.279 -4.65 165.69638584471295\n", "-72.401 -38.556 -7.585 167.30041519673526\n", "-73.334 -38.596 -7.941 168.19813717755616\n", "-72.028 -37.639 -7.728 166.6059995258274\n", "-71.529 -39.583 -8.315 166.98547264358058\n", "-70.604 -39.413 -7.976 166.04579167807896\n", "-71.85 -40.469 -7.98 167.61063903583207\n", "-71.615 -39.475 -10.114 167.18944319842686\n", "-70.877 -37.846 -10.425 165.89233663132242\n", "-70.856 -37.643 -11.404 165.89522164908786\n", "-69.938 -37.807 -10.083 164.98713899877166\n", "-71.399 -37.124 -9.972 166.03527840793353\n", "-73.619 -36.932 -5.032 167.5756057067973\n", "-74.457 -37.276 -5.455 168.5088671049687\n", "-73.687 -35.685 -4.221 167.1005449841502\n", "-73.015 -35.097 -4.671 166.28570049766753\n", "-73.235 -35.827 -2.752 166.65061853170545\n", "-72.655 -34.896 -2.206 165.72840077669247\n", "-75.107 -35.083 -4.277 168.18401497764287\n", "-75.77 -35.813 -4.113 169.0625551060908\n", "-75.189 -34.391 -3.56 167.95450385446648\n", "-75.429 -34.425 -5.632 168.32669857452797\n", "-74.757 -33.707 -5.811 167.45042715382962\n", "-75.374 -35.119 -6.35 168.59028570472262\n", "-76.838 -33.803 -5.647 169.40135247098823\n", "-77.516 -34.524 -5.504 170.28558941084827\n", "-76.907 -33.129 -4.911 169.16696078726483\n", "-77.113 -33.11 -6.994 169.50522380151003\n", "-76.473 -32.351 -7.113 168.6454472376886\n", "-76.991 -33.769 -7.737 169.69400792603136\n", "-78.496 -32.563 -7.088 170.600245222567\n", "-78.647 -32.119 -7.971 170.65521375568926\n", "-78.663 -31.886 -6.371 170.4585587554934\n", "-79.176 -33.289 -6.989 171.48557341945704\n", "-73.467 -36.984 -2.126 167.28036654670504\n", "-73.947 -37.705 -2.626 168.0310405520361\n", "-73.051 -37.255 -0.734 166.93828983489675\n", "-73.343 -36.454 -0.212 166.87074214493086\n", "-71.526 -37.373 -0.609 165.580960291333\n", "-70.947 -36.821 0.32 164.7930743478014\n", "-73.756 -38.516 -0.189 168.06210549079765\n", "-73.456 -39.276 -0.766 168.1167400498832\n", "-73.375 -38.816 1.263 167.78123018085185\n", "-73.843 -39.635 1.594 168.52930365073013\n", "-73.624 -38.056 1.863 167.6879764980185\n", "-72.39 -38.967 1.351 166.93837841251482\n", "-75.284 -38.359 -0.247 169.40316257673584\n", "-75.742 -39.175 0.106 170.13302250298148\n", "-75.594 -38.215 -1.187 169.6713260483338\n", "-75.585 -37.577 0.299 169.35153595406211\n", "-70.866 -38.003 -1.589 165.27461623310458\n", "-71.394 -38.39 -2.345 165.95197710783683\n", "-69.407 -38.154 -1.609 164.00451490431595\n", "-69.151 -38.524 -0.716 163.88000208689283\n", "-68.704 -36.795 -1.78 162.82196708675397\n", "-67.713 -36.525 -1.113 161.77440567036552\n", "-69.017 -39.135 -2.734 164.11105167233558\n", "-69.76 -39.793 -2.857 165.06523557369673\n", "-68.886 -38.617 -3.58 163.82902052444797\n", "-67.719 -39.907 -2.422 163.2365528091058\n", "-67.097 -39.293 -1.935 162.38949375498402\n", "-68.024 -41.134 -1.557 163.98538796490374\n", "-67.188 -41.642 -1.349 163.43748354034332\n", "-68.653 -41.755 -2.025 164.84180038448986\n", "-68.445 -40.866 -0.69 164.21198952573468\n", "-67.061 -40.385 -3.715 162.91878954252024\n", "-66.218 -40.887 -3.524 162.35931277878706\n", "-66.831 -39.613 -4.307 162.42388902498303\n", "-67.671 -40.992 -4.225 163.76006668599032\n", "-69.267 -35.907 -2.611 163.0283837066417\n", "-70.093 -36.175 -3.106 163.92009214553292\n", "-68.728 -34.561 -2.828 162.01770043424267\n", "-67.764 -34.698 -3.054 161.19909627848412\n", "-68.799 -33.696 -1.557 161.67928963537662\n", "-67.841 -33.004 -1.23 160.51404899260376\n", "-69.477 -33.887 -3.997 162.51793299817717\n", "-69.904 -34.596 -4.558 163.22158772968726\n", "-70.183 -33.285 -3.624 162.91519082332377\n", "-68.531 -33.053 -4.884 161.38728711085022\n", "-67.825 -32.651 -4.301 160.54275814872497\n", "-67.889 -33.945 -5.95 161.21893871688897\n", "-67.272 -33.418 -6.534 160.49470423973494\n", "-68.585 -34.362 -6.535 162.0661681690537\n", "-67.36 -34.682 -5.529 160.98901205361813\n", "-69.299 -31.938 -5.591 161.7264156190942\n", "-68.69 -31.394 -6.168 161.00484101107023\n", "-69.727 -31.322 -4.929 161.84493980659389\n", "-70.02 -32.313 -6.173 162.57772952960067\n", "-69.907 -33.774 -0.8 162.6947726019493\n", "-70.677 -34.322 -1.128 163.63033905727875\n", "-70.029 -33.081 0.496 162.48975277536732\n", "-69.821 -32.127 0.279 161.94585547645238\n", "-69.019 -33.594 1.519 161.7177279985098\n", "-68.47 -32.784 2.257 160.87935073837164\n", "-71.449 -33.195 1.07 163.82613894308807\n", "-71.786 -34.123 0.911 164.4948767925615\n", "-71.413 -33.017 2.053 163.69576899235972\n", "-72.424 -32.202 0.427 164.3821429535459\n", "-72.019 -31.288 0.431 163.66965485697096\n", "-72.61 -32.481 -0.515 164.69585052149918\n", "-73.736 -32.183 1.223 165.56642428644764\n", "-74.17 -33.083 1.177 166.3029501211569\n", "-73.547 -31.952 2.177 165.27796835936724\n", "-74.69 -31.189 0.694 166.1114767197017\n", "-74.426 -30.706 -0.141 165.72365989803626\n", "-75.862 -30.878 1.223 167.07619457600774\n", "-76.311 -31.454 2.304 167.66996947575316\n", "-75.764 -32.156 2.761 167.4017962328959\n", "-77.202 -31.194 2.676 168.40053476459033\n", "-76.614 -29.966 0.673 167.4763660998172\n", "-76.306 -29.496 -0.154 167.05529071837262\n", "-77.499 -29.736 1.079 168.21172677610798\n", "-68.763 -34.903 1.545 161.9890332769475\n", "-69.267 -35.504 0.924 162.70864713345753\n", "-67.774 -35.494 2.446 161.28829071262427\n", "-67.998 -35.169 3.365 161.34437327344264\n", "-66.354 -35.01 2.11 159.80241487849923\n", "-65.619 -34.628 3.013 158.95371376913468\n", "-67.888 -37.028 2.385 162.0093236267592\n", "-68.855 -37.275 2.326 162.99479573593754\n", "-67.411 -37.352 1.568 161.72838992582595\n", "-67.277 -37.717 3.62 161.7049522711039\n", "-66.423 -37.248 3.846 160.72995297703537\n", "-68.228 -37.644 4.819 162.5256908368643\n", "-67.83 -38.092 5.62 162.33908126203005\n", "-69.097 -38.095 4.615 163.50529433018366\n", "-68.424 -36.694 5.063 162.31806943775547\n", "-67.008 -39.189 3.314 162.07525030676334\n", "-66.611 -39.653 4.106 161.89573317725205\n", "-66.371 -39.285 2.549 161.5544070769968\n", "-67.853 -39.665 3.071 163.04670909282407\n", "-65.999 -34.936 0.822 159.48859939193144\n", "-66.648 -35.254 0.131 160.236341926543\n", "-64.699 -34.409 0.373 158.10412494935102\n", "-64.006 -34.915 0.886 157.65297123111887\n", "-64.555 -32.922 0.73 157.37176779842056\n", "-63.505 -32.529 1.224 156.2348140876418\n", "-64.492 -34.676 -1.136 158.08738113144895\n", "-65.28 -34.3 -1.623 158.68394741119846\n", "-64.392 -36.197 -1.405 158.62397567517968\n", "-63.494 -36.516 -1.102 157.92203936436482\n", "-65.105 -36.661 -0.88 159.4379803842234\n", "-63.22 -33.978 -1.657 156.67056267850703\n", "-63.089 -34.153 -2.633 156.6748880005982\n", "-62.408 -34.306 -1.175 156.0347922035339\n", "-63.276 -32.988 -1.527 156.32267118367702\n", "-64.562 -36.573 -2.883 159.01359439683137\n", "-64.491 -37.562 -3.012 159.3644424832591\n", "-63.86 -36.138 -3.446 158.23102715017683\n", "-65.455 -36.282 -3.226 159.7292532380966\n", "-65.6 -32.101 0.563 158.02278016475978\n", "-66.429 -32.455 0.13 158.9404482219677\n", "-65.567 -30.698 0.996 157.44313419136446\n", "-64.749 -30.324 0.558 156.56126607817146\n", "-65.421 -30.551 2.519 157.20612688441884\n", "-64.68 -29.683 2.969 156.1833007814856\n", "-66.831 -29.968 0.522 158.36019310420156\n", "-67.597 -30.535 0.825 159.2698915489051\n", "-66.841 -29.101 1.02 158.03290190653337\n", "-66.809 -29.735 -1.278 158.33271657178122\n", "-66.804 -30.913 -1.874 158.79608366077548\n", "-66.088 -31.398 3.311 158.12503721422485\n", "-66.724 -32.047 2.892 158.96899905956505\n", "-65.925 -31.414 4.768 157.95706334317563\n", "-66.074 -30.466 5.051 157.73478970094072\n", "-64.51 -31.826 5.181 156.8030247986307\n", "-63.932 -31.193 6.058 156.02099267085825\n", "-66.97 -32.336 5.419 159.2684393531876\n", "-67.36 -32.93 4.715 159.86297785916537\n", "-66.519 -32.895 6.115 159.0634376781792\n", "-68.104 -31.583 6.081 160.0290084047264\n", "-67.931 -31.074 7.382 159.67931193489028\n", "-67.064 -31.212 7.86 158.93040187767724\n", "-69.321 -31.376 5.406 161.0837530354939\n", "-69.444 -31.729 4.478 161.33881574500293\n", "-68.974 -30.372 8.01 160.3925208387224\n", "-68.849 -30.013 8.935 160.15566975290008\n", "-70.365 -30.673 6.035 161.79131267778257\n", "-71.23 -30.528 5.555 162.5460777687361\n", "-70.192 -30.174 7.338 161.4491558633863\n", "-70.936 -29.678 7.786 161.9661790652604\n", "-63.932 -32.842 4.531 156.6722244241142\n", "-64.465 -33.331 3.841 157.3647758108529\n", "-62.551 -33.273 4.783 155.5704447702069\n", "-62.47 -33.395 5.772 155.53650673073508\n", "-61.564 -32.179 4.362 154.23667323305438\n", "-60.644 -31.889 5.114 153.26799037633396\n", "-62.268 -34.631 4.099 155.8657016889861\n", "-62.535 -34.555 3.138 156.09715742767386\n", "-63.087 -35.754 4.777 157.06188784361404\n", "-62.679 -35.951 5.669 156.76310902122347\n", "-64.025 -35.432 4.903 157.78583230759344\n", "-60.77 -34.979 4.16 154.63939639690787\n", "-60.588 -35.857 3.718 154.84417440123474\n", "-60.455 -35.041 5.107 154.36600516305393\n", "-60.221 -34.282 3.698 153.86103615925637\n", "-63.132 -37.06 3.971 157.65322453410207\n", "-63.671 -37.756 4.446 158.426385150959\n", "-62.212 -37.426 3.83 156.9731756479431\n", "-63.545 -36.912 3.072 157.9846981704241\n", "-61.773 -31.517 3.221 154.19014347875807\n", "-62.536 -31.797 2.638 155.01541645268705\n", "-60.934 -30.401 2.789 152.9945168788738\n", "-59.994 -30.742 2.784 152.260449956645\n", "-60.996 -29.228 3.781 152.5824104082774\n", "-59.948 -28.744 4.189 151.4224302473052\n", "-61.34 -29.984 1.372 153.25074149575914\n", "-61.293 -30.76 0.743 153.52806095629555\n", "-60.736 -29.268 1.022 152.43235235670934\n", "-62.276 -29.632 1.356 153.9827875867949\n", "-62.192 -28.838 4.244 153.53589989640858\n", "-63.01 -29.266 3.859 154.46077377120702\n", "-62.367 -27.815 5.287 153.3069262297043\n", "-61.912 -26.997 4.935 152.5875492266653\n", "-61.691 -28.211 6.605 152.8198418727097\n", "-61.053 -27.373 7.237 151.9186705378901\n", "-63.871 -27.569 5.517 154.61531460369636\n", "-64.344 -28.449 5.484 155.37704661242597\n", "-63.99 -27.16 6.422 154.57484795722752\n", "-64.51 -26.635 4.475 154.88614629785323\n", "-64.144 -26.887 3.579 154.64911797679287\n", "-66.032 -26.787 4.492 156.36254893675783\n", "-66.46 -26.184 3.818 156.56138478245518\n", "-66.405 -26.557 5.391 156.62105082650928\n", "-66.301 -27.726 4.279 156.95135713016307\n", "-64.179 -25.168 4.769 154.05557441715635\n", "-64.596 -24.564 4.09 154.24677108127742\n", "-63.191 -25.013 4.753 153.0759320272132\n", "-64.518 -24.898 5.67 154.27172241535388\n", "-61.788 -29.486 6.996 153.38840322853616\n", "-62.356 -30.108 6.457 154.14937194163326\n", "-61.102 -30.012 8.174 152.96214273146148\n", "-61.352 -29.402 8.926 152.97071497839056\n", "-59.579 -29.953 8.007 151.53193772271246\n", "-58.907 -29.481 8.918 150.7414288276451\n", "-61.594 -31.438 8.481 153.97026708426532\n", "-61.691 -31.933 7.618 154.24470590914942\n", "-60.911 -31.894 9.052 153.5287075435731\n", "-62.947 -31.466 9.217 155.2387889317615\n", "-63.534 -30.78 8.788 155.51046290523345\n", "-63.579 -32.856 9.112 156.36065258241922\n", "-64.459 -32.886 9.587 157.190343027172\n", "-62.986 -33.551 9.519 156.09796166189997\n", "-63.736 -33.107 8.157 156.59104606266604\n", "-62.784 -31.137 10.704 154.99408403548827\n", "-63.666 -31.157 11.174 155.82894912691927\n", "-62.39 -30.226 10.828 154.2847023557423\n", "-62.181 -31.797 11.153 154.7069677099257\n", "-59.032 -30.338 6.85 151.17046053048853\n", "-59.637 -30.69 6.135 151.86514441767076\n", "-57.587 -30.273 6.569 149.81487076388643\n", "-57.137 -30.738 7.331 149.58680038358997\n", "-57.098 -28.816 6.556 148.79746229354853\n", "-56.092 -28.519 7.196 147.75613575753798\n", "-57.242 -31.033 5.265 149.80394436395858\n", "-57.825 -30.662 4.542 150.20031776264653\n", "-57.507 -32.552 5.424 150.65549802114757\n", "-56.78 -32.947 5.986 150.14944356207252\n", "-58.387 -32.677 5.881 151.50798607994233\n", "-55.764 -30.826 4.879 148.37003258744673\n", "-55.541 -31.317 4.037 148.3751123403113\n", "-55.155 -31.159 5.599 147.9398264092533\n", "-55.564 -29.857 4.732 147.8029089767857\n", "-57.547 -33.31 4.09 151.01696541779668\n", "-57.72 -34.284 4.236 151.57365122276363\n", "-56.679 -33.222 3.602 150.1982944377199\n", "-58.27 -32.955 3.498 151.5430678124209\n", "-57.836 -27.887 5.932 149.125921093551\n", "-58.646 -28.182 5.426 149.99029126246808\n", "-57.508 -26.452 5.958 148.2839878779904\n", "-56.578 -26.422 5.593 147.41150927251238\n", "-57.55 -25.871 7.375 148.1095088743461\n", "-56.706 -25.052 7.733 147.02672640714002\n", "-58.481 -25.641 5.094 148.89689729809683\n", "-59.383 -25.603 5.524 149.71999257614195\n", "-58.137 -24.712 4.957 148.2416439634963\n", "-58.66 -26.205 3.814 149.28767735483058\n", "-58.701 -27.158 3.888 149.67657143320727\n", "-58.51 -26.306 8.2 149.1689634910694\n", "-59.202 -26.935 7.845 150.0406572199682\n", "-58.584 -25.893 9.607 149.1085466195684\n", "-58.456 -24.901 9.585 148.62932198930332\n", "-57.451 -26.485 10.451 148.29307859101178\n", "-56.96 -25.817 11.355 147.61664037296066\n", "-59.962 -26.21 10.199 150.52012527898054\n", "-60.063 -25.769 11.091 150.47859227810446\n", "-60.682 -25.889 9.584 151.06125202049665\n", "-60.193 -27.592 10.404 151.247891965475\n", "-61.135 -27.755 10.45 152.18406265111994\n", "-56.98 -27.694 10.116 148.30188483293122\n", "-57.41 -28.174 9.351 148.86564590260573\n", "-55.871 -28.349 10.809 147.5464156596154\n", "-56.058 -28.2 11.78 147.6926675532675\n", "-54.515 -27.705 10.478 146.03833139624675\n", "-53.657 -27.607 11.352 145.23553258414412\n", "-55.857 -29.857 10.475 148.11246805721657\n", "-56.71 -30.092 10.01 148.97725009208622\n", "-55.084 -30.046 9.869 147.4628905521657\n", "-55.724 -30.737 11.729 148.3782164975708\n", "-55.074 -30.292 12.345 147.62790104177463\n", "-57.072 -30.894 12.438 149.70244276230096\n", "-56.984 -31.466 13.253 149.88411497553702\n", "-57.747 -31.32 11.835 150.46825502078505\n", "-57.432 -30.006 12.724 149.69447208564517\n", "-55.222 -32.13 11.347 148.4695523331299\n", "-55.131 -32.712 12.155 148.65372743728966\n", "-54.328 -32.079 10.903 147.6199258196535\n", "-55.854 -32.578 10.715 149.21025177245696\n", "-54.312 -27.246 9.238 145.64660663743595\n", "-55.017 -27.406 8.547 146.34803302060467\n", "-53.095 -26.516 8.847 144.23643861729255\n", "-52.35 -27.054 9.241 143.76231679407505\n", "-53.027 -25.108 9.454 143.65261985776658\n", "-51.934 -24.643 9.783 142.47234219665233\n", "-52.957 -26.464 7.314 144.07290144923158\n", "-53.863 -26.537 6.897 144.93680647095823\n", "-52.537 -25.596 7.049 143.35356114516304\n", "-52.078 -27.624 6.821 143.70866812409054\n", "-51.17 -27.526 7.229 142.8361806896278\n", "-52.49 -28.482 7.127 144.42553010461828\n", "-51.916 -27.684 5.294 143.58842846483137\n", "-50.935 -28.332 4.861 142.947498393641\n", "-52.767 -27.115 4.573 144.15924224967333\n", "-54.172 -24.457 9.685 144.47979076327596\n", "-55.03 -24.885 9.402 145.4289962352763\n", "-54.226 -23.146 10.333 144.0698291870994\n", "-53.554 -22.585 9.849 143.22987359835238\n", "-53.788 -23.17 11.813 143.71635072600475\n", "-53.382 -22.136 12.348 142.98870173898356\n", "-55.643 -22.583 10.168 145.18938752195353\n", "-55.915 -22.573 9.206 145.41971312377146\n", "-55.699 -21.646 10.513 144.92353030822844\n", "-56.309 -23.135 10.669 146.0204170176212\n", "-53.816 -24.332 12.474 144.19025230923205\n", "-54.078 -25.159 11.977 144.71920094790462\n", "-53.478 -24.444 13.899 143.9829521228121\n", "-53.699 -23.541 14.267 143.8779318936716\n", "-51.979 -24.649 14.183 142.68358394012955\n", "-51.531 -24.504 15.329 142.2805353131622\n", "-54.351 -25.53 14.56 145.2297255247699\n", "-54.775 -26.077 13.838 145.78884469327548\n", "-53.761 -26.113 15.118 144.93410903234613\n", "-55.466 -24.967 15.459 146.1080455382249\n", "-55.335 -23.813 15.946 145.5978813204368\n", "-56.41 -25.738 15.734 147.28432663729023\n", "-51.156 -24.941 13.165 141.98027973982866\n", "-51.531 -24.998 12.24 142.30880318518598\n", "-49.72 -25.18 13.367 140.75353638896607\n", "-49.603 -25.523 14.299 140.82508264510267\n", "-48.929 -23.871 13.297 139.52328918857955\n", "-48.614 -23.364 12.225 138.99390912554406\n", "-49.229 -26.276 12.409 140.68080211955004\n", "-49.939 -26.975 12.32 141.6032568869798\n", "-49.047 -25.87 11.514 140.32101996493608\n", "-47.941 -26.93 12.938 139.77826057009005\n", "-47.193 -26.268 12.893 138.82807997303715\n", "-48.081 -27.212 13.887 140.0651082782575\n", "-47.574 -28.159 12.098 139.89971060012954\n", "-48.348 -28.792 12.084 140.8629087055922\n", "-47.363 -27.869 11.164 139.55564014757698\n", "-46.353 -28.869 12.693 139.10207185372906\n", "-45.564 -28.255 12.676 138.13026300561364\n", "-46.546 -29.139 13.636 139.4338725202739\n", "-46.012 -30.088 11.919 139.26876341089553\n", "-45.215 -30.549 12.309 138.7582816195127\n", "-45.801 -29.861 10.968 138.9486130805198\n", "-46.773 -30.737 11.919 140.23192630068232\n", "-48.576 -23.323 14.46 139.0524072930778\n", "-48.917 -23.731 15.307 139.57114599371891\n", "-47.708 -22.147 14.544 137.8168390799905\n", "-48.171 -21.438 14.011 137.9583909046492\n", "-46.331 -22.426 13.924 136.60888741220316\n", "-45.702 -23.442 14.22 136.42684335936235\n", "-47.559 -21.699 16.005 137.60675410022574\n", "-47.143 -22.486 16.461 137.54285893858685\n", "-46.898 -20.949 15.965 136.71720472201002\n", "-49.103 -21.192 16.813 138.9162349079473\n", "-45.832 -21.49 13.112 135.75753815166212\n", "-46.436 -20.76 12.793 136.0371497716708\n", "-44.435 -21.49 12.67 134.44086618286866\n", "-44.211 -22.382 12.278 134.55111143353665\n", "-43.547 -21.254 13.89 133.59123853007725\n", "-43.81 -20.33 14.654 133.53788205973615\n", "-44.254 -20.419 11.583 133.83242795003008\n", "-44.901 -20.601 10.843 134.4750913812666\n", "-44.447 -19.522 11.981 133.70226438247033\n", "-42.832 -20.403 11.001 132.4844719165231\n", "-42.183 -20.168 11.725 131.82133642548158\n", "-42.615 -21.31 10.64 132.60974579569935\n", "-42.718 -19.372 9.871 131.9676343881332\n", "-43.361 -19.606 9.142 132.63531632261444\n", "-42.934 -18.463 10.228 131.85138788044665\n", "-41.292 -19.372 9.31 130.6275015033205\n", "-40.643 -19.175 10.045 129.96926934471855\n", "-41.087 -20.267 8.915 130.76065988667997\n", "-41.12 -18.346 8.251 130.07610059499785\n", "-40.187 -18.354 7.892 129.2050900235745\n", "-41.304 -17.43 8.606 129.92579879685172\n", "-41.744 -18.511 7.488 130.709951503319\n", "-42.503 -22.053 14.071 132.937025444381\n", "-42.347 -22.794 13.418 133.0419618165637\n", "-41.57 -21.893 15.19 132.0835244002824\n", "-42.004 -21.235 15.806 132.27619460054026\n", "-40.249 -21.28 14.718 130.60132092746994\n", "-39.749 -21.597 13.635 130.19874525509067\n", "-41.394 -23.201 15.98 132.48080491150407\n", "-41.022 -23.904 15.373 132.37460698336366\n", "-40.76 -23.044 16.737 131.8938825495709\n", "-42.747 -23.679 16.542 133.95007298616898\n", "-43.231 -22.885 16.91 134.11573099752317\n", "-43.276 -24.073 15.79 134.5356642455821\n", "-42.65 -24.73 17.654 134.36186640933505\n", "-43.646 -24.821 18.424 135.37426250953317\n", "-41.606 -25.41 17.733 133.6876514043088\n", "-39.697 -20.363 15.515 129.79645897327092\n", "-40.215 -20.078 16.321 130.22625543645182\n", "-38.386 -19.743 15.295 128.33674087727175\n", "-37.879 -20.307 14.643 128.03971789253518\n", "-37.628 -19.708 16.613 127.72040782114657\n", "-38.195 -19.343 17.631 128.190629415726\n", "-38.572 -18.335 14.708 127.94739515128863\n", "-39.19 -18.39 13.924 128.49403256571878\n", "-38.973 -17.743 15.407 128.15092062876488\n", "-37.234 -17.73 14.248 126.45494570399373\n", "-36.612 -17.683 15.029 125.9103868114144\n", "-36.838 -18.315 13.54 126.26210331687017\n", "-37.414 -16.322 13.678 126.08080628311352\n", "-36.595 -16.05 13.173 125.19235694322556\n", "-38.205 -16.299 13.067 126.77802109987361\n", "-37.635 -15.349 14.749 126.00956026429105\n", "-37.358 -15.624 15.67 125.91012333009606\n", "-38.16 -14.152 14.625 126.08219711759467\n", "-38.632 -13.688 13.509 126.30321968184342\n", "-38.607 -14.251 12.683 126.42646032377874\n", "-39.02 -12.767 13.475 126.36229989597372\n", "-38.184 -13.406 15.669 125.92524246551999\n", "-37.812 -13.744 16.533 125.75449770882948\n", "-38.575 -12.487 15.618 125.98685533419746\n", "-36.349 -20.04 16.602 126.66760585090411\n", "-35.952 -20.399 15.757 126.37669818047945\n", "-35.492 -19.902 17.779 125.92572014485363\n", "-36.069 -19.679 18.565 126.44291990459568\n", "-34.529 -18.735 17.583 124.57651519447795\n", "-33.832 -18.654 16.568 123.81789866170398\n", "-34.801 -21.239 18.066 125.84023554094294\n", "-35.503 -21.943 18.17 126.77034304994208\n", "-34.214 -21.466 17.289 125.32552896357548\n", "-33.941 -21.21 19.34 125.16692644624617\n", "-33.111 -20.684 19.157 124.18238323127801\n", "-34.462 -20.769 20.071 125.54472931588963\n", "-33.543 -22.624 19.796 125.42192425568985\n", "-33.368 -22.826 21.024 125.48150785275095\n", "-33.488 -23.533 18.942 125.65884154328337\n", "-34.522 -17.815 18.543 124.31258428252546\n", "-35.202 -17.886 19.272 125.03873523432648\n", "-33.577 -16.712 18.587 123.03527691276187\n", "-33.481 -16.362 17.655 122.73033317399573\n", "-32.227 -17.24 19.073 122.03410032036128\n", "-32.093 -17.718 20.2 122.21165235770277\n", "-34.12 -15.583 19.48 123.21878394952614\n", "-35.075 -15.412 19.237 124.01950524413488\n", "-34.065 -15.874 20.435 123.37607107133861\n", "-33.329 -14.277 19.317 122.00361946270283\n", "-33.751 -13.571 19.885 122.2117378568851\n", "-32.388 -14.43 19.618 121.21474861170978\n", "-33.311 -13.795 17.859 121.67445108156437\n", "-32.212 -13.409 17.407 120.47340388235072\n", "-34.366 -13.911 17.187 122.6392660243855\n", "-31.215 -17.171 18.205 120.9897647489241\n", "-31.371 -16.741 17.316 120.88944493627223\n", "-29.878 -17.705 18.509 119.99454662191945\n", "-30.047 -18.597 18.928 120.53809904341446\n", "-29.12 -16.844 19.517 119.07384118268797\n", "-28.193 -17.329 20.163 118.48289089147005\n", "-29.062 -17.851 17.219 119.18090334864893\n", "-29.038 -16.967 16.752 118.77645317991272\n", "-28.131 -18.127 17.458 118.45826629239514\n", "-29.658 -18.896 16.266 120.05561929789043\n", "-29.734 -19.773 16.741 120.51346817264866\n", "-30.565 -18.597 15.971 120.7456983995703\n", "-28.755 -19.06 15.039 119.20174086396555\n", "-28.68 -18.184 14.562 118.75271057538014\n", "-27.847 -19.36 15.332 118.51471663890523\n", "-29.354 -20.104 14.093 120.10537176163271\n", "-29.442 -20.979 14.57 120.57328859245733\n", "-30.255 -19.8 13.784 120.78687470085481\n", "-28.494 -20.306 12.9 119.33469137262642\n", "-28.889 -20.989 12.285 119.94407294235091\n", "-27.583 -20.621 13.164 118.65017620298757\n", "-28.388 -19.454 12.387 118.86532958773134\n", "-29.472 -15.564 19.617 118.92721235276643\n", "-30.232 -15.235 19.056 119.44747333451636\n", "-28.804 -14.617 20.504 118.06310433831563\n", "-27.831 -14.848 20.502 117.25047496705503\n", "-29.357 -14.796 21.918 118.81359324589084\n", "-30.521 -14.514 22.193 119.82159004536703\n", "-28.937 -13.17 19.98 117.6041169517462\n", "-29.905 -12.923 19.926 118.41008413560054\n", "-28.324 -13.062 18.561 116.84280387768858\n", "-27.349 -13.276 18.62 116.02093000833945\n", "-28.777 -13.729 17.969 117.44304373610214\n", "-28.24 -12.199 20.955 116.73094997900085\n", "-28.314 -11.255 20.634 116.43444827884915\n", "-27.268 -12.418 21.045 115.91703257934097\n", "-28.652 -12.248 21.865 117.24612753519835\n", "-28.467 -11.68 17.914 116.4262552176269\n", "-28.056 -11.667 17.003 115.95267277212716\n", "-28.016 -10.978 18.465 115.81917351630514\n", "-29.43 -11.426 17.82 117.22961907726221\n", "-28.493 -15.238 22.829 118.3023072344745\n", "-27.593 -15.547 22.521 117.54931231615096\n", "-28.797 -15.294 24.259 118.80693151916684\n", "-29.77 -15.504 24.353 119.79118611149985\n", "-28.487 -13.921 24.85 118.11161540255046\n", "-27.322 -13.53 24.936 116.9126692065492\n", "-28.005 -16.419 24.962 118.61016284028952\n", "-27.027 -16.213 24.918 117.6332619160074\n", "-28.212 -17.775 24.245 119.210496094094\n", "-29.184 -18.008 24.285 120.191057129888\n", "-27.932 -17.674 23.29 118.77837386073273\n", "-28.422 -16.487 26.445 119.2546773044982\n", "-27.923 -17.209 26.925 119.15706383593043\n", "-29.4 -16.678 26.534 120.23260220505917\n", "-28.234 -15.622 26.91 118.83773862288024\n", "-27.422 -18.941 24.847 119.04425622011335\n", "-27.595 -19.788 24.345 119.46492436276013\n", "-27.678 -19.092 25.802 119.48599518353603\n", "-26.439 -18.761 24.817 118.07948257847337\n", "-29.518 -13.188 25.268 118.86652753824349\n", "-30.448 -13.519 25.11 119.8166894969144\n", "-29.322 -11.912 25.952 118.35304197611484\n", "-28.493 -11.496 25.578 117.3826737640611\n", "-29.087 -12.159 27.446 118.47466121074159\n", "-30.003 -12.569 28.176 119.59040650905071\n", "-30.481 -10.951 25.647 119.05485805291609\n", "-30.519 -10.808 24.658 118.88827551949771\n", "-31.332 -11.376 25.956 120.03667716577294\n", "-30.341 -9.578 26.336 118.58864952431156\n", "-30.259 -9.741 27.319 118.73266690342636\n", "-29.099 -8.82 25.861 117.10869187639318\n", "-29.024 -7.933 26.317 116.83471725048167\n", "-29.134 -8.656 24.875 116.93066454100052\n", "-28.266 -9.338 26.057 116.53174335776495\n", "-31.565 -8.719 26.028 119.40895814385115\n", "-31.494 -7.823 26.466 119.13810501262809\n", "-32.402 -9.156 26.357 120.38260062816386\n", "-31.662 -8.573 25.043 119.29773652085775\n", "-27.847 -11.904 27.868 117.3195174043944\n", "-27.171 -11.646 27.178 116.48397920744293\n", "-27.395 -11.971 29.26 117.18823716141479\n", "-27.964 -12.669 29.694 118.03725866860852\n", "-27.616 -10.616 29.932 117.06262221990416\n", "-27.297 -9.572 29.363 116.30996320608136\n", "-25.921 -12.41 29.369 116.01212868058235\n", "-25.374 -11.652 29.014 115.17564196044229\n", "-25.559 -12.711 30.83 116.08464396723625\n", "-24.604 -12.997 30.911 115.33511955601381\n", "-26.131 -13.444 31.197 116.94414694630936\n", "-25.688 -11.903 31.405 116.03944668516823\n", "-25.619 -13.67 28.542 116.028398127355\n", "-24.658 -13.934 28.629 115.26636214438277\n", "-25.809 -13.516 27.572 115.96617186059044\n", "-26.178 -14.441 28.846 116.87755049623514\n", "-28.186 -10.614 31.131 117.83127405744197\n", "-28.444 -11.495 31.528 118.44684832446998\n", "-28.462 -9.402 31.912 117.85424932941535\n", "-27.84 -8.697 31.57 116.98118776110968\n", "-28.167 -9.637 33.391 117.98589223292757\n", "-28.071 -10.781 33.834 118.37453681007584\n", "-29.914 -8.954 31.699 119.00718765688062\n", "-30.557 -9.65 32.017 119.88956645596812\n", "-30.098 -8.09 32.168 119.00838550707256\n", "-30.135 -8.755 30.314 118.86474618237318\n", "-29.294 -8.71 29.86 117.9798441302581\n", "-28.001 -8.567 34.159 117.66876164046258\n", "-28.059 -7.661 33.74 117.34180169487767\n", "-27.737 -8.661 35.594 117.8012303543558\n", "-27.006 -9.336 35.695 117.37307267853218\n", "-28.978 -9.145 36.351 119.27842659508886\n", "-30.104 -8.732 36.068 120.11127854202535\n", "-27.278 -7.304 36.127 117.09112313920298\n", "-28.015 -6.631 36.062 117.5484509681008\n", "-26.979 -7.38 37.078 117.0843494579869\n", "-26.182 -6.816 35.37 115.74542709325495\n", "-25.422 -6.706 35.942 115.15816379658021\n", "-28.786 -10.038 37.318 119.63332462570786\n", "-27.895 -10.487 37.383 118.985637040779\n", "-29.816 -10.392 38.287 120.93670518911948\n", "-30.668 -10.527 37.781 121.62464919168318\n", "-30.033 -9.241 39.289 121.0360712267215\n", "-29.153 -8.411 39.501 120.03488680379549\n", "-29.42 -11.705 38.973 121.18872978540537\n", "-29.286 -12.434 38.302 121.13435972093136\n", "-30.129 -12.003 39.613 122.10087561520596\n", "-28.568 -11.599 39.486 120.52237698452515\n", "-31.2 -9.219 39.935 122.2677499711187\n", "-31.824 -9.981 39.761 123.02591672895593\n", "-31.661 -8.189 40.876 122.63467446444336\n", "-32.583 -8.495 41.115 123.63420034116773\n", "-31.892 -6.793 40.261 122.26417537038394\n", "-32.083 -5.818 40.988 122.36393726911535\n", "-30.79 -8.19 42.146 122.20479866600982\n", "-29.866 -7.89 41.91 121.2067240750281\n", "-31.185 -7.56 42.815 122.57244961654311\n", "-30.702 -9.567 42.776 122.73063613458538\n", "-31.708 -10.2 43.064 123.92154747661924\n", "-29.509 -10.075 42.991 121.87796887871079\n", "-29.419 -10.986 43.393 122.20950518269844\n", "-28.692 -9.55 42.752 120.90496137462681\n", "-31.963 -6.71 38.934 121.94635313940306\n", "-31.787 -7.546 38.414 121.89228124865004\n", "-32.277 -5.499 38.171 121.69094655725215\n", "-32.335 -4.762 38.845 121.71749605130726\n", "-33.622 -5.615 37.455 122.78520879568515\n", "-34.139 -6.719 37.257 123.52583175190524\n", "-31.163 -5.224 37.162 120.3242180444153\n", "-30.995 -6.05 36.624 120.26793737318354\n", "-31.445 -4.481 36.554 120.22612398725992\n", "-29.877 -4.823 37.888 119.2106857165078\n", "-30.085 -4.085 38.53 119.36890610623857\n", "-29.53 -5.614 38.391 119.24811566645403\n", "-28.794 -4.344 36.936 117.82809682329591\n", "-27.685 -4.063 37.432 116.85426816766257\n", "-29.037 -4.24 35.71 117.71440933037891\n", "-34.201 -4.477 37.065 122.9142985417075\n", "-33.839 -3.603 37.388 122.42576559286856\n", "-35.361 -4.493 36.169 123.78153252404009\n", "-35.934 -5.255 36.471 124.5935046581482\n", "-34.9 -4.777 34.738 123.09224817997273\n", "-33.939 -4.181 34.252 121.92163992089344\n", "-36.235 -3.231 36.31 124.30275390754623\n", "-36.435 -3.112 37.282 124.69567296422117\n", "-37.567 -3.412 35.555 125.42052403414682\n", "-37.37 -3.47 34.576 125.02739698562073\n", "-37.991 -4.264 35.861 126.10861636303841\n", "-35.505 -1.95 35.884 123.19400837703105\n", "-36.096 -1.15 35.986 123.57870396229279\n", "-35.22 -2.001 34.927 122.71431650382117\n", "-34.687 -1.801 36.44 122.52344605421445\n", "-38.57 -2.275 35.773 126.13023026618161\n", "-39.415 -2.44 35.263 126.8500198541569\n", "-38.192 -1.401 35.468 125.49239271764642\n", "-38.807 -2.187 36.74 126.5590643494175\n", "-35.59 -5.683 34.052 123.83068478369971\n", "-36.368 -6.13 34.493 124.78002078057207\n", "-35.255 -6.051 32.679 123.3219616045739\n", "-34.742 -5.275 32.313 122.5480689811145\n", "-36.503 -6.214 31.811 124.35734408952291\n", "-37.583 -6.569 32.295 125.568585649437\n", "-34.364 -7.302 32.668 122.84518896969469\n", "-33.661 -7.206 33.373 122.3143329990398\n", "-34.928 -8.104 32.866 123.64875457925162\n", "-33.68 -7.505 31.316 121.98576811251384\n", "-33.288 -6.494 30.688 121.19743177559498\n", "-33.555 -8.674 30.892 122.13490649277952\n", "-36.353 -5.939 30.516 123.88299911206542\n", "-35.437 -5.713 30.184 122.8942048959185\n", "-37.456 -5.949 29.551 124.74257064450772\n", "-38.198 -6.439 30.009 125.66293927407555\n", "-37.032 -6.69 28.297 124.32505495675439\n", "-36.01 -6.373 27.689 123.16593475064441\n", "-37.939 -4.529 29.196 124.74944809897956\n", "-37.183 -4.079 28.721 123.8286269567744\n", "-39.193 -4.589 28.312 125.79751783322276\n", "-39.511 -3.67 28.078 125.82070921752108\n", "-39.939 -5.063 28.78 126.71195748231497\n", "-39.007 -5.076 27.459 125.6056460235765\n", "-38.313 -3.731 30.445 125.12739499406194\n", "-38.625 -2.812 30.203 125.14357848887013\n", "-37.529 -3.638 31.059 124.48039222704915\n", "-39.048 -4.182 30.951 126.03714558018203\n", "-37.847 -7.657 27.87 125.29637324759244\n", "-38.646 -7.883 28.428 126.20998457332921\n", "-37.634 -8.405 26.628 125.10909350642741\n", "-36.754 -8.098 26.267 124.13188442136853\n", "-38.725 -8.062 25.615 125.87976273015451\n", "-39.902 -8.338 25.872 127.11091681283712\n", "-37.531 -9.915 26.892 125.50929820933587\n", "-38.429 -10.247 27.18 126.50009051775417\n", "-37.265 -10.367 26.041 125.26422985832787\n", "-36.508 -10.284 27.976 124.84606461158478\n", "-36.76 -9.822 28.827 125.0876477754698\n", "-36.529 -11.274 28.115 125.20101265165549\n", "-35.083 -9.876 27.606 123.32368839764726\n", "-34.773 -10.393 26.808 123.06262775107639\n", "-35.047 -8.897 27.404 122.95399517299143\n", "-34.17 -10.152 28.718 122.75339505284568\n", "-34.28 -9.558 29.515 122.81649065984583\n", "-33.231 -11.059 28.827 122.18992376624186\n", "-33.028 -11.976 27.926 122.14151270145624\n", "-33.602 -12.008 27.107 122.54440043510759\n", "-32.298 -12.648 28.052 121.71318726005002\n", "-32.44 -11.013 29.848 121.63234976765021\n", "-32.552 -10.295 30.535 121.63813357249443\n", "-31.716 -11.695 29.951 121.20684486859643\n", "-38.376 -7.46 24.466 125.20640340254168\n", "-39.287 -7.363 23.337 125.88637669740122\n", "-40.205 -7.123 23.653 126.73243708695891\n", "-39.383 -8.714 22.619 126.27600388434851\n", "-38.47 -9.538 22.675 125.66627016825159\n", "-38.682 -6.287 22.437 124.8905602317485\n", "-38.961 -6.408 21.485 125.07273767292374\n", "-38.935 -5.37 22.745 124.9187102278918\n", "-37.186 -6.544 22.617 123.56347271746614\n", "-36.88 -7.304 22.043 123.41804223856411\n", "-36.652 -5.727 22.401 122.79772917688665\n", "-37.077 -6.896 24.1 123.76189206698481\n", "-36.36 -7.574 24.26 123.30255314874871\n", "-36.896 -6.083 24.653 123.43949259049957\n", "-40.486 -8.933 21.911 127.29796043535023\n", "-41.267 -8.318 22.02 127.87302918129373\n", "-40.585 -10.05 20.978 127.61621476912721\n", "-40.172 -10.878 21.357 127.52250522162744\n", "-39.821 -9.632 19.706 126.62849437626586\n", "-40.171 -8.59 19.143 126.59357113613628\n", "-42.07 -10.338 20.746 129.08332094039105\n", "-42.435 -10.417 21.674 129.55781830904687\n", "-42.404 -9.493 20.327 129.10292109398608\n", "-42.497 -11.785 19.743 129.82411388490198\n", "-38.77 -10.354 19.269 125.80926650290908\n", "-37.829 -9.894 18.243 124.67701889682797\n", "-37.647 -8.917 18.351 124.21671918868248\n", "-38.425 -10.018 16.834 125.1559729617408\n", "-37.983 -10.813 16.016 124.920688794931\n", "-36.556 -10.724 18.469 123.75513700044938\n", "-36.063 -10.869 17.611 123.25654503514204\n", "-35.951 -10.283 19.131 123.1104611558254\n", "-37.092 -12.042 19.017 124.73733446727165\n", "-37.373 -12.652 18.276 125.12948036334203\n", "-36.408 -12.5 19.585 124.30321417405102\n", "-38.292 -11.599 19.85 125.80939361589816\n", "-39.023 -12.28 19.816 126.7123340326426\n", "-38.029 -11.439 20.801 125.61490097118255\n", "-39.494 -9.287 16.546 125.92489133606587\n", "-39.808 -8.62 17.222 126.08037866773718\n", "-40.236 -9.404 15.295 126.57290710890699\n", "-40.193 -10.37 15.039 126.80775941952447\n", "-39.583 -8.598 14.18 125.63866567263439\n", "-39.212 -7.441 14.37 124.95853927603346\n", "-41.691 -8.967 15.519 127.84463338756149\n", "-41.694 -8.031 15.87 127.60105567745119\n", "-42.173 -8.997 14.644 128.25491705583843\n", "-42.429 -9.868 16.517 128.8875381291768\n", "-41.85 -10.0 17.321 128.44122789042464\n", "-43.736 -9.198 16.932 129.96785435252824\n", "-44.238 -9.766 17.584 130.66552098009635\n", "-44.327 -9.044 16.14 130.42651636841336\n", "-43.564 -8.313 17.364 129.5845244386844\n", "-42.715 -11.244 15.913 129.53065314820273\n", "-43.196 -11.829 16.566 130.21599589144182\n", "-41.866 -11.705 15.654 128.85006506013102\n", "-43.284 -11.165 15.094 129.99022050139\n", "-39.53 -9.183 12.986 125.69576194128423\n", "-39.666 -10.171 12.914 126.12150034787882\n", "-39.276 -8.403 11.781 125.16540117380681\n", "-38.462 -7.849 11.956 124.23267401935772\n", "-40.475 -7.478 11.502 126.03157352028894\n", "-41.607 -7.84 11.842 127.23257774642467\n", "-38.997 -9.348 10.603 125.13841995566348\n", "-39.739 -10.015 10.534 126.0456619681931\n", "-38.948 -8.814 9.759 124.90653578576263\n", "-37.691 -10.096 10.778 124.13180958964547\n", "-36.664 -9.515 11.073 122.98627469356083\n", "-37.672 -11.392 10.576 124.51676514028141\n", "-36.815 -11.899 10.665 123.87340278687752\n", "-38.515 -11.873 10.333 125.46165497872248\n", "-40.287 -6.341 10.8 125.50511540570767\n", "-41.385 -5.423 10.476 126.29905908200583\n", "-41.726 -5.036 11.333 126.5534700512001\n", "-42.611 -6.11 9.84 127.64658951965774\n", "-43.747 -5.767 10.146 128.6561131893856\n", "-40.76 -4.383 9.539 125.3946590688774\n", "-40.833 -4.671 8.584 125.52197374563546\n", "-41.196 -3.49 9.652 125.58718452533283\n", "-39.298 -4.337 9.986 123.9843486332045\n", "-38.703 -4.038 9.24 123.31319699042758\n", "-39.181 -3.727 10.77 123.73519952301365\n", "-39.008 -5.786 10.371 124.10922322696247\n", "-38.662 -6.306 9.59 123.90066518384798\n", "-38.351 -5.837 11.123 123.51800564290211\n", "-42.392 -7.149 9.023 127.70408489551146\n", "-41.444 -7.43 8.871 126.87090311809087\n", "-43.448 -7.905 8.334 128.91854061383103\n", "-44.142 -7.217 8.12 129.38964940828922\n", "-44.147 -8.976 9.198 129.9091311648261\n", "-45.119 -9.588 8.749 131.0083727438823\n", "-42.831 -8.556 7.082 128.50221467352227\n", "-42.05 -9.115 7.361 127.9196309680418\n", "-43.52 -9.137 6.648 129.32911544582683\n", "-42.348 -7.548 6.056 127.75131032204717\n", "-42.752 -6.403 6.028 127.8211321104613\n", "-41.471 -7.947 5.166 127.03104885420728\n", "-41.139 -7.31 4.47 126.54067534196268\n", "-41.134 -8.888 5.183 126.98240526151645\n", "-43.639 -9.262 10.396 129.5361299715257\n", "-42.85 -8.73 10.703 128.63637340192702\n", "-44.152 -10.302 11.3 130.36262420264484\n", "-44.695 -10.908 10.718 131.0421072785385\n", "-45.056 -9.727 12.394 131.10019140336902\n", "-45.825 -10.471 13.005 132.08142668066543\n", "-42.98 -11.046 11.947 129.49609588709612\n", "-42.389 -10.375 12.395 128.7490892627983\n", "-43.346 -11.678 12.63 130.0684939906663\n", "-42.137 -11.847 10.941 128.90513824514522\n", "-42.669 -12.634 10.629 129.64780880909632\n", "-41.921 -11.259 10.161 128.49258821426238\n", "-40.824 -12.352 11.556 127.84302575033179\n", "-40.096 -13.11 10.876 127.37513168982397\n", "-40.476 -11.934 12.684 127.42938149814586\n", "-45.004 -8.412 12.618 130.68263041812403\n", "-44.354 -7.873 12.082 129.88398719626682\n", "-45.832 -7.71 13.592 131.32898889811037\n", "-45.896 -8.289 14.405 131.59733879908057\n", "-47.266 -7.529 13.066 132.62952697646176\n", "-47.683 -6.454 12.647 132.72290749151028\n", "-45.139 -6.404 13.99 130.3297682956584\n", "-44.184 -6.593 14.217 129.47604517824908\n", "-45.179 -5.762 13.224 130.1560984971507\n", "-45.795 -5.765 15.183 130.86479855942926\n", "-45.898 -6.303 16.449 131.19530428715808\n", "-45.524 -7.182 16.746 131.09554726610662\n", "-46.44 -4.559 15.204 131.1776587609338\n", "-46.543 -3.933 14.431 131.07191527554636\n", "-46.589 -5.439 17.213 131.69339583289664\n", "-46.817 -5.582 18.176 132.03105557405803\n", "-46.928 -4.357 16.495 131.68923850869515\n", "-48.0 -8.644 13.009 133.63836663922527\n", "-47.625 -9.469 13.433 133.53243639655497\n", "-49.32 -8.746 12.368 134.90416917575232\n", "-49.499 -7.829 12.012 134.81082606749354\n", "-50.463 -9.043 13.333 136.12822563304056\n", "-51.591 -9.168 12.874 137.22368754701208\n", "-49.254 -9.797 11.245 135.09172177080282\n", "-48.79 -10.613 11.589 134.89423576639587\n", "-50.184 -10.035 10.965 136.04110030060767\n", "-48.49 -9.271 10.026 134.17361568505189\n", "-48.958 -8.463 9.668 134.38899856015001\n", "-47.561 -9.024 10.302 133.2204534596696\n", "-48.423 -10.34 8.931 134.39101651896232\n", "-47.796 -11.068 9.21 134.0097416944007\n", "-49.334 -10.724 8.78 135.3714986583217\n", "-47.918 -9.696 7.639 133.7055092283037\n", "-48.635 -9.118 7.249 134.22675013945616\n", "-47.111 -9.139 7.835 132.7749992054227\n", "-47.545 -10.714 6.631 133.6393960813951\n", "-47.216 -10.283 5.791 133.200863101558\n", "-48.329 -11.289 6.395 134.55820715957836\n", "-46.819 -11.31 6.975 133.12349627695332\n", "-50.214 -9.22 14.625 136.00880238425745\n", "-49.29 -9.051 14.967 135.096799647512\n", "-51.247 -9.654 15.563 137.17823671778262\n", "-52.055 -9.086 15.408 137.7863702112803\n", "-51.464 -10.608 15.355 137.64109623945893\n", "-50.82 -9.539 17.017 136.84046879121686\n", "-49.751 -9.014 17.315 135.69430551426984\n", "-51.666 -10.044 17.912 137.86207391810117\n", "-52.483 -10.514 17.579 138.74845799863868\n", "-51.462 -9.947 19.359 137.76667180054832\n", "-51.258 -8.984 19.535 137.32185325722924\n", "-50.281 -10.804 19.8 136.92437103744533\n", "-50.161 -11.966 19.4 137.1107996475843\n", "-52.73 -10.369 20.114 139.16792826653705\n", "-52.887 -11.343 19.949 139.5772227191815\n", "-53.842 -9.662 19.611 139.9880581549726\n", "-53.61 -8.74 19.497 139.50603817039604\n", "-52.657 -10.08 21.612 139.17162914904745\n", "-53.497 -10.366 22.073 140.10320619100764\n", "-52.53 -9.103 21.783 138.80077130549384\n", "-51.893 -10.568 22.034 138.6259478308444\n", "-49.427 -10.227 20.645 136.02999571418061\n", "-49.592 -9.273 20.893 135.9445653897205\n", "-48.264 -10.893 21.235 135.17794723622637\n", "-48.012 -11.645 20.626 135.09548677139438\n", "-48.648 -11.482 22.597 135.86950051428022\n", "-49.227 -10.798 23.442 136.32156244703182\n", "-47.072 -9.91 21.322 133.76930210253772\n", "-47.323 -9.139 21.907 133.85466595528152\n", "-46.737 -9.363 19.911 133.14513627617043\n", "-46.498 -10.139 19.328 133.0835649282059\n", "-47.555 -8.915 19.551 133.7636070910171\n", "-45.85 -10.596 21.968 132.88118512791792\n", "-45.075 -9.966 22.028 131.9680281583384\n", "-45.56 -11.39 21.433 132.78173745662465\n", "-46.063 -10.91 22.893 133.28612613846948\n", "-45.588 -8.355 19.825 131.75562431638352\n", "-45.443 -8.057 18.882 131.44221074297252\n", "-44.734 -8.756 20.156 131.08809243024328\n", "-45.781 -7.544 20.377 131.77204713064148\n", "-48.299 -12.742 22.841 135.9451120599781\n", "-47.878 -13.262 22.098 135.61946202886958\n", "-48.492 -13.42 24.132 136.49492864205612\n", "-48.713 -12.693 24.782 136.5670380179639\n", "-47.215 -14.129 24.558 135.5691801443086\n", "-46.612 -14.842 23.758 135.12561001157403\n", "-49.645 -14.43 24.066 137.88560429573496\n", "-49.375 -15.177 23.458 137.7906385680827\n", "-50.794 -13.846 23.501 138.71844809541372\n", "-50.646 -12.909 23.373 138.27927310699894\n", "-50.041 -14.939 25.449 138.59933446449153\n", "-50.793 -15.595 25.388 139.50415270163109\n", "-50.338 -14.186 26.037 138.7257990209463\n", "-49.272 -15.394 25.897 138.08321048556192\n", "-46.808 -13.952 25.811 135.30353301373916\n", "-47.379 -13.394 26.413 135.75279879619424\n", "-45.583 -14.518 26.367 134.41555152957562\n", "-45.048 -14.826 25.581 133.9005444723807\n", "-45.842 -15.745 27.239 135.1860388464726\n", "-46.81 -15.791 27.994 136.2207020757124\n", "-44.838 -13.431 27.137 133.4890330289346\n", "-45.492 -12.934 27.708 134.03592588929283\n", "-44.148 -13.863 27.718 133.0712586323583\n", "-44.144 -12.437 26.27 132.3965795101973\n", "-44.661 -11.28 25.802 132.4611108665483\n", "-45.598 -10.966 25.956 133.2735400782916\n", "-42.78 -12.497 25.776 131.06186715440919\n", "-43.706 -10.596 25.081 131.2521758372028\n", "-43.858 -9.719 24.625 131.0734195289037\n", "-42.514 -11.286 25.074 130.3357910360773\n", "-41.726 -13.426 25.904 130.388510249178\n", "-41.89 -14.303 26.355 130.89397435711086\n", "-41.249 -10.989 24.573 128.98329390273764\n", "-41.087 -10.126 24.094 128.50228382406283\n", "-40.446 -13.129 25.402 129.02197088093175\n", "-39.703 -13.789 25.513 128.5597155177313\n", "-40.205 -11.908 24.745 128.31194384389943\n", "-39.29 -11.696 24.401 127.33796623945271\n", "-44.936 -16.716 27.17 134.65448275122517\n", "-44.176 -16.586 26.533 133.8080942320008\n", "-44.952 -17.956 27.943 135.21131191583046\n", "-45.632 -17.839 28.667 135.91679588262812\n", "-43.568 -18.184 28.554 134.10954058902743\n", "-42.553 -17.843 27.94 132.9540221166701\n", "-45.362 -19.138 27.051 135.86348381371647\n", "-44.668 -19.254 26.34 135.15747451399054\n", "-45.401 -19.962 27.616 136.27702810085052\n", "-46.709 -18.975 26.367 136.95206855684947\n", "-47.854 -19.587 26.911 138.3046784566596\n", "-47.776 -20.149 27.735 138.55271552373125\n", "-46.821 -18.188 25.203 136.6212490830032\n", "-46.004 -17.776 24.8 135.66606482462737\n", "-49.109 -19.409 26.297 139.3177806670778\n", "-49.918 -19.86 26.673 140.27744111581163\n", "-48.077 -17.981 24.607 137.64023479346437\n", "-48.158 -17.4 23.797 137.41654903977178\n", "-49.223 -18.595 25.153 138.9880290025008\n", "-50.438 -18.399 24.576 139.97881659022553\n", "-50.336 -18.353 23.625 139.7488983105055\n", "-43.53 -18.747 29.763 134.47507808884143\n", "-44.397 -18.899 30.238 135.40866533940874\n", "-42.293 -19.157 30.437 133.60263953230864\n", "-41.531 -18.675 30.004 132.65490899699114\n", "-42.092 -20.656 30.245 133.92766315440585\n", "-42.998 -21.429 30.563 135.0957569244867\n", "-42.342 -18.754 31.919 133.77720539015604\n", "-42.423 -17.759 31.984 133.51533985651238\n", "-43.137 -19.183 32.347 134.7385231401918\n", "-41.071 -19.203 32.658 132.9179258828545\n", "-41.022 -20.202 32.637 133.2314311639712\n", "-40.274 -18.82 32.19 131.96162404653862\n", "-41.051 -18.741 34.12 133.02951892343293\n", "-41.216 -17.755 34.153 132.8398196438101\n", "-41.773 -19.217 34.622 133.961281962364\n", "-39.697 -19.046 34.778 132.04542521420422\n", "-38.964 -18.655 34.222 131.12067938353584\n", "-39.675 -18.641 35.692 132.07854415081957\n", "-39.435 -20.502 34.919 132.37049325661667\n", "-38.548 -20.666 35.35 131.72417163527732\n", "-39.432 -20.954 34.027 132.34797851875186\n", "-40.136 -20.939 35.482 133.28718246703244\n", "-40.91 -21.035 29.771 132.90653718685172\n", "-40.214 -20.328 29.648 131.9876532142306\n", "-40.549 -22.406 29.416 133.03510984698738\n", "-39.723 -22.378 28.853 132.17898482360954\n", "-41.639 -23.038 28.526 134.1181393995607\n", "-42.32 -22.336 27.777 134.34952009590506\n", "-40.201 -23.182 30.703 133.24638228860098\n", "-41.011 -23.217 31.289 134.09905072743803\n", "-39.928 -24.112 30.456 133.31978818239998\n", "-39.053 -22.52 31.485 132.09767185306484\n", "-37.965 -22.353 30.885 130.9385985032679\n", "-39.27 -22.162 32.675 132.385375514065\n", "-41.855 -24.347 28.601 134.83484646781778\n", "-41.302 -24.889 29.233 134.6538135330745\n", "-42.874 -25.03 27.792 135.89678700028193\n", "-42.938 -24.516 26.937 135.6219053619289\n", "-44.286 -24.959 28.418 137.2473871008115\n", "-45.147 -25.811 28.167 138.32189347315918\n", "-42.398 -26.452 27.469 135.98458123625633\n", "-42.327 -26.968 28.323 136.26398676466206\n", "-43.071 -26.887 26.871 136.6772355514992\n", "-41.031 -26.465 26.768 134.6518320447219\n", "-40.797 -25.622 25.865 133.96532704024574\n", "-40.209 -27.32 27.157 134.32490877346615\n", "-44.546 -23.949 29.26 137.23003058368818\n", "-43.817 -23.298 29.471 136.35405505154588\n", "-45.856 -23.763 29.882 138.45485000533566\n", "-46.045 -24.657 30.289 139.0356740192962\n", "-46.927 -23.411 28.85 139.1298639868522\n", "-46.729 -22.587 27.957 138.5021649000477\n", "-45.834 -22.698 30.976 138.22488828355043\n", "-45.141 -22.899 31.669 137.79290821373934\n", "-45.671 -21.787 30.597 137.67406241554724\n", "-47.109 -22.709 31.595 139.50216727348717\n", "-47.79 -22.711 30.923 140.0061383332888\n", "-48.118 -23.996 29.016 140.46320010949486\n", "-48.206 -24.698 29.723 140.92205017668456\n", "-49.306 -23.663 28.215 141.30101379324918\n", "-48.939 -23.426 27.315 140.74159784868152\n", "-50.059 -22.439 28.737 141.6266966006056\n", "-50.938 -21.936 28.044 142.14985090741388\n", "-50.239 -24.876 28.114 142.5913109554716\n", "-50.481 -25.175 29.037 143.06693553019159\n", "-51.067 -24.606 27.623 143.17564026397787\n", "-49.58 -26.046 27.37 142.32246305133984\n", "-49.224 -25.721 26.494 141.74744375120136\n", "-48.828 -26.406 27.922 141.858329783626\n", "-50.598 -27.162 27.117 143.64396795549752\n", "-50.955 -27.492 27.991 144.22440381918724\n", "-51.35 -26.807 26.562 144.11428571102866\n", "-49.917 -28.316 26.376 143.37337284168214\n", "-49.513 -27.977 25.526 142.75697013105875\n", "-49.201 -28.709 26.953 142.96212388601393\n", "-50.883 -29.391 26.036 144.6316071438052\n", "-50.43 -30.14 25.553 144.4594557029757\n", "-51.614 -29.043 25.448 145.07828192393237\n", "-51.305 -29.768 26.861 145.2781989322555\n", "-49.746 -21.97 29.944 141.36497437837988\n", "-49.053 -22.454 30.478 140.9923282451921\n", "-50.369 -20.778 30.527 141.6154142210515\n", "-51.269 -20.717 30.096 142.3526040963073\n", "-49.525 -19.546 30.205 140.3562604553142\n", "-48.323 -19.566 30.499 139.3032328878264\n", "-50.558 -20.905 32.044 142.09810700357693\n", "-50.891 -20.036 32.41 142.17118765769666\n", "-49.323 -21.134 32.678 141.15897110704654\n", "-49.455 -21.186 33.625 141.47648592257298\n", "-51.502 -22.054 32.4 143.4324639577805\n", "-51.618 -22.128 33.39 143.74656057450557\n", "-51.146 -22.927 32.066 143.35691702181657\n", "-52.405 -21.915 31.994 144.14113425736596\n", "-50.115 -18.473 29.647 140.4462603774127\n", "-49.416 -17.208 29.468 139.3479702076783\n", "-48.649 -17.362 28.845 138.5842252242296\n", "-48.834 -16.692 30.784 138.86104076017867\n", "-49.365 -16.966 31.864 139.63543677734532\n", "-50.451 -16.228 28.908 139.90406911880726\n", "-50.88 -15.701 29.642 140.25636188779458\n", "-50.034 -15.603 28.248 139.21104728433014\n", "-51.467 -17.14 28.227 141.0396969118978\n", "-52.371 -16.714 28.198 141.74291049643364\n", "-51.177 -17.372 27.298 140.70458967638547\n", "-51.47 -18.373 29.125 141.58709165386512\n", "-52.115 -18.27 29.882 142.27524547861444\n", "-51.692 -19.199 28.608 141.98787234831008\n", "-47.757 -15.917 30.696 137.59300164252542\n", "-47.27 -15.855 29.825 136.96953192224905\n", "-47.268 -15.152 31.847 137.09982505459297\n", "-47.083 -15.836 32.552 137.27942848074505\n", "-48.352 -14.18 32.322 137.89163703792917\n", "-49.176 -13.715 31.532 138.37277514742556\n", "-45.951 -14.414 31.549 135.5854435734161\n", "-45.673 -13.964 32.398 135.34412674364557\n", "-44.844 -15.389 31.124 134.79254658177504\n", "-43.992 -14.902 30.932 133.8085640196471\n", "-45.105 -15.889 30.298 135.0506125310063\n", "-44.66 -16.058 31.844 134.97474242612947\n", "-46.131 -13.333 30.485 135.22236861555118\n", "-45.268 -12.863 30.302 134.23829505025753\n", "-46.798 -12.648 30.779 135.68820855918173\n", "-46.454 -13.727 29.625 135.49743219338143\n", "-48.342 -13.868 33.617 138.03390698665308\n", "-47.644 -14.283 34.201 137.62896792100128\n", "-49.303 -12.946 34.228 138.7709968257056\n", "-50.2 -13.382 34.156 139.7244178982328\n", "-49.34 -11.606 33.487 138.2645921774624\n", "-48.295 -11.075 33.12 137.0600784510209\n", "-48.905 -12.722 35.686 138.63161815401276\n", "-48.871 -13.589 36.182 138.96549645505536\n", "-48.016 -12.269 35.746 137.68182053561029\n", "-49.842 -11.899 36.339 139.4013497316292\n", "-49.459 -11.034 36.487 138.82678086378002\n", "-50.521 -11.03 33.284 139.16763630959608\n", "-51.347 -11.566 33.458 140.12960779221498\n", "-50.672 -9.641 32.815 138.83173168623952\n", "-49.864 -9.467 32.252 137.91633703807537\n", "-50.667 -8.638 33.969 138.77770554739692\n", "-50.659 -7.423 33.746 138.40550459067728\n", "-51.944 -9.496 31.97 139.83591915169723\n", "-52.191 -8.529 31.914 139.79959151943183\n", "-53.048 -10.136 32.574 141.16386681088045\n", "-53.75 -9.5 32.711 141.67970970467152\n", "-51.741 -10.162 30.605 139.5854670121499\n", "-52.561 -10.077 30.039 140.24150322212037\n", "-51.538 -11.136 30.708 139.6850339334891\n", "-50.981 -9.74 30.11 138.6653587454343\n", "-50.631 -9.131 35.21 139.12695427198855\n", "-50.413 -10.098 35.341 139.21443031884303\n", "-50.899 -8.306 36.376 139.40290897969095\n", "-51.562 -7.613 36.093 139.78568917811293\n", "-49.589 -7.653 36.791 138.08919561645655\n", "-48.677 -8.339 37.252 137.51713323437193\n", "-51.546 -9.107 37.525 140.47330483405023\n", "-50.829 -9.653 37.958 140.0456077176289\n", "-51.911 -8.451 38.186 140.78864527013533\n", "-52.689 -10.062 37.135 141.71824597065827\n", "-52.285 -10.869 36.704 141.4696557322453\n", "-53.164 -10.334 37.972 142.42010927183\n", "-53.731 -9.479 36.166 142.33439282548682\n", "-54.899 -9.357 36.577 143.48704813327228\n", "-53.373 -9.184 35.002 141.680629826381\n", "-49.494 -6.329 36.646 137.6266960513112\n", "-50.316 -5.824 36.381 138.21772956462567\n", "-48.25 -5.568 36.853 136.30837681522\n", "-47.613 -5.981 36.202 135.66901152805676\n", "-47.648 -5.716 38.263 136.10003288023114\n", "-46.473 -5.427 38.456 134.96932177720979\n", "-48.504 -4.079 36.565 136.11952578157184\n", "-49.271 -3.774 37.13 136.89757983251567\n", "-47.683 -3.565 36.812 135.27555412934\n", "-48.837 -3.782 35.095 136.0478078066677\n", "-48.087 -4.106 34.518 135.29406882786841\n", "-49.68 -4.26 34.847 136.90988074642385\n", "-49.031 -2.286 34.857 135.83472200067257\n", "-48.279 -1.441 35.304 135.02359521579922\n", "-50.076 -1.882 34.167 136.5976557705146\n", "-50.233 -0.905 34.023 136.50422112887208\n", "-50.713 -2.552 33.786 137.27940077083667\n", "-48.437 -6.168 39.245 137.18595845420916\n", "-49.408 -6.298 39.044 138.0821488716047\n", "-47.966 -6.483 40.594 137.15323661510874\n", "-47.335 -5.746 40.836 136.43715760744942\n", "-47.165 -7.799 40.676 136.7694235017462\n", "-46.463 -8.036 41.661 136.4295307658866\n", "-49.19 -6.525 41.518 138.53857369700324\n", "-49.709 -5.672 41.464 138.79703849866536\n", "-48.916 -6.659 42.47 138.56042058971963\n", "-49.803 -7.274 41.267 139.23922799627982\n", "-47.274 -8.669 39.668 136.85724287007977\n", "-47.921 -8.462 38.934 137.22915177177185\n", "-46.499 -9.91 39.578 136.45843758448942\n", "-46.565 -10.333 40.482 136.86074224919284\n", "-45.05 -9.585 39.227 134.93663539232034\n", "-44.796 -8.704 38.42 134.26034712080852\n", "-47.076 -10.859 38.519 137.01292588292534\n", "-46.938 -10.49 37.6 136.5671668776943\n", "-46.651 -11.762 38.583 136.89642805055215\n", "-48.467 -11.037 38.695 138.39756939339648\n", "-48.896 -10.182 38.735 138.56430242309887\n", "-44.081 -10.319 39.785 134.38527461742228\n", "-44.339 -11.07 40.393 134.99375945946537\n", "-42.646 -10.067 39.54 132.92494651494127\n", "-42.499 -9.097 39.735 132.55890526856354\n", "-42.23 -10.283 38.078 132.2476897718822\n", "-41.397 -9.544 37.568 131.1390258618692\n", "-41.833 -10.96 40.484 132.67588727421423\n", "-42.213 -10.883 41.406 133.24075866265545\n", "-41.905 -11.907 40.172 132.9478642964978\n", "-40.35 -10.564 40.525 131.20518403630246\n", "-39.984 -10.58 39.594 130.63527479589885\n", "-40.271 -9.64 40.898 130.95724374008486\n", "-39.528 -11.519 41.395 130.96862199397228\n", "-38.572 -11.227 41.401 130.00724660956402\n", "-39.885 -11.512 42.329 131.54379135861942\n", "-39.575 -12.908 40.902 131.3133121355181\n", "-40.125 -13.562 41.421 132.15827532545967\n", "-38.95 -13.356 39.831 130.6093621682611\n", "-38.229 -12.578 39.09 129.51508014127157\n", "-38.135 -11.61 39.324 129.18391711045146\n", "-37.766 -12.944 38.283 129.00815232379693\n", "-39.034 -14.612 39.511 131.01333748134195\n", "-39.572 -15.237 40.077 131.85234618693744\n", "-38.561 -14.954 38.699 130.4941392132229\n", "-42.793 -11.302 37.425 132.917544549243\n", "-43.337 -11.951 37.956 133.74002125392383\n", "-42.669 -11.536 35.982 132.54549028918333\n", "-42.017 -10.861 35.638 131.6614178299778\n", "-44.054 -11.356 35.388 133.64714877991224\n", "-44.992 -12.047 35.797 134.81435900897205\n", "-42.109 -12.932 35.634 132.38027721681203\n", "-42.726 -13.627 36.004 133.25029217979224\n", "-40.725 -13.136 36.277 131.3113998288039\n", "-40.087 -12.474 35.884 130.42559561681136\n", "-40.802 -12.981 37.262 131.55956914645168\n", "-42.032 -13.109 34.102 132.0367248079109\n", "-41.67 -14.01 33.863 131.93982310887037\n", "-41.435 -12.42 33.691 131.1819660509782\n", "-42.937 -13.02 33.685 132.7612293894569\n", "-40.166 -14.542 36.05 131.20052469788374\n", "-39.268 -14.644 36.478 130.50840060701074\n", "-40.065 -14.734 35.074 130.95515525553012\n", "-40.772 -15.236 36.438 132.07253524105607\n", "-44.181 -10.44 34.438 133.29288348595358\n", "-43.373 -9.933 34.138 132.32813596888604\n", "-45.466 -10.154 33.822 134.28366909270835\n", "-45.942 -11.032 33.763 134.9721770069669\n", "-45.309 -9.634 32.393 133.70421803742767\n", "-44.253 -9.147 31.988 132.49585495780613\n", "-46.254 -9.181 34.716 134.92934277613597\n", "-47.185 -9.097 34.362 135.70594018317695\n", "-46.283 -9.546 35.647 135.25617068732944\n", "-45.662 -7.805 34.781 134.00848216064534\n", "-45.934 -6.799 33.891 133.81043864736412\n", "-46.624 -6.821 33.167 134.3215374055851\n", "-44.682 -7.353 35.625 133.1474211053297\n", "-44.269 -7.866 36.377 133.0662914527943\n", "-45.109 -5.781 34.166 132.82306071236275\n", "-45.056 -4.935 33.636 132.44745221407618\n", "-44.364 -6.049 35.247 132.42032062716055\n", "-46.379 -9.719 31.613 134.58585589132312\n", "-47.166 -10.238 31.946 135.53594003436874\n", "-46.472 -9.1 30.302 134.26071728171274\n", "-45.542 -8.971 29.959 133.28667751504648\n", "-47.125 -7.72 30.428 134.52052420355787\n", "-48.203 -7.579 30.998 135.60515546615474\n", "-47.214 -10.041 29.345 135.06180953548636\n", "-46.675 -10.875 29.228 134.7753334145384\n", "-48.103 -10.27 29.74 136.03271468290265\n", "-47.434 -9.399 27.973 134.8629777626165\n", "-48.039 -8.61 28.083 135.23414913770856\n", "-46.55 -9.095 27.617 133.88448472844044\n", "-48.06 -10.348 26.959 135.56824199642037\n", "-47.836 -11.546 26.937 135.70220184654337\n", "-48.803 -9.811 26.019 135.98136665734756\n", "-49.181 -10.384 25.292 136.40062360561257\n", "-48.991 -8.829 26.03 135.8878740322329\n", "-46.496 -6.692 29.858 133.54996672781314\n", "-45.583 -6.844 29.48 132.65880450237742\n", "-47.076 -5.351 29.758 133.73672226430554\n", "-48.068 -5.476 29.725 134.70695096393501\n", "-46.628 -4.665 28.462 132.91796451195\n", "-45.448 -4.71 28.106 131.7452127441449\n", "-46.719 -4.521 31.0 133.41040013807017\n", "-47.05 -4.993 31.817 133.99442622363065\n", "-45.726 -4.419 31.053 132.4504664053698\n", "-47.333 -3.148 30.967 133.6563190163488\n", "-48.673 -2.866 31.094 134.89253814796427\n", "-49.404 -3.534 31.235 135.77296297127788\n", "-46.682 -1.957 30.781 132.72247063327293\n", "-45.695 -1.835 30.678 131.7321710023789\n", "-48.827 -1.535 30.995 134.7182092146418\n", "-49.699 -1.054 31.084 135.4636976610339\n", "-47.646 -0.94 30.76 133.4119954164542\n", "-47.57 -4.039 27.737 133.5461699151271\n", "-48.493 -3.989 28.118 134.4779139078235\n", "-47.338 -3.417 26.412 132.96929506468774\n", "-48.244 -3.305 26.005 133.75201998848465\n", "-46.545 -4.335 25.463 132.29497995766883\n", "-45.527 -3.925 24.901 131.13819293401903\n", "-46.689 -2.027 26.58 132.04342975324442\n", "-45.875 -2.123 27.153 131.37241913735164\n", "-46.423 -1.689 25.677 131.57560639419452\n", "-47.617 -0.99 27.229 132.80015123861867\n", "-48.399 -0.828 26.627 133.42534611159903\n", "-47.94 -1.344 28.107 133.32912530276346\n", "-46.872 0.337 27.461 131.82939649031243\n", "-46.079 0.171 28.047 131.19574303307255\n", "-46.566 0.701 26.581 131.31984271617142\n", "-47.79 1.365 28.138 132.60816612109525\n", "-48.578 1.545 27.549 133.23822942008798\n", "-48.104 1.002 29.015 133.13107568858592\n", "-47.1 2.66 28.394 131.72377342378255\n", "-47.716 3.313 28.835 132.26646790097632\n", "-46.778 3.069 27.54 131.19338564881994\n", "-46.309 2.532 28.992 131.08589321509768\n", "-47.001 -5.588 25.354 133.03246913441845\n", "-47.802 -5.823 25.904 133.93701169579674\n", "-46.443 -6.661 24.504 132.66195623840318\n", "-47.017 -7.44 24.755 133.45203718564957\n", "-45.0 -7.1 24.813 131.44616670713526\n", "-44.404 -7.893 24.08 130.99685085527818\n", "-46.599 -6.306 23.026 132.52547427570292\n", "-46.033 -5.505 22.831 131.75053634046427\n", "-46.281 -7.08 22.479 132.36053573856523\n", "-48.046 -5.99 22.632 133.7807419511493\n", "-48.638 -6.742 22.922 134.57859824281127\n", "-48.334 -5.146 23.085 133.89698790488154\n", "-48.168 -5.812 21.119 133.67867434261905\n", "-49.177 -6.309 20.574 134.71777646992246\n", "-47.235 -5.213 20.538 132.5667521100219\n", "-44.43 -6.618 25.916 130.93142298546977\n", "-44.964 -5.986 26.478 131.35613399076573\n", "-43.076 -6.949 26.363 129.80093239649705\n", "-42.638 -7.478 25.636 129.42205526493544\n", "-43.15 -7.804 27.615 130.30396002424484\n", "-44.098 -7.679 28.395 131.29455444533866\n", "-42.28 -5.662 26.608 128.73500843593402\n", "-42.77 -5.103 27.276 129.1598028412865\n", "-41.38 -5.904 26.971 128.00141276564096\n", "-42.092 -4.846 25.32 128.14652914925162\n", "-41.329 -5.231 24.8 127.44462893743305\n", "-42.929 -4.901 24.775 128.88161145019873\n", "-41.793 -3.371 25.627 127.5294161909322\n", "-42.427 -3.054 26.333 128.1643982898527\n", "-40.854 -3.296 25.964 126.6638089787292\n", "-41.946 -2.477 24.389 127.27587662632693\n", "-41.775 -1.525 24.643 126.91867357485265\n", "-41.288 -2.759 23.691 126.61763660327892\n", "-43.313 -2.564 23.802 128.52927132758512\n", "-43.396 -1.976 22.997 128.36247662771234\n", "-44.006 -2.278 24.464 129.21680319911957\n", "-43.524 -3.5 23.521 128.92423184956348\n", "-42.145 -8.646 27.802 129.6227341171293\n", "-41.478 -8.759 27.066 128.9069156950084\n", "-41.962 -9.414 29.023 129.87839771878924\n", "-42.853 -9.579 29.445 130.83794435101768\n", "-41.111 -8.602 30.001 129.01589317987143\n", "-39.994 -8.213 29.664 127.79245053601562\n", "-41.32 -10.751 28.646 129.60895534645744\n", "-41.913 -11.205 27.981 130.1918403971616\n", "-40.432 -10.563 28.227 128.64829980609926\n", "-41.102 -11.705 29.825 129.9034890178089\n", "-40.608 -11.212 30.541 129.4206011653477\n", "-42.429 -12.203 30.392 131.3988102115084\n", "-42.279 -12.825 31.161 131.59488256767432\n", "-42.954 -12.694 29.697 131.9177847373128\n", "-42.988 -11.441 30.718 131.7465895194255\n", "-40.313 -12.916 29.342 129.46376853776502\n", "-40.153 -13.561 30.089 129.6566005184464\n", "-39.423 -12.642 28.977 128.48349530192584\n", "-40.806 -13.4 28.619 129.95341998577797\n", "-41.653 -8.344 31.185 129.67146809148107\n", "-42.56 -8.722 31.368 130.6660929124308\n", "-41.03 -7.552 32.241 129.06802432051092\n", "-40.229 -7.118 31.829 128.11265608440095\n", "-40.58 -8.444 33.393 129.13309099529832\n", "-41.317 -9.337 33.819 130.16849877754603\n", "-42.022 -6.5 32.745 129.81266307259858\n", "-42.891 -6.953 32.945 130.7936280328671\n", "-41.657 -6.094 33.583 129.53195840795428\n", "-42.308 -5.383 31.794 129.5969089214708\n", "-43.108 -5.456 30.71 130.16695361342678\n", "-43.622 -6.266 30.428 130.81539605489866\n", "-41.784 -4.024 31.817 128.75565055561637\n", "-43.111 -4.244 30.048 129.73692857471227\n", "-43.639 -4.054 29.221 130.04449815736152\n", "-42.289 -3.327 30.677 128.84200263112956\n", "-40.919 -3.318 32.68 127.93191667445618\n", "-40.562 -3.769 33.498 127.87719684916462\n", "-41.932 -1.999 30.397 128.12726939648718\n", "-42.299 -1.535 29.591 128.2203681089709\n", "-40.552 -1.987 32.405 127.20240303940801\n", "-39.932 -1.505 33.024 126.62652587037205\n", "-41.051 -1.33 31.266 127.29467226871672\n", "-40.779 -0.387 31.074 126.77984185587233\n", "-39.393 -8.154 33.918 128.0512309351222\n", "-38.855 -7.443 33.466 127.24980049100272\n", "-38.808 -8.785 35.098 127.94615361940349\n", "-39.462 -9.459 35.44 128.8282760188927\n", "-38.546 -7.708 36.153 127.63222557802554\n", "-37.723 -6.826 35.927 126.565012341484\n", "-37.496 -9.474 34.706 126.84393955171845\n", "-36.879 -8.782 34.331 125.98180715087396\n", "-37.091 -9.87 35.53 126.77363525591588\n", "-37.624 -10.58 33.681 127.07567382469391\n", "-37.694 -11.918 34.107 127.65001421856559\n", "-37.66 -12.135 35.083 127.90169344852318\n", "-37.663 -10.28 32.306 126.73334705593471\n", "-37.603 -9.33 31.999 126.3273811530976\n", "-37.812 -12.948 33.163 127.88933205705627\n", "-37.871 -13.898 33.469 128.3188969287065\n", "-37.786 -11.316 31.365 126.98158161717784\n", "-37.829 -11.101 30.389 126.76714688751183\n", "-37.848 -12.652 31.791 127.5483701424679\n", "-37.918 -13.39 31.12 127.72264978851636\n", "-39.244 -7.754 37.291 128.56211349382835\n", "-39.76 -8.586 37.496 129.32708139055794\n", "-39.295 -6.644 38.262 128.53656796414006\n", "-38.506 -6.076 38.027 127.5900095070143\n", "-39.117 -7.121 39.719 128.8698786295696\n", "-40.09 -7.217 40.471 129.9917918447161\n", "-40.603 -5.834 38.097 129.4957434551422\n", "-41.337 -6.413 38.451 130.42095856878217\n", "-40.48 -4.517 38.865 129.22705009014172\n", "-41.313 -3.971 38.776 129.84533678573135\n", "-39.717 -3.971 38.52 128.2890374622867\n", "-40.324 -4.683 39.839 129.3711183340393\n", "-40.953 -5.488 36.643 129.3853246276408\n", "-41.805 -4.966 36.594 130.03657725424796\n", "-41.068 -6.317 36.095 129.5874218394671\n", "-40.231 -4.939 36.222 128.46757616223636\n", "-37.885 -7.4 40.185 127.9299911865861\n", "-36.651 -7.521 39.416 126.62455787484512\n", "-36.683 -6.909 38.625 126.27797599740026\n", "-36.466 -8.945 38.867 126.72638615142468\n", "-37.127 -9.9 39.304 127.73096869592746\n", "-35.553 -7.164 40.419 125.77627549343318\n", "-34.683 -7.586 40.165 125.02886104016143\n", "-35.436 -6.173 40.487 125.40892438339465\n", "-36.084 -7.746 41.729 126.78806619709917\n", "-35.817 -8.705 41.827 126.84887642387693\n", "-35.747 -7.224 42.513 126.55072915238378\n", "-37.603 -7.614 41.599 128.1096577038593\n", "-38.064 -8.447 41.904 128.8538786610632\n", "-37.942 -6.834 42.124 128.34842093691688\n", "-35.53 -9.091 37.935 125.6729357459274\n", "-35.14 -8.267 37.524 124.96637031617745\n", "-35.041 -10.383 37.479 125.50412962926757\n", "-35.851 -10.925 37.257 126.36237011863935\n", "-34.255 -11.107 38.58 125.2874684276125\n", "-33.585 -10.484 39.402 124.69290053567605\n", "-34.17 -10.169 36.242 124.33714792450404\n", "-34.679 -9.697 35.522 124.49038708671443\n", "-33.852 -11.042 35.872 124.23219198339856\n", "-33.365 -9.617 36.461 123.47813183717997\n", "-34.304 -12.435 38.582 125.75929199069148\n", "-34.931 -12.872 37.937 126.31112372629735\n", "-33.515 -13.313 39.451 125.55674458188219\n", "-32.885 -12.726 39.959 124.92591568205533\n", "-32.718 -14.303 38.614 124.95358627106306\n", "-33.102 -14.619 37.494 125.12756195978567\n", "-34.445 -14.061 40.413 126.90255326824594\n", "-35.176 -14.489 39.881 127.56693635499757\n", "-33.916 -14.768 40.883 126.7913524101703\n", "-35.078 -13.141 41.466 127.45441055530405\n", "-34.368 -12.599 41.916 126.76022914936686\n", "-35.738 -12.529 41.03 127.73533732683372\n", "-35.789 -14.021 42.497 128.67106553534092\n", "-36.583 -14.448 42.065 129.40918165648063\n", "-35.157 -14.731 42.807 128.42653601962485\n", "-36.26 -13.218 43.708 129.1762064971719\n", "-35.528 -12.616 44.028 128.41527473396613\n", "-37.061 -12.67 43.468 129.65508300101465\n", "-36.626 -14.156 44.798 130.12794410502303\n", "-36.939 -13.66 45.608 130.4874931478109\n", "-35.843 -14.717 45.066 129.69099776391573\n", "-37.361 -14.77 44.51 130.90619853925938\n", "-31.65 -14.861 39.184 124.33165781087293\n", "-31.38 -14.552 40.096 124.22414023449709\n", "-30.847 -15.915 38.53 123.81345140573379\n", "-30.468 -15.487 37.71 123.11014236853111\n", "-31.719 -17.108 38.115 124.92138907729131\n", "-31.565 -17.629 37.012 124.70112104147259\n", "-29.711 -16.385 39.458 123.21115766439335\n", "-30.149 -16.762 40.274 123.95901393605872\n", "-28.84 -17.461 38.798 122.65875894529505\n", "-28.108 -17.756 39.412 122.28359828284414\n", "-28.418 -17.116 37.96 121.93591379491113\n", "-29.384 -18.266 38.56 123.38371709832704\n", "-28.794 -15.218 39.833 122.07190318005203\n", "-28.056 -15.522 40.436 121.68985435524195\n", "-29.303 -14.5 40.308 122.4020074835376\n", "-28.379 -14.812 39.019 121.33581615087937\n", "-32.688 -17.47 38.962 126.13699007428391\n", "-32.739 -16.97 39.826 126.22605368148051\n", "-33.688 -18.531 38.751 127.36744731288289\n", "-33.142 -19.357 38.61 127.15271839013116\n", "-34.583 -18.314 37.519 127.78471957554235\n", "-35.19 -19.259 37.018 128.55873805385613\n", "-34.608 -18.576 39.982 128.52183514485\n", "-35.037 -17.678 40.08 128.60508532713627\n", "-35.313 -19.266 39.816 129.36258724994642\n", "-33.911 -18.918 41.31 128.37910080694598\n", "-33.731 -19.901 41.34 128.59443916826262\n", "-33.046 -18.419 41.362 127.44028723288407\n", "-34.789 -18.53 42.514 129.3474762645178\n", "-34.229 -18.021 43.509 128.94635787799513\n", "-36.034 -18.633 42.417 130.46598957199535\n", "-34.67 -17.081 37.017 127.29504497426441\n", "-34.171 -16.344 37.473 126.69215556221307\n", "-35.462 -16.757 35.83 127.61757008343325\n", "-36.264 -17.35 35.905 128.57249918236792\n", "-34.718 -17.065 34.53 126.76079738625819\n", "-35.281 -16.893 33.446 126.97592622619455\n", "-35.86 -15.283 35.837 127.46556875878285\n", "-35.031 -14.729 35.757 126.50216278783537\n", "-36.454 -15.11 35.052 127.77016160669125\n", "-36.595 -14.854 37.088 128.2809231335665\n", "-37.319 -15.655 37.72 129.36304279430038\n", "-36.505 -13.653 37.409 127.87438468278155\n", "-33.454 -17.485 34.618 125.78880656878815\n", "-33.02 -17.509 35.519 125.61028637416602\n", "-32.677 -17.911 33.46 124.99034767933081\n", "-32.678 -17.126 32.84 124.56929723250428\n", "-33.332 -19.128 32.822 125.90290089191748\n", "-33.547 -20.144 33.479 126.62252033899814\n", "-31.243 -18.266 33.845 123.91489956014166\n", "-31.229 -19.007 34.517 124.33357761280737\n", "-30.715 -18.536 33.04 123.36766466136902\n", "-30.596 -17.154 34.424 123.04534931885885\n", "-29.67 -17.356 34.555 122.31784160129706\n", "-33.636 -19.042 31.533 125.88259060727975\n", "-33.341 -18.237 31.018 125.21148874204795\n", "-34.384 -20.082 30.846 126.82082002967807\n", "-33.777 -20.868 30.732 126.55567852925445\n", "-35.155 -20.338 31.429 127.7279055375136\n", "-34.899 -19.637 29.49 126.86486708699142\n", "-34.451 -18.635 28.918 125.97737008288432\n", "-35.847 -20.408 28.974 127.92701416041884\n", "-36.165 -21.194 29.504 128.61122994513346\n", "-36.443 -20.16 27.673 128.15284296885497\n", "-35.836 -19.533 27.184 127.2824395350749\n", "-37.799 -19.493 27.86 129.1692805933361\n", "-38.605 -19.887 28.696 130.19172184513113\n", "-36.535 -21.459 26.872 128.6067228763722\n", "-37.208 -22.059 27.304 129.51976969559513\n", "-36.829 -21.245 25.94 128.64705150527158\n", "-35.222 -22.196 26.797 127.69534687685373\n", "-34.855 -23.257 27.59 127.91817308342078\n", "-35.409 -23.669 28.313 128.70366174278024\n", "-34.168 -21.931 25.966 126.50749467916911\n", "-34.116 -21.185 25.302 126.06411242697105\n", "-33.623 -23.644 27.224 126.9097575917628\n", "-33.11 -24.39 27.648 126.82945066899879\n", "-33.176 -22.888 26.208 126.03661500135586\n", "-38.062 -18.483 27.052 128.90708870345338\n", "-37.336 -18.17 26.44 128.03047692248904\n", "-39.341 -17.798 26.997 129.82662448434834\n", "-39.982 -18.274 27.599 130.6825477330466\n", "-39.845 -17.861 25.57 130.09710945674388\n", "-39.06 -17.787 24.626 129.2112665443691\n", "-39.188 -16.36 27.497 129.25881908016953\n", "-38.469 -15.909 26.969 128.35321933632983\n", "-40.053 -15.877 27.363 129.87061586825558\n", "-38.821 -16.288 28.965 129.1414249147035\n", "-39.836 -16.187 29.933 130.2129090489879\n", "-40.793 -16.124 29.649 131.0237741671335\n", "-37.473 -16.393 29.362 128.007152272832\n", "-36.751 -16.447 28.672 127.2411451418133\n", "-39.505 -16.174 31.301 130.15645241400827\n", "-40.222 -16.062 31.989 130.9097921241952\n", "-37.143 -16.422 30.73 127.96538220940849\n", "-36.189 -16.515 31.013 127.17822776717719\n", "-38.161 -16.319 31.7 129.04901359173573\n", "-37.862 -16.4 33.02 129.06720392493204\n", "-38.672 -16.419 33.53 129.92000401016003\n", "-41.153 -17.977 25.398 131.32123195051133\n", "-41.744 -18.054 26.201 132.01180138911823\n", "-41.753 -17.996 24.074 131.6999899316625\n", "-41.001 -17.937 23.417 130.89680867767555\n", "-42.645 -16.78 23.901 132.0813312962888\n", "-43.554 -16.575 24.702 132.96428558827367\n", "-42.489 -19.312 23.821 132.81713328106432\n", "-43.194 -19.42 24.522 133.5998188509251\n", "-42.92 -19.265 22.92 133.08472545713124\n", "-41.601 -20.541 23.854 132.45224764042322\n", "-41.066 -21.072 22.664 132.00850124518496\n", "-41.208 -20.597 21.796 131.8581964308628\n", "-41.345 -21.183 25.078 132.6219552902158\n", "-41.694 -20.789 25.928 132.9161462200887\n", "-40.33 -22.275 22.698 131.79618113587355\n", "-39.967 -22.66 21.85 131.51236817881426\n", "-40.6 -22.376 25.114 132.39891853410282\n", "-40.423 -22.826 25.989 132.53684262498484\n", "-40.104 -22.937 23.924 132.00231636603957\n", "-39.447 -24.125 23.957 131.87824396010132\n", "-40.082 -24.841 23.965 132.74203238989523\n", "-42.428 -15.998 22.844 131.47769528326847\n", "-41.566 -16.083 22.344 130.64177897594627\n", "-43.416 -15.021 22.398 132.0198426070869\n", "-44.056 -14.898 23.156 132.67158000491287\n", "-44.184 -15.588 21.205 132.78956756462458\n", "-43.603 -16.046 20.222 132.29399232013523\n", "-42.802 -13.637 22.157 130.9639130256881\n", "-43.6 -13.036 22.121 131.51810752135995\n", "-42.291 -13.464 22.999 130.53163405473785\n", "-41.755 -13.419 20.702 129.74388166306724\n", "-45.508 -15.6 21.306 134.04553502821346\n", "-45.915 -15.253 22.151 134.40908551879963\n", "-46.409 -16.086 20.265 134.9410042388895\n", "-45.839 -16.517 19.566 134.48073547166524\n", "-47.146 -14.895 19.682 135.1875744364104\n", "-47.861 -14.203 20.4 135.71289706214364\n", "-47.38 -17.153 20.796 136.26120955723238\n", "-47.939 -16.707 21.495 136.7109160455009\n", "-48.266 -17.699 19.669 137.1618094769823\n", "-48.898 -18.393 20.014 138.0216641038645\n", "-47.713 -18.118 18.949 136.7193103295946\n", "-48.809 -16.969 19.254 137.3879995086907\n", "-46.624 -18.345 21.401 136.02489067446442\n", "-47.26 -19.036 21.745 136.89451637666133\n", "-46.046 -18.053 22.163 135.47100697566248\n", "-46.037 -18.78 20.719 135.55606231002727\n", "-46.977 -14.67 18.384 134.83616519317061\n", "-46.301 -15.224 17.898 134.33635470713057\n", "-47.714 -13.665 17.617 135.14943309907\n", "-48.098 -13.025 18.282 135.3708443129465\n", "-48.804 -14.37 16.841 136.34100490314717\n", "-48.502 -15.209 15.989 136.2607291445338\n", "-46.804 -12.883 16.662 133.96932846737718\n", "-46.514 -13.495 15.926 133.8318855056597\n", "-47.554 -11.689 16.055 134.27368729203798\n", "-46.965 -11.175 15.431 133.51673379018825\n", "-47.867 -11.062 16.768 134.43759048718476\n", "-48.355 -11.993 15.54 135.09169549976045\n", "-45.577 -12.382 17.413 132.7105733579657\n", "-44.97 -11.869 16.806 131.92890392177145\n", "-45.055 -13.144 17.796 132.4858047490372\n", "-45.839 -11.779 18.167 132.83823271182132\n", "-50.063 -14.044 17.134 137.45364073752282\n", "-50.224 -13.335 17.821 137.44296621871922\n", "-51.222 -14.676 16.496 138.70091976984148\n", "-50.878 -15.242 15.747 138.5012099947145\n", "-52.136 -13.634 15.852 139.20353804770912\n", "-52.554 -12.673 16.491 139.35762473219754\n", "-51.932 -15.584 17.516 139.73438119875868\n", "-51.253 -16.182 17.941 139.31750802034895\n", "-52.356 -15.01 18.216 140.01216166105\n", "-53.02 -16.456 16.866 140.99045620537584\n", "-53.717 -15.857 16.471 141.43178195158256\n", "-52.601 -17.003 16.141 140.7194908532574\n", "-53.697 -17.404 17.87 142.0108316009733\n", "-53.915 -16.902 18.707 142.12403407235524\n", "-54.538 -17.767 17.47 142.89017038970877\n", "-52.837 -18.553 18.24 141.6084678153111\n", "-51.948 -18.332 18.641 140.73369065721258\n", "-53.117 -19.844 18.097 142.29375240325908\n", "-54.246 -20.287 17.617 143.4644164488184\n", "-54.956 -19.642 17.334 143.8912200274916\n", "-54.401 -21.271 17.532 143.9408029052221\n", "-52.235 -20.745 18.422 141.80534510729842\n", "-51.344 -20.466 18.78 140.9068786291145\n", "-52.449 -21.716 18.313 142.33618526924207\n", "-52.457 -13.857 14.584 139.4976648872661\n", "-51.902 -14.529 14.093 139.14912237955363\n", "-53.538 -13.222 13.829 140.2945428518159\n", "-54.08 -12.638 14.433 140.67163584034984\n", "-54.463 -14.338 13.288 141.48406166066906\n", "-54.094 -15.51 13.307 141.4944049847908\n", "-52.91 -12.316 12.741 139.37531333058948\n", "-52.221 -11.738 13.177 138.56839663141088\n", "-52.471 -12.904 12.062 139.101701355519\n", "-53.88 -11.396 11.997 140.00588326923977\n", "-55.092 -11.518 12.03 141.20282071191068\n", "-53.394 -10.432 11.266 139.24100234126442\n", "-54.01 -9.828 10.761 139.6488150683707\n", "-52.405 -10.296 11.211 138.25229003889953\n", "-55.649 -13.979 12.799 142.4835028836672\n", "-55.871 -13.006 12.861 142.41091024566904\n", "-56.673 -14.835 12.179 143.6906588265222\n", "-57.081 -15.302 12.963 144.25332479010666\n", "-56.143 -15.923 11.235 143.48550694059662\n", "-56.701 -17.013 11.215 144.35552193802633\n", "-57.652 -13.945 11.399 144.33072084279215\n", "-58.303 -14.504 10.885 145.10126014959346\n", "-58.15 -13.34 12.02 144.65212070688767\n", "-56.97 -13.122 10.464 143.40973399668516\n", "-56.817 -13.614 9.658 143.38763399958867\n", "-55.069 -15.658 10.485 142.36024925870285\n", "-54.631 -14.765 10.594 141.67160287439398\n", "-54.49 -16.594 9.511 142.08127156666356\n", "-55.006 -17.441 9.64 142.84370658170417\n", "-53.016 -16.936 9.754 140.80021123918812\n", "-52.398 -17.599 8.925 140.4157641684152\n", "-54.659 -15.995 8.113 142.03034998900762\n", "-54.425 -16.664 7.408 142.01382904492084\n", "-55.597 -15.677 7.973 142.82100526883292\n", "-53.795 -14.88 7.957 140.86084793511645\n", "-52.887 -15.182 7.922 140.09106331240403\n", "-52.4 -16.414 10.818 140.0773664265573\n", "-52.952 -15.951 11.512 140.4753399497577\n", "-50.951 -16.492 11.011 138.7379149079299\n", "-50.649 -17.294 10.496 138.69991995671808\n", "-50.602 -16.699 12.476 138.53037433718282\n", "-51.044 -15.938 13.334 138.74102914783353\n", "-50.283 -15.216 10.476 137.67948569049784\n", "-50.463 -15.151 9.494 137.80506744310964\n", "-50.684 -14.427 10.942 137.82548168608008\n", "-48.779 -15.169 10.683 136.24601295450813\n", "-48.22 -14.357 11.692 135.49200362383013\n", "-48.818 -13.83 12.296 135.91775594454168\n", "-47.94 -15.949 9.865 135.68347372838005\n", "-48.337 -16.546 9.168 136.23977488237418\n", "-46.821 -14.286 11.851 134.1503014420765\n", "-46.424 -13.703 12.56 133.6188654868765\n", "-46.544 -15.89 10.027 134.35047257825332\n", "-45.95 -16.449 9.449 133.96330020942304\n", "-45.983 -15.043 11.003 133.57136135414657\n", "-44.633 -14.95 11.098 132.2694329616635\n", "-44.379 -14.928 12.02 132.05739496143332\n", "-49.75 -17.683 12.754 138.06485453583036\n", "-49.499 -18.319 12.025 138.01252165655114\n", "-49.169 -17.872 14.072 137.64744121123354\n", "-49.339 -17.024 14.575 137.55224247172418\n", "-47.654 -18.079 13.977 136.29007929779775\n", "-47.189 -18.956 13.246 136.11965108682875\n", "-49.868 -19.027 14.789 138.73723025561668\n", "-50.844 -18.812 14.752 139.57733905258402\n", "-49.684 -19.837 14.232 138.8130844769325\n", "-49.261 -19.2 16.485 138.33931610717175\n", "-46.896 -17.299 14.749 135.35747803132267\n", "-47.353 -16.569 15.257 135.57352417784233\n", "-45.448 -17.428 14.91 134.05296295494554\n", "-45.16 -18.261 14.437 134.04303739844156\n", "-45.113 -17.556 16.394 133.88388696179985\n", "-45.432 -16.663 17.17 133.937484977134\n", "-44.757 -16.208 14.281 132.95195338542416\n", "-45.052 -16.143 13.328 133.1555915987008\n", "-45.055 -15.393 14.779 132.99030189453666\n", "-43.216 -16.249 14.305 131.5201040867897\n", "-42.956 -16.509 15.235 131.42322359080984\n", "-42.647 -17.272 13.324 131.28558140176702\n", "-41.648 -17.282 13.356 130.35648806637894\n", "-42.922 -17.061 12.386 131.42466621604942\n", "-42.97 -18.193 13.539 131.9226203613315\n", "-42.628 -14.884 13.939 130.48666331085334\n", "-41.628 -14.909 13.954 129.55507462851463\n", "-42.928 -14.18 14.583 130.57489929538525\n", "-42.915 -14.604 13.023 130.61557941149286\n", "-44.449 -18.64 16.784 133.67082574743077\n", "-44.316 -19.367 16.111 133.75572796332872\n", "-43.898 -18.85 18.124 133.34126033977628\n", "-44.269 -18.157 18.742 133.4974052819005\n", "-42.385 -18.676 18.062 131.86652077005746\n", "-41.71 -19.412 17.349 131.44552312650288\n", "-44.322 -20.238 18.63 134.27873687594771\n", "-45.315 -20.247 18.752 135.21425147150723\n", "-44.063 -20.922 17.949 134.22961263819545\n", "-43.656 -20.595 19.968 133.9194356245575\n", "-42.663 -20.55 19.856 132.97376213373823\n", "-43.944 -19.931 20.658 134.01486395918926\n", "-44.029 -21.997 20.454 134.83320600282408\n", "-43.946 -22.645 19.697 134.92536346810408\n", "-43.413 -22.268 21.193 134.44656748686444\n", "-45.412 -22.072 20.966 136.1895206724805\n", "-45.744 -21.299 21.506 136.26913247687457\n", "-46.247 -23.076 20.769 137.31378340501726\n", "-45.975 -24.086 19.986 137.36827245037333\n", "-45.1 -24.123 19.503 136.53268046515456\n", "-46.642 -24.822 19.87 138.25239531017175\n", "-47.401 -23.07 21.387 138.43972412931197\n", "-47.638 -22.313 21.996 138.444703524548\n", "-48.046 -23.822 21.25 139.30088585863334\n", "-41.853 -17.723 18.817 131.1009536883695\n", "-42.466 -17.166 19.378 131.5305636610746\n", "-40.42 -17.443 18.873 129.67367872856852\n", "-40.006 -18.006 18.157 129.42394688001136\n", "-39.887 -17.847 20.241 129.45985696732404\n", "-40.333 -17.3 21.246 129.78909028111724\n", "-40.097 -15.974 18.559 128.8287082020153\n", "-40.518 -15.418 19.276 129.10000367544532\n", "-40.685 -15.522 17.206 129.10446511255913\n", "-40.062 -15.797 16.473 128.55732251023278\n", "-41.572 -15.964 17.074 130.0751965479968\n", "-38.568 -15.773 18.545 127.3307715636719\n", "-38.333 -14.822 18.342 126.76408229463107\n", "-38.137 -16.351 17.852 127.06842782139078\n", "-38.168 -16.006 19.431 127.12593964254502\n", "-40.882 -14.009 17.132 128.77489583765927\n", "-41.263 -13.74 16.248 128.9753728275286\n", "-40.013 -13.528 17.251 127.80889135345788\n", "-41.508 -13.694 17.845 129.3206085741944\n", "-38.935 -18.777 20.271 128.91903328058274\n", "-38.722 -19.249 19.415 128.80830449547886\n", "-38.177 -19.161 21.463 128.4939353043559\n", "-38.788 -19.119 22.254 129.13523176112705\n", "-37.032 -18.176 21.681 127.10014394169662\n", "-36.257 -17.927 20.763 126.18724208888948\n", "-37.663 -20.592 21.27 128.53856520126556\n", "-38.433 -21.178 21.02 129.44075081673466\n", "-36.989 -20.593 20.531 127.83837618649572\n", "-37.007 -21.156 22.536 128.30651417601524\n", "-36.219 -20.592 22.784 127.39977235458467\n", "-37.669 -21.153 23.285 129.0052986276145\n", "-36.544 -22.591 22.27 128.41552246515994\n", "-37.342 -23.18 22.142 129.36030892433737\n", "-35.978 -22.611 21.446 127.8106279227201\n", "-35.727 -23.097 23.456 128.02789977579104\n", "-35.225 -22.337 23.868 127.32308477648505\n", "-36.337 -23.502 24.137 128.83483529309922\n", "-34.752 -24.125 23.033 127.51150415158627\n", "-34.218 -24.455 23.812 127.2707788535923\n", "-34.114 -23.757 22.357 126.69834342642369\n", "-35.215 -24.911 22.623 128.20269125880316\n", "-36.925 -17.625 22.882 126.94855982247296\n", "-37.585 -17.915 23.575 127.75342864283526\n", "-35.929 -16.631 23.286 125.7225507894268\n", "-35.272 -16.546 22.537 124.98735421633661\n", "-35.245 -17.138 24.549 125.44992878834168\n", "-35.91 -17.508 25.515 126.33801913121796\n", "-36.588 -15.256 23.533 125.87930739402722\n", "-37.259 -15.372 24.265 126.6425355123625\n", "-37.324 -14.754 22.269 126.2260197978214\n", "-36.65 -14.414 21.613 125.40149779807257\n", "-37.831 -15.515 21.863 126.91073255639178\n", "-35.542 -14.215 23.986 124.61073912789378\n", "-35.968 -13.325 24.146 124.72726352325701\n", "-34.832 -14.095 23.292 123.81454207806124\n", "-35.097 -14.5 24.835 124.41782311630436\n", "-38.307 -13.63 22.573 126.80128540752258\n", "-38.769 -13.323 21.741 127.02959681113688\n", "-37.838 -12.842 22.972 126.15350175480661\n", "-39.007 -13.931 23.22 127.63847771342307\n", "-33.919 -17.12 24.559 124.2256466314424\n", "-33.441 -16.799 23.741 123.55222841373602\n", "-33.122 -17.547 25.708 123.82493289317785\n", "-33.702 -18.126 26.281 124.66109244668121\n", "-32.687 -16.333 26.525 123.10852960700976\n", "-31.937 -15.479 26.044 122.03294160594506\n", "-31.928 -18.357 25.217 122.96429593585285\n", "-31.381 -17.831 24.566 122.16757350868518\n", "-31.351 -18.645 25.981 122.66765375599223\n", "-32.395 -19.518 24.559 123.73890775742285\n", "-32.5 -20.225 25.195 124.20443854790375\n", "-33.157 -16.251 27.768 123.7168475390478\n", "-33.81 -16.946 28.07 124.61935679901417\n", "-32.779 -15.211 28.715 123.16353076296569\n", "-32.273 -14.514 28.206 122.36162136879355\n", "-31.861 -15.79 29.789 122.72909598379675\n", "-32.16 -16.835 30.365 123.49247003360163\n", "-34.046 -14.593 29.319 124.21976790752748\n", "-34.637 -14.218 28.605 124.50592779863936\n", "-33.817 -13.851 29.95 123.87057242541508\n", "-34.571 -15.276 29.826 125.03406476636677\n", "-30.748 -15.11 30.073 121.52226654403711\n", "-30.531 -14.301 29.527 120.9305144535489\n", "-29.83 -15.494 31.147 121.03780051702856\n", "-30.244 -16.24 31.668 121.7932116047524\n", "-29.638 -14.321 32.097 120.63825984736351\n", "-29.307 -13.226 31.65 119.85684856527807\n", "-28.517 -15.994 30.533 119.9059301661098\n", "-28.727 -16.643 29.801 120.19493339571349\n", "-28.018 -15.214 30.154 119.08935156847566\n", "-27.634 -16.69 31.576 119.58182542928502\n", "-27.397 -16.035 32.293 119.27406149704133\n", "-28.14 -17.454 31.976 120.41212432724538\n", "-26.346 -17.222 30.937 118.49290055526532\n", "-26.573 -17.774 30.135 118.74921362686997\n", "-25.767 -16.455 30.661 117.62022498703188\n", "-25.599 -18.085 31.957 118.37429105173132\n", "-25.334 -17.525 32.742 118.08910399355226\n", "-26.19 -18.83 32.264 119.26275397205951\n", "-24.373 -18.676 31.373 117.39133377298342\n", "-23.891 -19.238 32.045 117.3343681493193\n", "-23.745 -17.963 31.061 116.47985186288656\n", "-24.593 -19.256 30.589 117.65890435066952\n", "-29.822 -14.563 33.386 121.17071822020368\n", "-30.109 -15.483 33.651 121.81971805089684\n", "-29.634 -13.579 34.443 120.89230368803466\n", "-29.396 -12.711 34.008 120.27580979565258\n", "-28.479 -14.012 35.339 120.20822917338063\n", "-28.457 -15.143 35.821 120.709461079072\n", "-30.936 -13.382 35.216 122.18747469769559\n", "-31.207 -14.255 35.621 122.83094710210452\n", "-30.783 -12.711 35.942 121.99221741160375\n", "-32.066 -12.889 34.338 122.84771282364193\n", "-32.106 -11.545 33.929 122.34540077583627\n", "-31.378 -10.916 34.201 121.53324462878459\n", "-33.07 -13.779 33.917 123.97313878014057\n", "-33.028 -14.741 34.188 124.32658858828225\n", "-33.172 -11.088 33.137 123.00323360790154\n", "-33.21 -10.128 32.859 122.67242297272848\n", "-34.132 -13.324 33.118 124.61802016161226\n", "-34.847 -13.959 32.824 125.42611202217823\n", "-34.187 -11.974 32.733 124.13976779823619\n", "-34.946 -11.644 32.173 124.61642109288807\n", "-27.5 -13.132 35.529 119.05890437090373\n", "-27.622 -12.205 35.174 118.76214933218411\n", "-26.249 -13.448 36.232 118.21506689081556\n", "-26.395 -14.358 36.619 118.76990819647878\n", "-26.002 -12.471 37.372 117.94112740685497\n", "-26.264 -11.279 37.245 117.73543671724329\n", "-25.046 -13.503 35.269 116.91257921626739\n", "-24.247 -13.629 35.857 116.38614126260909\n", "-25.185 -14.667 34.277 117.2225254206716\n", "-24.404 -14.701 33.653 116.38671791488923\n", "-26.014 -14.572 33.726 117.80529042874092\n", "-25.234 -15.543 34.757 117.70631875562161\n", "-24.843 -12.215 34.46 116.07493790220177\n", "-24.054 -12.295 33.851 115.24402076897525\n", "-24.687 -11.433 35.064 115.8082816425492\n", "-25.646 -12.014 33.899 116.59927733052206\n", "-25.492 -12.97 38.493 117.95581081913684\n", "-25.456 -13.963 38.607 118.30769676990589\n", "-24.981 -12.116 39.566 117.49597393953547\n", "-25.626 -11.355 39.63 117.83168057020998\n", "-23.598 -11.574 39.217 115.97237713352261\n", "-22.857 -12.175 38.434 115.30130324068327\n", "-24.944 -12.876 40.898 118.10848875927589\n", "-24.573 -13.792 40.747 118.05986517441056\n", "-24.363 -12.383 41.546 117.60992130343425\n", "-26.36 -12.99 41.471 119.57637827765146\n", "-26.717 -12.067 41.612 119.61916186380842\n", "-26.931 -13.47 40.805 120.0607325523212\n", "-26.433 -13.745 42.804 120.30053345268257\n", "-27.533 -13.697 43.399 121.43901166429178\n", "-25.42 -14.357 43.207 119.74447031491684\n", "-23.248 -10.437 39.812 115.43965882659217\n", "-23.921 -9.964 40.38 116.04927791244545\n", "-21.922 -9.857 39.666 114.0138650603513\n", "-21.779 -9.723 38.685 113.55929083082546\n", "-20.847 -10.818 40.184 113.53448388925719\n", "-21.052 -11.544 41.158 114.26148882716345\n", "-21.873 -8.505 40.389 113.73439248529884\n", "-22.187 -8.629 41.33 114.33924626741249\n", "-20.93 -8.173 40.393 112.78153534599537\n", "-22.746 -7.457 39.728 113.98958355042797\n", "-23.16 -7.577 38.59 114.07671966707318\n", "-23.036 -6.379 40.415 114.11826961096106\n", "-23.595 -5.659 40.004 114.28587328712153\n", "-22.698 -6.276 41.35 114.06271648965757\n", "-19.691 -10.817 39.529 112.31256263659911\n", "-19.597 -10.259 38.705 111.79474353474764\n", "-18.554 -11.612 39.985 111.7218397897206\n", "-18.909 -12.533 40.146 112.41721149806197\n", "-17.988 -11.058 41.306 111.42781326491155\n", "-18.096 -9.855 41.572 111.18485536258973\n", "-17.481 -11.659 38.893 110.46709874890351\n", "-17.347 -10.737 38.529 109.90956980172382\n", "-16.625 -11.987 39.292 109.94970659806236\n", "-17.891 -12.595 37.749 110.84553471385303\n", "-17.912 -13.533 38.095 111.31320275241387\n", "-18.804 -12.335 37.434 111.47103976369824\n", "-16.926 -12.532 36.56 109.63771267679749\n", "-17.428 -12.704 35.424 109.84301405642508\n", "-15.717 -12.304 36.776 108.54203657569724\n", "-17.357 -11.9 42.148 111.4418333302176\n", "-16.761 -11.442 43.398 111.16220962179548\n", "-17.489 -11.096 43.99 111.87109340665263\n", "-15.793 -10.269 43.18 109.82622363078866\n", "-14.86 -10.363 42.386 108.78117893275473\n", "-16.057 -12.668 43.992 111.19669818839046\n", "-15.098 -12.701 43.712 110.28532710202205\n", "-16.113 -12.666 44.99 111.58418547446587\n", "-16.837 -13.843 43.405 112.11655222133795\n", "-16.266 -14.662 43.35 111.91110420329163\n", "-17.653 -14.041 43.949 113.07675666554996\n", "-17.214 -13.343 42.012 111.80596759565206\n", "-16.498 -13.548 41.345 111.04941126363525\n", "-18.079 -13.739 41.705 112.61219904610691\n", "-15.989 -9.18 43.93 109.8707606053585\n", "-16.729 -9.218 44.602 110.76112747710724\n", "-15.213 -7.928 43.856 108.7403569241889\n", "-15.653 -7.379 44.567 109.1897413587925\n", "-15.374 -7.109 42.561 108.17213749852593\n", "-14.646 -6.134 42.367 107.14509158146255\n", "-13.732 -8.174 44.198 107.64616021484463\n", "-13.292 -8.637 43.428 107.15452209776309\n", "-13.284 -7.294 44.358 107.01373818814106\n", "-13.547 -9.028 45.43 108.21594481406147\n", "-13.986 -8.694 46.516 108.87514124445487\n", "-12.915 -10.171 45.299 108.02616763543912\n", "-12.793 -10.769 46.091 108.42328308071103\n", "-12.555 -10.444 44.407 107.49721172663038\n", "-16.333 -7.455 41.7 108.85302893810534\n", "-16.84 -8.298 41.877 109.64036826826148\n", "-16.688 -6.68 40.516 108.53858558595647\n", "-16.066 -5.897 40.493 107.72355491256312\n", "-18.114 -6.133 40.632 109.67503065876025\n", "-18.983 -6.685 41.299 110.83646500137037\n", "-16.472 -7.529 39.248 108.23523628652546\n", "-16.976 -8.386 39.357 109.00586619994357\n", "-16.839 -7.023 38.468 108.16336219348952\n", "-14.997 -7.872 38.951 106.94586322527861\n", "-14.641 -8.344 39.757 107.0384852518009\n", "-14.9 -8.755 37.708 106.79463386331732\n", "-13.948 -8.984 37.505 105.9692178984067\n", "-15.282 -8.291 36.908 106.74404559505882\n", "-15.402 -9.61 37.836 107.57946077667427\n", "-14.157 -6.618 38.678 105.69203822426738\n", "-13.205 -6.859 38.488 104.86615299990744\n", "-14.167 -6.002 39.465 105.73982971898526\n", "-14.51 -6.115 37.889 105.60472297676841\n", "-18.362 -5.016 39.957 109.34190950408721\n", "-17.591 -4.563 39.51 108.3716207731526\n", "-19.684 -4.402 39.822 110.30929324857448\n", "-20.189 -4.666 40.644 111.09499799720957\n", "-20.467 -4.948 38.615 110.82696899672028\n", "-21.495 -4.384 38.251 111.48973345111199\n", "-19.525 -2.878 39.759 109.69999923883317\n", "-20.464 -2.534 39.743 110.45214704115081\n", "-19.097 -2.64 40.631 109.51102072850932\n", "-18.561 -2.272 38.348 108.22818305783387\n", "-19.959 -6.006 37.976 110.50817486502977\n", "-19.109 -6.393 38.335 109.96408847437422\n", "-20.539 -6.644 36.8 110.90795554873418\n", "-21.529 -6.565 36.919 111.81531105354043\n", "-20.165 -8.129 36.721 111.02854304186828\n", "-19.33 -8.619 37.482 110.64856056000005\n", "-20.082 -5.91 35.533 109.92071172440615\n", "-20.504 -6.364 34.748 110.24520815436833\n", "-20.412 -4.968 35.591 109.94624038137911\n", "-18.59 -5.848 35.266 108.47070316449506\n", "-17.851 -4.737 35.708 107.56764435925888\n", "-18.317 -3.981 36.168 107.88723559810029\n", "-17.949 -6.878 34.551 108.0326593257798\n", "-18.481 -7.646 34.196 108.67856703140687\n", "-16.46 -4.683 35.507 106.22946963531352\n", "-15.934 -3.9 35.839 105.59919263895912\n", "-16.559 -6.826 34.336 106.69805992612986\n", "-16.103 -7.558 33.83 106.3998363344606\n", "-15.811 -5.74 34.835 105.79505187389437\n", "-14.461 -5.71 34.69 104.52255458033926\n", "-14.047 -5.703 35.553 104.3818695655524\n", "-20.764 -8.836 35.761 111.54960054612476\n", "-21.534 -8.409 35.287 111.98293814237952\n", "-20.383 -10.185 35.347 111.5581482008374\n", "-19.664 -10.51 35.961 111.18505824974865\n", "-19.832 -10.158 33.914 110.68943751325145\n", "-20.43 -9.518 33.042 110.79737455824483\n", "-21.623 -11.078 35.453 113.01455848252472\n", "-22.05 -10.939 36.346 113.58179312724376\n", "-22.269 -10.827 34.732 113.32821077295802\n", "-21.276 -12.547 35.304 113.18903924850675\n", "-20.893 -13.018 34.243 112.75306066355803\n", "-21.404 -13.317 36.353 113.85535175388111\n", "-21.189 -14.291 36.287 114.00870627281058\n", "-21.717 -12.932 37.221 114.22398268752494\n", "-18.736 -10.869 33.639 109.88484708548309\n", "-18.333 -11.429 34.363 109.90588098004582\n", "-18.1 -10.863 32.321 108.99143542040355\n", "-17.917 -9.901 32.12 108.43414099350812\n", "-19.017 -11.385 31.197 109.74984232334914\n", "-18.863 -11.005 30.037 109.21756941994268\n", "-16.801 -11.669 32.406 108.13892028774838\n", "-16.212 -11.324 33.137 107.6605552558596\n", "-16.289 -11.616 31.548 107.45739319376773\n", "-16.989 -12.633 32.592 108.71365933037117\n", "-20.013 -12.213 31.53 111.02699030866324\n", "-20.105 -12.48 32.489 111.42750327006344\n", "-20.977 -12.75 30.564 111.88337679923679\n", "-20.409 -13.041 29.794 111.31502443515878\n", "-21.976 -11.701 30.049 112.29878643600739\n", "-22.59 -11.924 29.008 112.72554113864345\n", "-21.737 -13.928 31.191 113.14345137479233\n", "-22.2 -13.607 32.017 113.62325013394045\n", "-22.415 -14.258 30.534 113.73801575550718\n", "-20.812 -15.093 31.568 112.83959718999354\n", "-20.411 -15.477 30.736 112.44855923043211\n", "-20.084 -14.755 32.164 112.19184340227234\n", "-21.573 -16.188 32.296 114.10876891808097\n", "-22.518 -16.778 31.786 115.07041656742187\n", "-21.193 -16.508 33.512 114.17711192704077\n", "-21.674 -17.227 34.013 115.00761071772598\n", "-20.423 -16.032 33.937 113.40760091369538\n", "-22.151 -10.578 30.756 112.21125957763775\n", "-21.608 -10.464 31.588 111.85953606644361\n", "-23.083 -9.503 30.398 112.61809547759187\n", "-23.723 -9.901 29.741 113.20337358047242\n", "-22.406 -8.326 29.658 111.44740830095601\n", "-23.001 -7.257 29.508 111.61702850819852\n", "-23.826 -9.067 31.669 113.42869800451734\n", "-24.251 -9.85 32.122 114.1803298821649\n", "-24.547 -8.408 31.454 113.82744691857056\n", "-23.2 -8.638 32.32 112.85940569132907\n", "-21.154 -8.499 29.217 110.26238540408963\n", "-20.736 -9.399 29.339 110.21020233626287\n", "-20.355 -7.455 28.566 109.04644238580184\n", "-20.598 -6.602 29.027 109.08643091604014\n", "-20.725 -7.3 27.083 109.04800391112161\n", "-20.67 -8.252 26.302 109.17003920948274\n", "-18.85 -7.747 28.76 107.79807897175162\n", "-18.683 -8.688 28.467 107.90576663459649\n", "-18.465 -7.586 30.249 107.70779530284703\n", "-18.686 -6.652 30.531 107.66349222461623\n", "-19.007 -8.234 30.785 108.54099445370859\n", "-17.971 -6.838 27.889 106.5082069560839\n", "-17.001 -7.039 28.026 105.71011002264636\n", "-18.12 -5.875 28.113 106.3750011374853\n", "-18.177 -6.964 26.918 106.55020152022237\n", "-16.983 -7.836 30.564 106.50770764597273\n", "-16.799 -7.717 31.54 106.52380936203888\n", "-16.397 -7.2 30.061 105.64357993271526\n", "-16.715 -8.766 30.312 106.52883647163335\n", "-20.986 -6.061 26.663 108.81104349743183\n", "-21.102 -5.353 27.359 108.82684442268828\n", "-21.115 -5.659 25.262 108.55383673090509\n", "-21.303 -6.495 24.746 108.90791642943132\n", "-19.81 -5.049 24.748 107.05555674508446\n", "-19.251 -4.155 25.369 106.36300506285069\n", "-22.281 -4.673 25.113 109.31378552588873\n", "-22.12 -3.885 25.707 109.02834021941268\n", "-22.331 -4.369 24.162 109.11124875557057\n", "-23.611 -5.291 25.488 110.81228784300052\n", "-24.26 -6.148 24.581 111.53367289747074\n", "-23.894 -6.271 23.659 111.08378799356817\n", "-24.147 -5.092 26.774 111.48018309995727\n", "-23.691 -4.475 27.415 110.98677149102049\n", "-25.423 -6.831 24.972 112.89901792752671\n", "-25.876 -7.454 24.334 113.4172698005026\n", "-25.321 -5.759 27.157 112.85017611860425\n", "-25.709 -5.608 28.066 113.33632019789596\n", "-25.95 -6.638 26.262 113.5487907861638\n", "-26.775 -7.129 26.542 114.52099278734882\n", "-19.312 -5.47 23.585 106.53195836930811\n", "-19.791 -6.188 23.08 107.13099964062688\n", "-18.073 -4.903 23.027 105.10502793872423\n", "-17.526 -4.608 23.81 104.62602730200548\n", "-18.375 -3.679 22.169 104.87416096446255\n", "-19.19 -3.767 21.252 105.5358771508533\n", "-17.28 -5.964 22.256 104.59048515519946\n", "-17.819 -6.264 21.469 105.07738086286696\n", "-16.421 -5.562 21.939 103.6098694188927\n", "-16.967 -7.178 23.141 104.84318437075439\n", "-16.6 -6.859 24.015 104.53688250086664\n", "-17.81 -7.691 23.301 105.82473326685025\n", "-15.941 -8.102 22.48 104.11136132046299\n", "-16.286 -8.402 21.59 104.40387962619013\n", "-15.08 -7.61 22.356 103.12425009181884\n", "-15.711 -9.323 23.381 104.4773024441194\n", "-16.264 -9.239 24.21 105.09091984562698\n", "-15.967 -10.156 22.891 104.93917564475146\n", "-14.296 -9.447 23.786 103.29226136550596\n", "-14.16 -10.246 24.372 103.56400014001002\n", "-13.996 -8.639 24.293 102.80881329438638\n", "-13.702 -9.547 22.988 102.6554737264409\n", "-17.689 -2.564 22.414 103.9273461799155\n", "-17.097 -2.54 23.22 103.48941522687237\n", "-17.755 -1.368 21.565 103.5114418458172\n", "-18.204 -1.674 20.725 103.90710155711206\n", "-16.357 -0.86 21.225 101.99252751549987\n", "-15.406 -1.045 21.987 101.25997544439757\n", "-18.607 -0.263 22.202 104.10026077296828\n", "-18.273 -0.084 23.128 103.87740093013493\n", "-18.529 0.569 21.653 103.71753314652251\n", "-20.081 -0.684 22.271 105.62627277813034\n", "-20.384 -0.938 21.352 105.85205432583724\n", "-20.159 -1.475 22.878 106.01357466381369\n", "-21.005 0.406 22.791 106.28795954857726\n", "-20.766 1.598 22.685 105.73410323069845\n", "-22.117 0.008 23.358 107.53941173355933\n", "-22.77 0.681 23.704 108.03954608382988\n", "-22.312 -0.969 23.445 108.00151974393694\n", "-16.225 -0.248 20.045 101.52912337354242\n", "-17.052 -0.052 19.519 102.19181030787152\n", "-14.936 0.151 19.481 100.11762148093611\n", "-14.288 0.077 20.239 99.62448066113066\n", "-14.964 1.597 19.006 99.68333996210198\n", "-15.908 1.981 18.323 100.40035885892041\n", "-14.516 -0.793 18.344 99.85106636386013\n", "-15.151 -0.669 17.582 100.33087184411384\n", "-13.592 -0.543 18.053 98.86698063054216\n", "-14.515 -2.279 18.738 100.34397323706092\n", "-13.975 -2.399 19.571 99.97655320123813\n", "-15.455 -2.577 18.904 101.34291600797758\n", "-13.909 -3.134 17.622 99.91003833449369\n", "-14.433 -2.995 16.782 100.27086408822852\n", "-12.96 -2.855 17.474 98.91132922977025\n", "-13.943 -4.619 17.994 100.46442951114588\n", "-13.372 -4.778 18.8 100.07784148851333\n", "-14.884 -4.895 18.191 101.45977273284225\n", "-13.43 -5.461 16.883 100.1458131476299\n", "-13.453 -6.43 17.128 100.52595941347687\n", "-12.485 -5.223 16.66 99.15864931008288\n", "-13.981 -5.339 16.057 100.53859681734174\n", "-13.922 2.365 19.322 98.52254061888578\n", "-13.227 1.985 19.932 98.04253538643316\n", "-13.732 3.736 18.829 97.92187570711664\n", "-14.366 3.821 18.06 98.41599470614518\n", "-12.282 3.935 18.36 96.42242215377084\n", "-11.374 3.38 18.985 95.77548207135268\n", "-14.086 4.787 19.904 98.14166400667965\n", "-13.492 4.633 20.694 97.71991421404338\n", "-13.905 5.693 19.522 97.70054718884639\n", "-15.545 4.765 20.398 99.6167607232839\n", "-15.796 3.82 20.606 100.1163162176875\n", "-15.685 5.611 21.664 99.7367838512953\n", "-16.628 5.606 21.996 100.69514580653825\n", "-15.426 6.561 21.491 99.24687768892278\n", "-15.1 5.261 22.395 99.36993893024187\n", "-16.493 5.294 19.318 100.26122121737794\n", "-17.441 5.281 19.636 101.21931881315938\n", "-16.439 4.737 18.489 100.23788093330782\n", "-16.265 6.236 19.071 99.7952894930417\n", "-12.041 4.703 17.284 95.87132616689934\n", "-10.692 5.052 16.849 94.4384092517446\n", "-10.133 4.224 16.812 94.10716754849227\n", "-10.0 5.99 17.846 93.65682450841474\n", "-10.64 6.837 18.466 94.15057371041347\n", "-10.868 5.696 15.472 94.30984165504678\n", "-10.162 6.385 15.305 93.44673380594959\n", "-10.84 5.007 14.747 94.38658092652788\n", "-12.252 6.34 15.564 95.50364186249651\n", "-12.198 7.246 15.983 95.28511192206263\n", "-12.673 6.415 14.66 95.81324725214148\n", "-13.033 5.373 16.452 96.57448340529706\n", "-13.682 5.861 17.035 97.1470385909936\n", "-13.522 4.694 15.905 97.15692120482205\n", "-8.683 5.84 17.987 92.44325451324178\n", "-8.248 5.056 17.545 92.16803427436217\n", "-7.83 6.763 18.757 91.49844988304446\n", "-8.27 6.885 19.647 92.01531943649383\n", "-7.765 8.14 18.079 91.0293045398019\n", "-7.917 8.241 16.863 91.00798379263216\n", "-6.43 6.139 18.966 90.33372607171698\n", "-6.123 5.92 18.04 89.97132634345233\n", "-5.384 7.057 19.612 89.19747053588459\n", "-4.508 6.586 19.714 88.48822710959915\n", "-5.68 7.355 20.519 89.5472560997823\n", "-5.231 7.873 19.055 88.77713830711147\n", "-6.527 4.919 19.888 90.86749025366552\n", "-5.628 4.506 20.031 90.14048809497316\n", "-7.127 4.221 19.497 91.567138199247\n", "-6.894 5.174 20.782 91.28705670027925\n", "-7.5 9.177 18.88 90.65105778754045\n", "-7.428 8.965 19.855 90.76465666216117\n", "-7.3 10.587 18.518 90.11733490289201\n", "-7.011 10.978 19.392 89.87998170894339\n", "-8.56 11.396 18.16 91.13923739531728\n", "-8.464 12.609 18.005 90.80530576458624\n", "-6.185 10.72 17.469 88.87361028449332\n", "-5.382 10.184 17.73 88.23607002241204\n", "-5.899 11.673 17.369 88.39647190923401\n", "-6.494 10.396 16.575 89.13448184625297\n", "-9.731 10.761 18.079 92.39002984088704\n", "-9.733 9.762 18.129 92.59578790096232\n", "-11.015 11.45 17.92 93.49232631612072\n", "-10.822 12.395 17.656 93.10362187369512\n", "-11.515 10.994 17.184 93.97821334756263\n", "-11.86 11.44 19.192 94.48030969995811\n", "-11.579 10.698 20.135 94.47502390049975\n", "-12.934 12.223 19.186 95.38908521418999\n", "-13.003 12.936 18.488 95.2471448600954\n", "-14.018 12.086 20.156 96.60269783499837\n", "-13.588 11.858 21.03 96.35004166579274\n", "-14.952 10.957 19.707 97.64935761693468\n", "-15.242 10.799 18.517 97.80788832706695\n", "-14.785 13.405 20.32 97.1595346067487\n", "-15.148 13.672 19.427 97.35127014066123\n", "-15.541 13.253 20.956 98.01372114658233\n", "-13.927 14.556 20.856 96.22480617803289\n", "-12.851 14.283 21.442 95.30285387647108\n", "-14.372 15.71 20.681 96.47399642390688\n", "-15.44 10.153 20.648 98.40256816770585\n", "-15.215 10.33 21.606 98.2929509781856\n", "-16.297 9.017 20.316 99.40610116587412\n", "-16.779 9.237 19.468 99.71794222204947\n", "-15.706 8.224 20.168 98.97188457839933\n", "-17.309 8.697 21.404 100.60623951326279\n", "-17.087 8.984 22.575 100.51461880244086\n", "-18.445 8.118 21.018 101.76667250136461\n", "-18.549 7.87 20.055 101.78539404551127\n", "-19.548 7.827 21.933 103.02690046293735\n", "-19.375 8.323 22.784 102.89135797043403\n", "-20.389 8.168 21.513 103.7124025996891\n", "-19.697 6.339 22.233 103.5253501805234\n", "-19.93 5.562 21.31 103.78415675333109\n", "-19.648 5.957 23.511 103.76183141695215\n", "-19.256 6.588 24.181 103.36070683775338\n", "-20.14 4.659 23.981 104.60164822315181\n", "-19.924 3.999 23.261 104.42997073158644\n", "-21.653 4.741 24.191 106.07005097575845\n", "-22.135 5.697 24.793 106.42481247340771\n", "-19.431 4.232 25.281 104.246345360401\n", "-19.66 4.897 25.991 104.44214051330046\n", "-19.779 3.332 25.542 104.838878093959\n", "-17.898 4.14 25.195 102.78846595800522\n", "-17.555 5.047 24.952 102.20486118086556\n", "-17.335 3.682 26.541 102.61519246680776\n", "-16.338 3.615 26.508 101.67800512401882\n", "-17.695 2.784 26.793 103.22712027853919\n", "-17.576 4.325 27.268 102.83458230575937\n", "-17.442 3.145 24.128 102.40686210406021\n", "-16.444 3.098 24.085 101.46013890193527\n", "-17.776 3.411 23.224 102.50907049622485\n", "-17.785 2.227 24.324 102.99844645915782\n", "-22.407 3.757 23.708 106.93945450113348\n", "-21.947 2.987 23.265 106.60980190395252\n", "-23.879 3.731 23.785 108.37070883776668\n", "-24.162 4.646 24.071 108.482906459958\n", "-24.319 2.706 24.821 109.20021236700961\n", "-23.967 1.539 24.696 109.12549850974335\n", "-24.502 3.407 22.412 108.83499399549758\n", "-24.196 2.484 22.177 108.7242107628287\n", "-26.035 3.455 22.472 110.30820822132864\n", "-26.435 3.244 21.58 110.61687630737002\n", "-26.355 4.362 22.746 110.45395972983495\n", "-26.389 2.792 23.132 110.89812712575446\n", "-24.041 4.388 21.323 108.01401007739689\n", "-24.454 4.164 20.44 108.3461313799436\n", "-23.047 4.361 21.213 107.04608173118714\n", "-24.299 5.326 21.553 108.08915811033037\n", "-25.108 3.104 25.814 110.03210355618945\n", "-25.308 4.081 25.892 110.0157245033636\n", "-25.701 2.202 26.797 110.9857916356864\n", "-24.973 1.604 27.131 110.49748632887537\n", "-26.8 1.345 26.133 112.12173628248894\n", "-27.856 1.88 25.78 112.94180980044545\n", "-26.252 3.025 27.959 111.53710261164218\n", "-25.517 3.666 28.181 110.7331054788946\n", "-27.023 3.525 27.566 112.08620959333042\n", "-26.745 2.034 29.393 112.51990295498837\n", "-26.584 0.034 25.914 112.2035879328286\n", "-27.502 -0.785 25.126 113.15495051476978\n", "-27.737 -0.274 24.299 113.1148592228271\n", "-28.832 -1.047 25.845 114.60776596287006\n", "-28.892 -1.081 27.072 114.88632161401982\n", "-26.746 -2.089 24.827 112.73411708529055\n", "-27.028 -2.817 25.452 113.30376635399193\n", "-26.898 -2.382 23.883 112.80941355223861\n", "-25.28 -1.725 25.049 111.28145683356234\n", "-24.737 -2.526 25.301 111.0308116920704\n", "-24.882 -1.293 24.239 110.65484927015173\n", "-25.389 -0.743 26.205 111.32000141034852\n", "-25.496 -1.217 27.079 111.7042846581992\n", "-24.593 -0.139 26.248 110.41445461985491\n", "-29.89 -1.308 25.071 115.55530861886008\n", "-29.77 -1.22 24.082 115.26379614172005\n", "-31.22 -1.716 25.561 117.00656873013583\n", "-31.77 -1.698 24.726 117.3936779601014\n", "-31.923 -0.72 26.502 117.5798307534077\n", "-32.823 -1.099 27.248 118.66035281002665\n", "-31.173 -3.142 26.134 117.43309169054521\n", "-30.604 -3.139 26.957 117.03341691585356\n", "-32.103 -3.424 26.372 118.4308633254018\n", "-30.605 -4.165 25.176 117.01988701498563\n", "-31.384 -4.611 24.091 117.71599851761866\n", "-32.309 -4.255 23.961 118.47491590205918\n", "-29.297 -4.651 25.352 115.94884298258434\n", "-28.746 -4.34 26.126 115.46820693593538\n", "-30.862 -5.557 23.189 117.36129983516712\n", "-31.421 -5.883 22.426 117.88004462588228\n", "-28.768 -5.575 24.435 115.57321549130663\n", "-27.829 -5.902 24.544 114.80310464443023\n", "-29.553 -6.044 23.362 116.29224010225272\n", "-29.046 -6.96 22.498 115.96894572686257\n", "-28.927 -7.795 22.951 116.17856947819591\n", "-31.569 0.567 26.441 116.91722929491615\n", "-30.818 0.829 25.834 116.034356024412\n", "-32.235 1.614 27.227 117.44492634848045\n", "-32.429 1.176 28.105 117.88902030723641\n", "-33.59 2.056 26.653 118.54458448195767\n", "-34.37 2.712 27.34 119.2672355385166\n", "-31.285 2.807 27.408 116.29812605970915\n", "-30.904 3.054 26.517 115.72138880086082\n", "-31.803 3.579 27.776 116.69334353338239\n", "-30.131 2.486 28.366 115.44167928439016\n", "-29.597 1.801 27.87 114.99581356292933\n", "-29.617 3.343 28.409 114.76742252921775\n", "-30.598 1.899 30.025 116.34470440462685\n", "-31.571 3.287 30.667 117.09445362612185\n", "-31.899 3.097 31.592 117.64193378638417\n", "-32.368 3.464 30.089 117.70070857050945\n", "-31.024 4.123 30.7 116.40095689469223\n", "-33.906 1.692 25.408 118.72563733667636\n", "-33.293 1.057 24.937 118.20850975289385\n", "-35.095 2.163 24.684 119.65231240974826\n", "-34.995 3.158 24.688 119.340876450611\n", "-36.432 1.862 25.382 121.1136342159709\n", "-37.377 2.64 25.243 121.83468447449602\n", "-35.082 1.596 23.256 119.55839631326609\n", "-35.839 2.006 22.748 120.12773225196585\n", "-34.216 1.848 22.825 118.60679797549548\n", "-35.228 0.064 23.198 120.04543108756785\n", "-34.493 -0.349 23.736 119.51429633730017\n", "-36.112 -0.189 23.592 121.01032682378805\n", "-35.155 -0.488 21.768 119.91781644109436\n", "-34.802 -1.679 21.631 119.85582613707186\n", "-35.453 0.287 20.831 119.90449346876038\n", "-36.497 0.778 26.164 121.54327395623338\n", "-35.667 0.231 26.273 120.89135160961679\n", "-37.704 0.339 26.872 122.91768190947957\n", "-38.453 0.599 26.262 123.47841887957587\n", "-37.941 1.061 28.201 123.20805925750149\n", "-39.02 0.937 28.773 124.3713931537313\n", "-37.645 -1.179 27.089 123.254511552316\n", "-36.909 -1.383 27.734 122.71032706744774\n", "-38.518 -1.483 27.471 124.22634188850608\n", "-37.388 -1.96 25.818 122.99455118418864\n", "-38.285 -1.849 24.738 123.66171511425837\n", "-39.137 -1.337 24.847 124.3701705796048\n", "-36.208 -2.715 25.68 122.03649738500363\n", "-35.585 -2.819 26.455 121.59360582695128\n", "-37.985 -2.456 23.508 123.35031177909522\n", "-38.622 -2.379 22.741 123.83896809566849\n", "-35.909 -3.321 24.45 121.72154692165228\n", "-35.072 -3.859 24.348 121.05133478817984\n", "-36.786 -3.171 23.362 122.36531365546365\n", "-36.554 -3.576 22.478 122.13101554068892\n", "-36.961 1.832 28.673 122.1821997714888\n", "-36.153 1.963 28.098 121.27546199046202\n", "-36.988 2.499 29.975 122.30652919202636\n", "-37.774 2.119 30.462 123.23434661651758\n", "-37.251 4.003 29.87 122.22756391665506\n", "-36.949 4.758 30.791 121.96725295340548\n", "-35.7 2.17 30.73 121.29245114598022\n", "-34.921 2.51 30.204 120.36996118633584\n", "-35.723 2.622 31.622 121.39791986685768\n", "-35.515 0.685 30.952 121.49221111248244\n", "-36.323 0.01 31.886 122.60713370762731\n", "-37.042 0.503 32.375 123.27888602270868\n", "-34.534 -0.022 30.234 120.58065682770184\n", "-33.981 0.451 29.547 119.80921421159557\n", "-36.117 -1.358 32.129 122.78794964083404\n", "-36.688 -1.839 32.794 123.5859537407063\n", "-34.328 -1.389 30.478 120.76454709060933\n", "-33.627 -1.889 29.97 120.12559426283809\n", "-35.109 -2.052 31.438 121.86285335572937\n", "-34.948 -3.02 31.63 121.99685466847087\n", "-37.815 4.458 28.747 122.47102327081292\n", "-37.924 3.831 27.976 122.56379679987072\n", "-38.28 5.839 28.602 122.62976168124929\n", "-37.527 6.42 28.911 121.85179949840708\n", "-39.502 6.087 29.491 123.92690159525495\n", "-40.366 5.219 29.623 124.94513462716345\n", "-38.58 6.157 27.134 122.60641670809893\n", "-39.208 5.467 26.775 123.28281042789379\n", "-39.008 7.059 27.079 122.85087514136804\n", "-37.301 6.158 26.286 121.22675863026281\n", "-36.698 6.892 26.598 120.5597652162611\n", "-36.836 5.278 26.387 120.958909394885\n", "-37.643 6.38 24.812 121.28702741843416\n", "-38.28 5.672 24.507 121.9915348456605\n", "-38.065 7.28 24.699 121.5193871158014\n", "-36.365 6.309 23.977 119.93479832809159\n", "-35.769 7.079 24.204 119.24791438427759\n", "-35.886 5.451 24.163 119.6592761594353\n", "-36.681 6.368 22.53 120.02997540614594\n", "-35.848 6.322 21.979 119.15504001929587\n", "-37.154 7.219 22.301 120.30663384452245\n", "-37.27 5.606 22.261 120.7107929308726\n", "-39.566 7.267 30.1 123.89459606455803\n", "-38.776 7.877 30.039 123.01547341290039\n", "-40.734 7.717 30.855 125.09257955210613\n", "-41.082 6.931 31.365 125.66166347378979\n", "-41.879 8.149 29.91 125.95060382943781\n", "-41.756 8.084 28.686 125.62061406075038\n", "-40.285 8.8 31.864 124.68296643888449\n", "-41.041 8.979 32.494 125.51421013176156\n", "-39.5 8.45 32.376 124.08636684583846\n", "-39.877 10.128 31.237 123.95829252212214\n", "-40.087 10.381 30.064 123.89657564678694\n", "-39.323 11.034 32.008 123.44635126240063\n", "-39.075 11.927 31.632 123.00526382639077\n", "-39.148 10.831 32.972 123.50847937692375\n", "-42.998 8.61 30.472 127.06677962787911\n", "-43.043 8.657 31.47 127.29455493853615\n", "-44.172 9.053 29.698 127.99497719051321\n", "-44.39 8.274 29.11 128.2229032934444\n", "-43.887 10.255 28.78 127.37674689282969\n", "-44.522 10.394 27.737 127.79865536851315\n", "-45.329 9.374 30.657 129.24672530087562\n", "-45.042 10.103 31.278 128.97916973682223\n", "-46.117 9.681 30.123 129.86928887924194\n", "-45.737 8.145 31.486 129.98692888517675\n", "-45.887 7.378 30.862 130.13678841895555\n", "-44.99 7.924 32.113 129.4207662085185\n", "-47.015 8.356 32.311 131.3520243658239\n", "-47.602 7.319 32.693 132.1583428883701\n", "-47.384 9.524 32.556 131.58354827637078\n", "-42.867 11.058 29.101 126.32645162831099\n", "-42.394 10.885 29.965 126.04743904974825\n", "-42.393 12.174 28.277 125.5693568073039\n", "-43.206 12.518 27.806 126.23893073454005\n", "-41.4 11.732 27.183 124.47308685012997\n", "-40.787 12.572 26.527 123.65544821397883\n", "-41.798 13.261 29.192 125.01313850151911\n", "-41.059 12.857 29.732 124.44186283160502\n", "-41.431 13.996 28.621 124.46452796278945\n", "-42.802 13.869 30.152 126.09678558155238\n", "-44.007 13.793 29.993 127.2518592634308\n", "-42.322 14.514 31.188 125.7536351959656\n", "-42.945 14.941 31.844 126.4434770678187\n", "-41.333 14.579 31.322 124.80950688549329\n", "-41.227 10.421 26.97 124.45318090350283\n", "-41.831 9.794 27.462 125.21618216508598\n", "-40.227 9.827 26.076 123.42185709589691\n", "-40.314 8.847 26.257 123.68782460290906\n", "-38.765 10.165 26.433 122.00202277831298\n", "-37.869 10.043 25.59 121.01169365396056\n", "-40.581 10.104 24.601 123.50162022014123\n", "-40.77 11.079 24.487 123.52818494173708\n", "-39.806 9.845 24.024 122.6995848648234\n", "-41.793 9.331 24.139 124.73791244846132\n", "-41.897 8.131 24.325 125.0563055667326\n", "-42.709 9.972 23.453 125.44317367238442\n", "-43.494 9.476 23.082 126.23727343776083\n", "-42.622 10.957 23.301 125.19530350216816\n", "-38.499 10.537 27.683 121.89739359805851\n", "-39.266 10.617 28.319 122.74377189495195\n", "-37.162 10.836 28.187 120.64092837010166\n", "-36.633 11.09 27.377 119.94597577659702\n", "-36.547 9.602 28.848 120.3517289614071\n", "-37.213 8.839 29.55 121.2508467310641\n", "-37.182 12.012 29.167 120.67304553213198\n", "-37.738 11.755 29.958 121.39922448681457\n", "-36.244 12.193 29.463 119.7922319810429\n", "-37.76 13.298 28.56 120.95470046674497\n", "-37.16 13.604 27.821 120.19835109517933\n", "-38.669 13.101 28.192 121.80025699890784\n", "-37.881 14.423 29.595 121.12863421173375\n", "-37.805 15.597 29.174 120.84364440466035\n", "-38.069 14.1 30.793 121.58302995484196\n", "-35.249 9.403 28.624 119.08320528521223\n", "-34.781 9.983 27.957 118.41498487100355\n", "-34.485 8.37 29.315 118.64482822693958\n", "-35.078 7.566 29.368 119.36697327569297\n", "-34.13 8.828 30.735 118.5059265606577\n", "-33.882 10.021 30.939 118.11550341508942\n", "-33.218 8.042 28.51 117.32418939417396\n", "-32.787 8.9 28.233 116.7083727973276\n", "-32.592 7.529 29.097 116.92212886789224\n", "-33.498 7.209 27.251 117.51485861370891\n", "-34.245 7.64 26.744 118.07295253359256\n", "-32.23 7.146 26.407 116.15294707410568\n", "-32.379 6.609 25.577 116.25858560123633\n", "-31.481 6.723 26.917 115.59605340148944\n", "-31.936 8.062 26.132 115.65581751472773\n", "-33.91 5.783 27.607 118.24280735418962\n", "-34.091 5.246 26.783 118.37838274364117\n", "-34.74 5.778 28.165 119.14482787767163\n", "-33.19 5.32 28.124 117.73231002999982\n", "-34.039 7.904 31.71 118.77815944019338\n", "-33.506 8.23 33.025 118.49587649365694\n", "-34.062 8.943 33.452 119.0055690713674\n", "-32.082 8.78 32.89 117.00555281267637\n", "-31.35 8.438 31.962 116.15550129460075\n", "-33.555 6.926 33.829 118.9551267201208\n", "-32.78 6.863 34.458 118.3724500126613\n", "-34.409 6.854 34.344 119.90332080472164\n", "-33.473 5.845 32.75 118.83570275384413\n", "-32.524 5.665 32.49 117.90564221444197\n", "-33.902 4.995 33.056 119.47838267234788\n", "-34.25 6.468 31.595 119.21451467837295\n", "-33.906 6.149 30.712 118.76129304617729\n", "-35.227 6.267 31.665 120.20444693105159\n", "-31.668 9.636 33.827 116.6816254514823\n", "-32.307 9.923 34.541 117.41651760293352\n", "-30.303 10.166 33.836 115.2900586520798\n", "-30.104 10.519 32.922 114.83022348667618\n", "-29.316 9.036 34.141 114.60459277882366\n", "-29.369 8.463 35.228 115.0202500997107\n", "-30.207 11.325 34.837 115.26020852835552\n", "-30.924 11.991 34.631 115.7999736226222\n", "-30.34 10.967 35.761 115.67138969944122\n", "-28.841 12.023 34.764 113.83090995419478\n", "-28.128 11.379 35.041 113.31331075826881\n", "-28.674 12.322 33.824 113.39820822658531\n", "-28.806 13.243 35.694 113.86095970963883\n", "-29.543 13.872 35.445 114.42122817467045\n", "-28.929 12.943 36.64 114.26476613987359\n", "-27.458 13.961 35.559 112.44087364922063\n", "-26.723 13.352 35.855 111.89566290522612\n", "-27.311 14.221 34.605 112.02403659036752\n", "-27.404 15.191 36.389 112.45338811703273\n", "-26.521 15.65 36.293 111.52914521774116\n", "-27.535 14.976 37.357 112.864728808428\n", "-28.117 15.837 36.119 112.99038756460658\n", "-28.414 8.751 33.203 113.56855449903375\n", "-28.45 9.256 32.341 113.31683753970545\n", "-27.374 7.737 33.371 112.79698458292224\n", "-27.827 6.994 33.864 113.48561709749829\n", "-26.205 8.27 34.208 111.78864867239427\n", "-25.686 9.36 33.954 111.03836031300173\n", "-26.862 7.24 32.005 112.084049239845\n", "-26.846 8.02 31.38 111.7826192258886\n", "-25.932 6.895 32.132 111.29185644062191\n", "-27.693 6.125 31.347 112.94767288439368\n", "-27.778 5.384 32.013 113.32595038207268\n", "-29.103 6.561 30.966 114.1284367237193\n", "-29.608 5.809 30.543 114.66962193623907\n", "-29.08 7.32 30.316 113.82513297598206\n", "-29.615 6.861 31.771 114.73585328919638\n", "-26.987 5.687 30.069 112.0868407173652\n", "-27.497 4.96 29.609 112.62951615362644\n", "-26.07 5.341 30.267 111.32394449982446\n", "-26.896 6.451 29.43 111.71378748390907\n", "-25.747 7.46 35.157 111.7422848567184\n", "-26.355 6.741 35.494 112.5423035707018\n", "-24.411 7.554 35.738 110.61037117739005\n", "-24.119 8.501 35.602 110.12200054939066\n", "-23.472 6.594 35.006 109.71850174423638\n", "-23.886 5.52 34.576 110.21889090804716\n", "-24.43 7.257 37.245 111.09185083974431\n", "-24.768 6.325 37.379 111.62906117584255\n", "-23.495 7.326 37.592 110.29553474189242\n", "-25.32 8.218 38.052 111.97583766598933\n", "-24.972 8.257 38.989 111.90878619214848\n", "-25.261 9.125 37.636 111.64249841794117\n", "-26.795 7.82 38.111 113.45526985116204\n", "-27.197 6.691 37.887 113.98371838995251\n", "-27.667 8.73 38.483 114.2197542503047\n", "-28.633 8.488 38.576 115.20014815962693\n", "-27.365 9.664 38.673 113.8292669791034\n", "-22.204 6.968 34.871 108.41083930124331\n", "-21.921 7.842 35.265 108.07648499558078\n", "-21.206 6.163 34.175 107.45230314423232\n", "-21.655 5.303 33.931 107.99580390922603\n", "-20.035 5.833 35.093 106.6598082784701\n", "-19.605 6.656 35.901 106.30305416590814\n", "-20.76 6.873 32.897 106.56223538852777\n", "-20.535 7.821 33.12 106.21542991957429\n", "-19.946 6.412 32.543 105.79934029094888\n", "-21.782 6.894 31.804 107.2642656852691\n", "-22.735 7.835 31.607 107.94032557853436\n", "-22.886 8.633 32.19 108.07096365814454\n", "-21.949 5.928 30.725 107.37403401660943\n", "-23.468 7.524 30.477 108.44448208184683\n", "-24.227 8.075 30.13 108.98988094772834\n", "-23.022 6.361 29.889 108.12227923513264\n", "-21.267 4.752 30.344 106.89553859726793\n", "-20.529 4.4 30.92 106.40513171835275\n", "-23.381 5.68 28.717 108.36074786102206\n", "-24.139 6.007 28.153 108.90418745851785\n", "-21.612 4.069 29.164 107.12157055420722\n", "-21.107 3.246 28.903 106.77879166295149\n", "-22.66 4.532 28.347 107.84615771551623\n", "-22.891 4.045 27.505 108.00936869549788\n", "-19.509 4.625 34.942 106.39036167341474\n", "-19.917 4.03 34.249 106.72585951399033\n", "-18.385 4.092 35.702 105.66714458146393\n", "-17.976 4.862 36.192 105.24634437832033\n", "-17.376 3.483 34.736 104.60606750088638\n", "-17.766 2.953 33.698 104.82428734792332\n", "-18.872 3.035 36.707 106.64994549928284\n", "-19.325 2.302 36.2 107.10653083729301\n", "-18.076 2.666 37.188 106.1382582342484\n", "-19.848 3.549 37.75 107.73366798731026\n", "-19.412 3.782 39.069 107.66573959249989\n", "-18.47 3.566 39.328 106.92424011888042\n", "-21.192 3.796 37.405 108.82818101025121\n", "-21.518 3.583 36.484 108.92387843810924\n", "-20.296 4.317 40.024 108.65347989825267\n", "-19.981 4.489 40.958 108.61602099598382\n", "-22.075 4.341 38.353 109.8002274587808\n", "-23.022 4.537 38.098 110.5671048458808\n", "-21.628 4.611 39.661 109.71205211370354\n", "-22.487 5.143 40.568 110.67102638450588\n", "-23.344 5.268 40.161 111.3169129916923\n", "-16.095 3.513 35.094 103.50309563003417\n", "-15.848 4.076 35.883 103.3593313349114\n", "-15.02 2.783 34.418 102.49876780722781\n", "-15.426 2.217 33.7 102.82744893266583\n", "-14.328 1.898 35.441 102.36765361187096\n", "-13.901 2.399 36.479 102.14288095604117\n", "-14.038 3.773 33.778 101.16653056223682\n", "-14.541 4.401 33.184 101.3262453118638\n", "-13.576 4.292 34.497 100.80679198347697\n", "-12.993 3.027 32.948 100.15913372728419\n", "-12.678 2.237 33.474 100.21094931193896\n", "-13.426 2.714 32.103 100.42380157114148\n", "-11.777 3.881 32.581 98.71471052482502\n", "-12.058 4.698 32.078 98.64477178745966\n", "-11.274 4.151 33.402 98.39954252942438\n", "-10.922 2.971 31.699 97.92173582509656\n", "-10.953 2.041 32.065 98.29191259712061\n", "-11.293 2.977 30.77 98.031955693029\n", "-9.502 3.362 31.609 96.47559733943085\n", "-8.994 2.733 31.021 96.01897959778577\n", "-9.071 3.356 32.511 96.31567141955662\n", "-9.407 4.282 31.229 96.05263805330907\n", "-14.238 0.602 35.165 102.55260797268882\n", "-14.628 0.279 34.302 102.76373170530543\n", "-13.604 -0.386 36.044 102.49372822275515\n", "-13.889 -1.286 35.715 102.9180356643091\n", "-14.132 -0.273 37.491 103.36915351786529\n", "-13.379 -0.222 38.463 102.9651662116854\n", "-12.071 -0.314 35.905 101.03161796685234\n", "-11.751 0.54 36.314 100.61825190292267\n", "-11.667 -1.089 36.392 101.03050723915028\n", "-11.608 -0.36 34.441 100.205034035222\n", "-12.124 -1.214 33.681 100.71927196917181\n", "-10.778 0.503 34.065 99.09268559787851\n", "-15.461 -0.147 37.61 104.58391865387335\n", "-15.995 -0.186 36.765 104.83665823079252\n", "-16.211 0.042 38.858 105.5939515123854\n", "-17.148 0.177 38.535 106.31644513902823\n", "-15.93 1.335 39.643 105.23897636807382\n", "-16.392 1.483 40.773 105.98245199560161\n", "-16.107 -1.226 39.713 106.11273441486652\n", "-15.149 -1.271 39.998 105.34692713601093\n", "-16.684 -1.051 40.511 106.83880974159156\n", "-16.62 -2.705 38.812 106.72549745023446\n", "-15.233 2.308 39.045 104.16573807639439\n", "-14.845 2.116 38.144 103.58084846147959\n", "-14.998 3.639 39.621 103.80444092137868\n", "-15.261 3.588 40.584 104.36783784289103\n", "-15.874 4.684 38.923 104.14539827567994\n", "-15.981 4.643 37.697 103.87948364330657\n", "-13.512 3.998 39.52 102.32413571098462\n", "-13.236 3.972 38.559 101.77148173235959\n", "-13.375 4.92 39.882 102.09864473145566\n", "-12.647 3.012 40.318 102.03674957582685\n", "-12.87 3.092 41.29 102.5448275292323\n", "-12.839 2.081 40.007 102.34604491625458\n", "-11.159 3.306 40.122 100.54495720820613\n", "-10.937 3.288 39.147 100.02596865314527\n", "-10.94 4.207 40.498 100.24977172043833\n", "-10.354 2.231 40.855 100.33958131764354\n", "-10.535 2.287 41.837 100.82764409624971\n", "-10.617 1.327 40.519 100.70355863622694\n", "-8.897 2.4 40.641 98.90800989303142\n", "-8.38 1.693 41.124 98.80068719396641\n", "-8.587 3.29 40.975 98.51277982576677\n", "-8.668 2.339 39.669 98.38664768656365\n", "-16.512 5.608 39.661 104.7583245665947\n", "-17.389 6.615 39.067 105.16906295104087\n", "-18.085 6.163 38.51 105.74020042065364\n", "-16.612 7.54 38.124 103.96799165608614\n", "-15.502 7.969 38.441 102.94624167496353\n", "-18.002 7.373 40.249 105.95328942038562\n", "-18.127 8.34 40.027 105.8098658207258\n", "-18.881 6.975 40.512 106.93133084835333\n", "-16.969 7.198 41.364 105.39497538307981\n", "-16.251 7.891 41.301 104.57336470631515\n", "-17.401 7.245 42.265 106.08372592438482\n", "-16.407 5.804 41.099 105.08241181567921\n", "-15.448 5.74 41.376 104.30760586361859\n", "-16.939 5.102 41.572 105.8806420456544\n", "-17.204 7.855 36.972 104.11427328661522\n", "-18.063 7.398 36.742 104.94304788789012\n", "-16.667 8.831 36.027 103.14761266263025\n", "-15.68 8.842 36.187 102.26543499149652\n", "-17.239 10.219 36.303 103.50885789148676\n", "-18.445 10.39 36.486 104.66721679685573\n", "-16.956 8.404 34.58 103.098727562468\n", "-17.932 8.203 34.5 104.0365472994947\n", "-16.721 9.165 33.975 102.56762133344031\n", "-16.171 7.166 34.125 102.48693316223292\n", "-16.337 6.43 34.782 102.97702073763834\n", "-16.639 6.773 32.729 102.64476316890209\n", "-16.147 5.967 32.4 102.27196965444637\n", "-16.484 7.515 32.077 102.1786855807022\n", "-17.616 6.559 32.725 103.61116887189334\n", "-14.665 7.44 34.067 100.998740690169\n", "-14.164 6.627 33.77 100.62151595956006\n", "-14.314 7.706 34.965 100.86288015915467\n", "-14.46 8.179 33.426 100.48076505481036\n", "-16.366 11.224 36.28 102.50617125324699\n", "-15.391 11.009 36.216 101.60644732003969\n", "-16.768 12.621 36.344 102.67741417663379\n", "-17.553 12.694 36.959 103.58662419926618\n", "-17.199 13.087 34.946 102.61808213468034\n", "-16.394 13.088 34.02 101.60006811513465\n", "-15.603 13.446 36.917 101.62152573643046\n", "-15.301 13.018 37.769 101.65987488188247\n", "-14.853 13.438 36.255 100.71886620191867\n", "-15.976 14.909 37.212 101.8551410877232\n", "-16.414 15.282 36.394 101.97741460245008\n", "-16.953 15.024 38.387 103.119471628786\n", "-17.186 15.98 38.567 103.2738333848415\n", "-16.556 14.642 39.222 103.05811634703983\n", "-17.802 14.531 38.197 103.92704057655061\n", "-14.715 15.698 37.559 100.66776467668286\n", "-14.933 16.654 37.755 100.81641549370815\n", "-14.062 15.681 36.802 99.8226115567009\n", "-14.263 15.315 38.364 100.54328465392406\n", "-18.469 13.473 34.802 103.72810157811622\n", "-19.077 13.385 35.591 104.53569431538683\n", "-19.028 14.017 33.561 103.85313716494075\n", "-18.512 13.619 32.802 103.22143030398288\n", "-18.836 15.54 33.535 103.4603590076895\n", "-19.755 16.299 33.838 104.32721457510499\n", "-20.505 13.599 33.414 105.28614310059989\n", "-21.023 14.03 34.153 105.9117244737333\n", "-20.836 13.938 32.533 105.3346251619096\n", "-20.774 12.085 33.469 105.78257687823643\n", "-20.455 11.753 34.356 105.76011789422324\n", "-22.273 11.839 33.289 107.20734479502791\n", "-22.482 10.862 33.32 107.57120319583676\n", "-22.591 12.194 32.41 107.24145886736156\n", "-22.799 12.289 34.011 107.82282625678108\n", "-20.016 11.308 32.393 104.91381986182753\n", "-20.21 10.329 32.454 105.27920171619844\n", "-19.028 11.432 32.49 103.97416889304765\n", "-20.276 11.617 31.478 104.89085215594349\n", "-17.609 15.967 33.248 102.15770935666089\n", "-16.934 15.277 32.987 101.53128579408417\n", "-17.16 17.365 33.282 101.57336336855248\n", "-17.804 17.82 33.898 102.30483689933726\n", "-17.281 18.1 31.934 101.26497457660274\n", "-17.009 19.295 31.868 100.86991787941537\n", "-15.722 17.415 33.834 100.33897644484918\n", "-15.436 18.373 33.873 99.9741548751476\n", "-15.729 17.031 34.757 100.643684998116\n", "-14.684 16.642 33.004 99.21239715378314\n", "-15.031 16.087 31.934 99.33355701373027\n", "-13.508 16.601 33.425 98.20767376839754\n", "-17.694 17.409 30.863 101.47416393841341\n", "-18.049 16.488 31.022 101.95961696671874\n", "-17.67 17.891 29.473 101.07507959432928\n", "-17.945 17.081 28.956 101.31426634487364\n", "-16.266 18.269 28.954 99.55856271561977\n", "-16.159 18.894 27.901 99.16028356655701\n", "-18.703 19.016 29.254 101.9152329732901\n", "-18.434 19.811 29.798 101.70561137911713\n", "-18.711 19.262 28.285 101.68887269018178\n", "-20.113 18.638 29.649 103.4071152725962\n", "-20.637 17.592 29.292 103.9418614803487\n", "-20.795 19.492 30.376 104.15472404072702\n", "-21.739 19.286 30.636 105.14748525761327\n", "-20.371 20.349 30.67 103.74024313158321\n", "-15.202 17.879 29.665 98.73343832258654\n", "-15.374 17.402 30.527 99.15705769132119\n", "-13.798 18.096 29.28 97.2633607120379\n", "-13.811 18.71 28.491 97.03047672252261\n", "-13.17 16.76 28.881 96.7174204680832\n", "-12.575 16.643 27.814 95.91554787937147\n", "-13.004 18.765 30.429 96.70321510167074\n", "-13.055 18.163 31.226 97.0146807292587\n", "-13.615 20.128 30.829 97.26356391270062\n", "-13.454 20.779 30.087 96.8711074108271\n", "-14.599 20.009 30.961 98.25594466494127\n", "-11.525 18.939 30.029 95.16147704822576\n", "-11.003 19.371 30.765 94.80078007063021\n", "-11.439 19.512 29.214 94.82436830266784\n", "-11.101 18.055 29.829 94.79737288553939\n", "-13.027 20.717 32.118 96.97870379109013\n", "-13.451 21.596 32.336 97.37703094672787\n", "-12.042 20.865 32.028 95.99636475408848\n", "-13.176 20.103 32.893 97.38010373274409\n", "-13.325 15.743 29.728 97.19452493324918\n", "-13.799 15.924 30.59 97.83523761917277\n", "-12.851 14.381 29.485 96.87051137472125\n", "-12.196 14.439 28.731 96.05620577037175\n", "-14.002 13.467 29.073 98.01753669114521\n", "-13.854 12.636 28.173 97.80405127600798\n", "-12.187 13.848 30.76 96.62423900864627\n", "-12.875 13.794 31.484 97.4730146450801\n", "-11.822 12.935 30.577 96.37324148849616\n", "-11.058 14.709 31.255 95.54338429739653\n", "-11.164 15.731 32.168 95.74217172176532\n", "-12.002 16.024 32.628 96.62672541797117\n", "-9.747 14.641 30.873 94.202758208027\n", "-9.363 14.001 30.207 93.76305881315946\n", "-9.945 16.265 32.332 94.5533289789418\n", "-9.738 17.036 32.934 94.42505598092065\n", "-9.037 15.62 31.574 93.56943049949594\n", "-15.154 13.631 29.73 99.25161940240572\n", "-15.206 14.355 30.418 99.35829677485418\n", "-16.339 12.815 29.502 100.46279349590075\n", "-16.216 12.413 28.595 100.2051190858032\n", "-17.608 13.67 29.497 101.55281625833918\n", "-17.804 14.515 30.372 101.82246128433549\n", "-16.43 11.714 30.567 100.97631529225059\n", "-16.493 12.149 31.465 101.18227501889842\n", "-17.258 11.179 30.397 101.81888360711876\n", "-15.253 10.755 30.595 100.02354819741198\n", "-15.15 9.726 29.64 99.88872155053342\n", "-15.868 9.608 28.954 100.4412890648064\n", "-14.241 10.914 31.561 99.26871459326951\n", "-14.316 11.636 32.248 99.38973005798938\n", "-14.038 8.863 29.648 98.9977634393828\n", "-13.971 8.128 28.973 98.9278017192336\n", "-13.124 10.059 31.561 98.36386931693973\n", "-12.402 10.18 32.242 97.8328711885734\n", "-13.021 9.034 30.604 98.22561183316701\n", "-12.226 8.428 30.603 97.59439941922898\n", "-18.508 13.415 28.546 102.24855884558959\n", "-18.269 12.754 27.835 101.96734685672664\n", "-19.83 14.051 28.486 103.42146493837728\n", "-19.93 14.551 29.346 103.634985839725\n", "-20.935 13.001 28.39 104.6213854477181\n", "-20.886 12.11 27.546 104.53756240222936\n", "-19.908 15.04 27.323 103.12253839971163\n", "-19.159 15.702 27.362 102.31828389882229\n", "-19.888 14.564 26.444 102.99330518533716\n", "-21.122 15.754 27.402 104.22706025308398\n", "-20.939 16.693 27.42 103.9414519862023\n", "-21.934 13.079 29.27 105.7613423231759\n", "-21.888 13.783 29.979 105.77087131625606\n", "-23.094 12.186 29.25 107.01062699096757\n", "-22.834 11.347 28.771 106.79089554358086\n", "-23.337 11.969 30.195 107.48235175134566\n", "-24.278 12.84 28.547 107.91143475091043\n", "-24.804 13.837 29.039 108.38171256720388\n", "-24.73 12.268 27.431 108.21277457860509\n", "-24.266 11.445 27.102 107.82722291703519\n", "-25.871 12.777 26.656 109.09939926965683\n", "-26.329 13.444 27.244 109.56011956912057\n", "-26.825 11.628 26.338 110.14018363885181\n", "-26.484 10.733 25.57 109.81484938750314\n", "-25.408 13.488 25.365 108.31680744002752\n", "-24.943 12.798 24.811 107.86693923997287\n", "-26.61 14.075 24.607 109.28207305409245\n", "-26.315 14.536 23.77 108.79797648853584\n", "-27.098 14.742 25.17 109.76710279951821\n", "-27.257 13.357 24.351 109.96967597478861\n", "-24.436 14.64 25.657 107.26539321701105\n", "-24.147 15.088 24.811 106.77833170170808\n", "-23.617 14.308 26.124 106.59527055174634\n", "-24.864 15.331 26.24 107.7008119468001\n", "-28.046 11.671 26.891 111.420007229402\n", "-28.284 12.477 27.433 111.63226241100732\n", "-29.064 10.608 26.754 112.54912199124432\n", "-29.796 10.841 27.394 113.33906067195014\n", "-28.514 9.241 27.199 112.32330309868918\n", "-28.163 9.078 28.362 112.23195062013312\n", "-29.669 10.606 25.33 112.89139481820568\n", "-28.935 10.427 24.675 112.09828632945286\n", "-30.35 9.875 25.277 113.66333309823357\n", "-30.351 11.921 24.932 113.28959221834987\n", "-31.111 12.103 25.556 114.10711228052351\n", "-29.689 12.668 24.987 112.54483140953207\n", "-30.884 11.817 23.497 113.60222548436275\n", "-30.122 11.654 22.871 112.78933446917753\n", "-31.532 11.058 23.438 114.34085849336621\n", "-31.591 13.121 23.108 114.05287107740865\n", "-32.362 13.281 23.724 114.8776611095473\n", "-30.947 13.884 23.174 113.33010018525528\n", "-32.111 13.074 21.719 114.37658276500481\n", "-32.569 13.93 21.479 114.68259659163634\n", "-32.771 12.331 21.608 115.11248846671677\n", "-31.37 12.928 21.064 113.5835776201824\n", "-28.434 8.28 26.283 112.25066840780948\n", "-28.795 8.498 25.376 112.40564857692873\n", "-27.876 6.939 26.455 111.99232435752015\n", "-27.972 6.756 27.433 112.29804688417337\n", "-26.377 6.858 26.123 110.50312358028617\n", "-25.826 5.761 26.09 110.1876402959969\n", "-28.685 5.932 25.61 112.82480041196615\n", "-28.287 5.024 25.744 112.64969750514203\n", "-29.628 5.935 25.942 113.79057469755568\n", "-28.712 6.222 24.097 112.54745264998226\n", "-28.505 7.393 23.688 112.05702921726952\n", "-29.005 5.283 23.332 112.9044389782793\n", "-25.696 7.98 25.857 109.58325776321855\n", "-26.158 8.856 25.995 109.8936454122803\n", "-24.308 7.997 25.373 108.15415377598771\n", "-24.079 7.028 25.282 108.10584698340789\n", "-23.329 8.602 26.37 107.27375142130529\n", "-23.625 9.613 27.005 107.4954423685023\n", "-24.204 8.702 24.013 107.69303833581816\n", "-24.43 9.669 24.129 107.75728902955939\n", "-23.268 8.616 23.672 106.7467484891226\n", "-25.164 8.086 22.991 108.5788650981396\n", "-25.02 7.097 22.963 108.62592634817895\n", "-26.105 8.278 23.271 109.49884408978936\n", "-24.938 8.657 21.594 108.04998529384443\n", "-25.137 9.637 21.587 108.06680220123107\n", "-23.991 8.507 21.311 107.11740197558937\n", "-25.831 7.987 20.631 108.91487926816978\n", "-26.791 7.904 20.899 109.89984651945606\n", "-25.504 7.485 19.455 108.54681391455026\n", "-24.293 7.562 18.972 107.29591934458644\n", "-23.573 8.014 19.498 106.5693648287349\n", "-24.086 7.169 18.076 107.07201960362939\n", "-26.401 6.874 18.736 109.45746156384223\n", "-27.338 6.785 19.075 110.4255886060835\n", "-26.153 6.494 17.845 109.19636803941785\n", "-22.134 8.02 26.426 106.24240157771284\n", "-22.047 7.11 26.02 106.26328370608542\n", "-20.939 8.6 27.031 105.09627982473974\n", "-21.223 9.399 27.562 105.32580286425544\n", "-19.979 9.021 25.924 103.8809675012704\n", "-19.391 8.172 25.258 103.35539529216652\n", "-20.28 7.565 27.95 104.84851114822756\n", "-20.95 7.289 28.639 105.68777213566383\n", "-20.026 6.773 27.395 104.65502706989281\n", "-19.022 8.068 28.675 103.69510139828206\n", "-18.404 8.459 27.993 102.88274678973146\n", "-19.376 9.137 29.707 104.05332745760704\n", "-18.557 9.464 30.179 103.31576981758398\n", "-20.004 8.776 30.396 104.87644368970565\n", "-19.815 9.923 29.272 104.23463129401858\n", "-18.346 6.909 29.401 103.44300182709316\n", "-17.524 7.217 29.88 102.70345492728079\n", "-18.077 6.192 28.758 103.19935776931946\n", "-18.961 6.502 30.076 104.26462120968932\n", "-19.811 10.322 25.736 103.44683724503132\n", "-20.411 10.953 26.228 104.01016293132128\n", "-18.798 10.882 24.849 102.20727959397021\n", "-18.75 10.29 24.045 102.12414998422263\n", "-17.464 10.877 25.589 101.05336876621183\n", "-17.34 11.476 26.657 101.0373363366236\n", "-19.188 12.294 24.373 102.26729687441632\n", "-19.142 12.889 25.175 102.27255527755233\n", "-20.64 12.389 23.845 103.57464235516335\n", "-21.262 12.215 24.609 104.33685819977521\n", "-20.786 13.316 23.5 103.51934528869471\n", "-18.19 12.785 23.312 101.03876526363531\n", "-18.429 13.702 22.992 101.08026602655931\n", "-18.181 12.175 22.519 100.99868744691683\n", "-17.262 12.821 23.683 100.19242875087916\n", "-20.994 11.407 22.718 103.89537846314435\n", "-21.943 11.523 22.426 104.75634826109585\n", "-20.878 10.46 23.018 103.99011540045524\n", "-20.408 11.55 21.921 103.1794480795473\n", "-16.485 10.179 25.026 100.12782990258002\n", "-16.72 9.637 24.219 100.3102176400789\n", "-15.096 10.13 25.476 98.88153443894365\n", "-15.071 10.404 26.437 98.99519625214144\n", "-14.304 11.104 24.612 97.77712411909035\n", "-14.19 10.891 23.404 97.48929560726141\n", "-14.536 8.698 25.354 98.59696932969085\n", "-14.548 8.465 24.382 98.47515610548683\n", "-13.099 8.629 25.888 97.33586357042299\n", "-12.732 7.702 25.811 97.16355918758842\n", "-13.061 8.895 26.851 97.44127122528728\n", "-12.497 9.242 25.376 96.5335527368593\n", "-15.396 7.675 26.114 99.77901896691509\n", "-15.019 6.753 26.024 99.59798612923858\n", "-16.331 7.66 25.761 100.61028532411584\n", "-15.439 7.896 27.088 99.96965337541187\n", "-13.771 12.159 25.227 97.1945852709913\n", "-13.907 12.255 26.213 97.50387482556782\n", "-12.995 13.184 24.527 96.14236436139898\n", "-13.443 13.309 23.642 96.39611749961715\n", "-11.557 12.703 24.313 94.78808841832395\n", "-10.966 12.108 25.222 94.49335657600484\n", "-13.019 14.512 25.301 96.11023712903845\n", "-12.529 14.384 26.163 95.82655308942296\n", "-12.553 15.206 24.752 95.45279832461696\n", "-14.435 15.017 25.619 97.4743890363002\n", "-14.816 14.299 26.201 98.06113127534272\n", "-14.275 15.839 26.165 97.31664674658698\n", "-15.511 15.362 24.202 98.20813051881191\n", "-14.751 16.894 23.595 97.1638904377547\n", "-15.233 17.238 22.789 97.45701908533833\n", "-13.795 16.744 23.341 96.20359162214267\n", "-14.775 17.608 24.295 97.22949709321755\n", "-10.98 12.969 23.137 93.97075861671013\n", "-11.518 13.468 22.457 94.29481846846092\n", "-9.61 12.58 22.773 92.6439594469062\n", "-9.568 12.647 21.776 92.42237074431709\n", "-9.298 11.115 23.128 92.66902463067149\n", "-8.464 10.817 23.994 92.08091047551603\n", "-8.609 13.565 23.4 91.62062421201898\n", "-8.778 13.623 24.384 91.96060664219218\n", "-7.679 13.234 23.241 90.74542036378475\n", "-8.728 14.952 22.813 91.41339800051193\n", "-8.652 15.149 21.618 91.1052499584958\n", "-8.873 15.969 23.63 91.55767293351224\n", "-8.92 16.899 23.267 91.41323358792205\n", "-8.936 15.813 24.616 91.82927179282214\n", "-10.004 10.183 22.484 93.41768208428209\n", "-10.664 10.484 21.796 93.8826796432654\n", "-9.868 8.744 22.727 93.62204491464603\n", "-10.204 8.601 23.658 94.14018603125872\n", "-8.399 8.316 22.649 92.28902994939321\n", "-7.71 8.569 21.665 91.40453959733071\n", "-10.732 7.932 21.748 94.46481254414259\n", "-10.509 8.255 20.828 94.03607697580753\n", "-10.44 6.431 21.867 94.54297107135991\n", "-11.003 5.905 21.23 95.10627018761697\n", "-10.632 6.101 22.791 94.95820964508545\n", "-9.481 6.235 21.664 93.63756266050498\n", "-12.226 8.133 22.041 95.90754883219569\n", "-12.79 7.606 21.405 96.46420879269158\n", "-12.482 9.096 21.953 95.94020520094794\n", "-12.452 7.838 22.969 96.34214505604491\n", "-7.927 7.62 23.682 92.17816248982183\n", "-8.558 7.418 24.431 92.96841757285104\n", "-6.561 7.131 23.801 91.00951371147964\n", "-6.165 7.094 22.884 90.4709283913899\n", "-6.555 5.713 24.379 91.45883921196463\n", "-7.511 5.303 25.033 92.59659431102203\n", "-5.78 8.114 24.683 90.21011509803098\n", "-5.793 9.034 24.292 89.9406440048102\n", "-4.825 7.833 24.774 89.38365166516749\n", "-6.175 8.164 25.6 90.7632879748194\n", "-5.453 4.984 24.204 90.56690879123566\n", "-4.681 5.406 23.73 89.63540318423296\n", "-5.304 3.594 24.667 90.88933725140699\n", "-5.982 3.055 24.167 91.57843826469197\n", "-5.611 3.425 26.167 91.53410458402922\n", "-6.252 2.463 26.582 92.4912130421047\n", "-3.863 3.157 24.356 89.5956550788039\n", "-3.637 3.45 23.427 89.12038636024867\n", "-3.249 3.605 25.006 89.02547316920027\n", "-3.643 1.643 24.45 89.8498342179884\n", "-2.674 1.451 24.292 88.97301090780282\n", "-3.897 1.341 25.369 90.36434629874772\n", "-4.469 0.852 23.431 90.66397774750453\n", "-4.659 -0.357 23.672 91.26225581805438\n", "-4.95 1.454 22.441 90.7536427147693\n", "-5.258 4.431 26.979 91.10975923028224\n", "-4.752 5.195 26.579 90.3455365748635\n", "-5.563 4.492 28.42 91.71252134795989\n", "-5.179 3.642 28.781 91.66794194809873\n", "-7.063 4.472 28.749 93.19959365254765\n", "-7.437 4.222 29.896 93.89296674405382\n", "-4.893 5.735 29.038 90.91669308218376\n", "-4.988 5.688 30.032 91.26794807050281\n", "-3.923 5.73 28.794 89.95017912155595\n", "-5.517 7.055 28.546 91.06069514889505\n", "-5.386 7.122 27.557 90.68753062025671\n", "-6.495 7.043 28.753 92.03433979770811\n", "-4.897 8.294 29.202 90.3531165151485\n", "-4.986 8.228 30.196 90.70565028155633\n", "-3.929 8.356 28.957 89.36633932863089\n", "-5.642 9.539 28.695 90.66107479508501\n", "-5.523 9.617 27.705 90.29513797541924\n", "-6.615 9.453 28.908 91.65243050241493\n", "-5.149 10.796 29.314 90.0921661633241\n", "-5.651 11.588 28.966 90.32895487051756\n", "-4.179 10.936 29.117 89.09598096996295\n", "-5.26 10.774 30.308 90.45749245363812\n", "-7.929 4.792 27.788 93.70707068305998\n", "-7.568 5.071 26.898 93.09859480142543\n", "-9.377 4.756 27.967 95.11919897160614\n", "-9.506 5.042 28.916 95.38755087012142\n", "-9.947 3.345 27.828 95.98602294605189\n", "-11.081 3.15 28.237 97.1929885176909\n", "-10.086 5.756 27.041 95.3404279726077\n", "-9.873 5.517 26.094 94.9970895185742\n", "-11.072 5.682 27.19 96.32397446638089\n", "-9.699 7.2 27.246 94.68237643827915\n", "-9.769 8.205 26.308 94.32660077093841\n", "-10.066 8.098 25.359 94.43952173745905\n", "-9.281 7.783 28.411 94.4180481581779\n", "-9.173 7.32 29.291 94.62626285022567\n", "-9.372 9.354 26.881 93.82829663806116\n", "-9.335 10.241 26.421 93.51666562704212\n", "-9.031 9.135 28.164 93.83508427555228\n", "-9.184 2.343 27.366 95.43808766944147\n", "-8.291 2.552 26.967 94.45761073095169\n", "-9.632 0.944 27.434 96.26444002330248\n", "-10.432 0.909 26.835 96.89423967914708\n", "-10.036 0.552 28.855 97.07071244201312\n", "-9.454 1.041 29.831 96.61963946838138\n", "-8.551 -0.014 26.924 95.42847679807112\n", "-7.683 0.213 27.365 94.64945839253386\n", "-8.811 -0.95 27.161 96.00454600173889\n", "-8.372 0.079 25.408 94.92160360002353\n", "-9.265 0.02 24.962 95.68615759868298\n", "-7.94 0.951 25.176 94.2135066219276\n", "-7.487 -1.071 24.93 94.35654282030472\n", "-6.565 -0.975 25.305 93.54442522138878\n", "-7.875 -1.947 25.218 95.05094548188355\n", "-7.396 -1.062 23.467 93.99505179529399\n", "-7.863 -0.311 23.0 94.11486297604645\n", "-6.772 -1.925 22.698 93.55532601621353\n", "-6.272 -3.027 23.175 93.54086496820521\n", "-6.358 -3.234 24.149 93.86799945668385\n", "-5.802 -3.667 22.567 93.21929454249263\n", "-6.647 -1.69 21.425 93.15117427601221\n", "-7.026 -0.852 21.032 93.17508560232181\n", "-6.172 -2.347 20.84 92.83313941691296\n", "-11.035 -0.316 28.95 98.27315169465156\n", "-11.444 -0.65 28.101 98.56220603253561\n", "-11.577 -0.816 30.211 99.21679336180947\n", "-11.039 -1.615 30.481 99.02489524356993\n", "-11.472 -0.096 30.897 99.07498985112235\n", "-13.046 -1.202 30.093 100.66286096669414\n", "-13.643 -1.11 29.016 100.94406993974435\n", "-13.628 -1.607 31.219 101.5894133214677\n", "-13.076 -1.644 32.052 101.29727906019981\n", "-15.03 -2.0 31.3 103.02095022372876\n", "-15.364 -2.172 30.373 103.16284834183283\n", "-15.863 -0.846 31.858 103.5924079264499\n", "-15.75 -0.464 33.024 103.67123416358078\n", "-15.142 -3.312 32.092 103.71290385000314\n", "-14.619 -3.232 32.941 103.42096515213925\n", "-16.103 -3.488 32.307 104.70338864143797\n", "-14.596 -4.48 31.285 103.38184350261898\n", "-14.735 -4.55 30.078 103.25009429535645\n", "-13.965 -5.447 31.899 103.26730929970044\n", "-13.609 -6.222 31.377 103.07446248707774\n", "-13.839 -5.411 32.89 103.38848081387016\n", "-16.701 -0.274 31.001 104.00554370320842\n", "-16.738 -0.643 30.072 103.92878041235738\n", "-17.569 0.85 31.315 104.58500045895683\n", "-17.139 1.333 32.077 104.23965474808519\n", "-18.935 0.345 31.748 106.09825246911468\n", "-19.526 -0.474 31.061 106.71037262609477\n", "-17.682 1.793 30.114 104.16695711212842\n", "-17.828 1.248 29.288 104.26215632241642\n", "-18.462 2.403 30.254 104.77780926322139\n", "-16.447 2.641 29.911 102.74402918904825\n", "-16.475 4.01 30.235 102.50808633956639\n", "-17.313 4.421 30.595 103.2850271917474\n", "-15.263 2.058 29.426 101.67118704923239\n", "-15.248 1.09 29.177 101.85811587693932\n", "-15.327 4.802 30.054 101.19527682653968\n", "-15.359 5.782 30.253 101.04649613420546\n", "-14.102 2.836 29.292 100.34935292765967\n", "-13.251 2.412 28.982 99.59023787500459\n", "-14.133 4.215 29.593 100.10287441427442\n", "-13.028 4.994 29.463 98.8435993375393\n", "-12.248 4.44 29.432 98.23558492216554\n", "-19.467 0.837 32.861 106.73511012783\n", "-18.919 1.462 33.417 106.20147119979082\n", "-20.825 0.503 33.31 108.2005291345657\n", "-21.178 -0.183 32.674 108.55476425288758\n", "-21.69 1.75 33.246 108.67862483947798\n", "-21.364 2.753 33.882 108.28806250921659\n", "-20.824 -0.117 34.713 108.7168036827794\n", "-20.535 0.571 35.378 108.44327109138675\n", "-19.886 -1.168 34.754 108.14061544581665\n", "-20.347 -2.007 34.763 108.80241213318756\n", "-22.183 -0.69 35.105 110.23234220953483\n", "-22.153 -1.087 36.022 110.55131652314229\n", "-22.466 -1.407 34.469 110.52485282053082\n", "-22.886 0.021 35.1 110.69888027437314\n", "-22.778 1.706 32.483 109.52694679392827\n", "-22.864 0.976 31.805 109.63080139267431\n", "-23.85 2.687 32.602 110.32925864882803\n", "-23.424 3.54 32.903 109.80184715204021\n", "-24.852 2.192 33.643 111.6387379631282\n", "-25.251 1.032 33.606 112.28400302803601\n", "-24.523 2.955 31.254 110.5932330163107\n", "-25.32 3.509 31.495 111.27588120972126\n", "-23.858 3.521 30.767 109.72492844837036\n", "-24.994 1.501 30.285 111.17270914662464\n", "-25.246 3.07 34.559 112.03156138338873\n", "-24.853 3.988 34.513 111.44428680286845\n", "-26.203 2.807 35.625 113.26120422280526\n", "-26.558 1.881 35.496 113.77534132666884\n", "-27.361 3.8 35.524 114.10456211738425\n", "-27.144 4.997 35.332 113.59712175050916\n", "-25.488 2.893 36.979 112.92730980148247\n", "-24.798 2.17 37.025 112.46172626276017\n", "-25.042 3.785 37.051 112.32946474990432\n", "-26.41 2.735 38.162 114.14817907439433\n", "-27.064 3.759 38.811 114.71391854086407\n", "-27.012 4.731 38.581 114.39446026359843\n", "-26.762 1.569 38.792 114.92068122840205\n", "-26.449 0.651 38.547 114.78048775815512\n", "-27.784 3.218 39.808 115.78719209394447\n", "-28.354 3.738 40.444 116.39033113192865\n", "-27.634 1.887 39.835 115.9539333485501\n", "-28.587 3.313 35.665 115.4019766468495\n", "-28.692 2.32 35.714 115.73435371141967\n", "-29.788 4.127 35.753 116.38321656922874\n", "-29.503 5.05 36.012 115.98875686893103\n", "-30.716 3.579 36.844 117.6520296042529\n", "-30.703 2.389 37.148 117.97659524244628\n", "-30.468 4.169 34.379 116.68210352491936\n", "-29.847 4.529 33.683 115.85331687094677\n", "-31.28 4.753 34.398 117.33714723820415\n", "-30.754 3.255 34.093 117.07978460434576\n", "-31.543 4.454 37.414 118.39778945571577\n", "-31.424 5.425 37.205 118.03705033166493\n", "-32.618 4.069 38.331 119.73118873125748\n", "-32.508 3.095 38.528 119.88307656212363\n", "-33.96 4.312 37.652 120.77096790619838\n", "-34.249 5.435 37.229 120.71612231181051\n", "-32.51 4.844 39.644 119.82904426306669\n", "-31.628 4.684 40.087 119.1557210292481\n", "-32.636 5.825 39.497 119.71698387029302\n", "-33.524 4.4 40.518 121.11332136887337\n", "-34.343 4.299 40.032 121.76821986462642\n", "-34.769 3.264 37.521 121.7159195709419\n", "-34.462 2.384 37.882 121.70472032341226\n", "-36.078 3.324 36.881 122.78112717351962\n", "-36.173 4.236 36.482 122.58908168348435\n", "-37.188 3.151 37.914 124.12505388518467\n", "-37.161 2.228 38.726 124.49904380355697\n", "-36.145 2.286 35.764 122.79153158096857\n", "-35.383 2.443 35.136 121.88737375544687\n", "-36.061 1.375 36.169 123.00703242497967\n", "-37.431 2.333 34.969 123.81588898844929\n", "-38.457 1.409 35.235 125.04914657045843\n", "-38.349 0.738 35.969 125.26444603717367\n", "-37.601 3.302 33.962 123.54886126549285\n", "-36.872 3.961 33.776 122.67884876375389\n", "-39.636 1.429 34.467 125.99175850427677\n", "-40.351 0.75 34.634 126.85597233082879\n", "-38.794 3.346 33.216 124.51610779734483\n", "-38.919 4.045 32.511 124.34704129170102\n", "-39.813 2.403 33.464 125.73588377627128\n", "-40.953 2.423 32.724 126.66537533596147\n", "-40.73 2.428 31.793 126.26173950171919\n", "-38.171 4.053 37.895 124.87019598767353\n", "-38.133 4.792 37.223 124.52407457596303\n", "-39.306 4.001 38.824 126.1910276287502\n", "-38.968 3.542 39.645 126.17410828692232\n", "-40.437 3.189 38.207 127.26691900882962\n", "-40.995 3.585 37.188 127.46928624966878\n", "-39.783 5.403 39.222 126.48068977120579\n", "-40.081 5.893 38.403 126.46614716199745\n", "-38.706 6.116 39.793 125.47992272072851\n", "-37.964 5.525 39.922 124.91906868849127\n", "-40.891 5.359 40.275 127.8139029605152\n", "-41.188 6.282 40.521 127.9964388332738\n", "-40.576 4.905 41.108 127.82149959220474\n", "-41.688 4.859 39.936 128.5719354680484\n", "-40.802 2.081 38.846 127.99746245140955\n", "-40.288 1.826 39.665 127.77459795280124\n", "-41.899 1.211 38.437 129.11467813536925\n", "-42.434 1.696 37.745 129.35069885392966\n", "-42.81 0.922 39.638 130.33717514585007\n", "-42.339 0.494 40.691 130.25641403401215\n", "-41.32 -0.063 37.817 128.69228002875695\n", "-40.621 0.19 37.148 127.8144191709214\n", "-40.906 -0.617 38.539 128.6037634402664\n", "-42.367 -0.897 37.119 129.701717390326\n", "-42.938 -2.001 37.775 130.65066047670788\n", "-42.656 -2.229 38.707 130.6646942176807\n", "-42.803 -0.537 35.829 129.73569891899453\n", "-42.41 0.262 35.373 129.08329485258733\n", "-43.905 -2.786 37.122 131.59376580978295\n", "-44.284 -3.595 37.572 132.25051887232806\n", "-43.789 -1.3 35.183 130.6998669203607\n", "-44.101 -1.045 34.268 130.74103737159194\n", "-44.336 -2.425 35.829 131.62152442134985\n", "-45.301 -3.149 35.224 132.57389060067598\n", "-46.071 -2.599 35.081 133.14257593271958\n", "-44.111 1.213 39.508 131.47224358395957\n", "-44.432 1.513 38.61 131.49212567298468\n", "-45.105 1.122 40.596 132.70613316648178\n", "-45.883 1.658 40.267 133.24820420928756\n", "-44.655 1.805 41.908 132.4853622744792\n", "-44.815 1.269 43.003 133.04103805217395\n", "-45.547 -0.342 40.796 133.4840669743022\n", "-44.741 -0.877 41.05 132.9082766459636\n", "-46.211 -0.366 41.543 134.3075336569025\n", "-46.191 -1.009 39.568 133.92829425106555\n", "-45.538 -0.951 38.813 133.1144594512557\n", "-46.527 -2.458 39.915 134.6574618689956\n", "-46.949 -2.924 39.137 134.97255960009056\n", "-47.165 -2.504 40.684 135.4602519117693\n", "-45.704 -2.966 40.168 134.0650283892112\n", "-47.482 -0.314 39.13 134.89051996711999\n", "-47.879 -0.766 38.332 135.17375771946269\n", "-47.311 0.641 38.888 134.46890302594127\n", "-48.163 -0.328 39.862 135.71601264405024\n", "-44.046 2.99 41.792 131.6453458235421\n", "-43.908 3.356 40.872 131.20087618990965\n", "-43.567 3.789 42.928 131.35000504377606\n", "-43.421 4.718 42.589 130.94661156746287\n", "-44.299 3.793 43.61 132.22865597517054\n", "-42.274 3.291 43.588 130.41395556457906\n", "-41.765 3.96 44.485 130.0663690774829\n", "-41.709 2.159 43.148 129.9839091464786\n", "-42.2 1.634 42.453 130.35868327810005\n", "-40.416 1.634 43.616 129.01433500584344\n", "-40.182 2.147 44.442 128.92961714827203\n", "-39.329 1.873 42.575 127.65108110000479\n", "-39.589 1.81 41.378 127.57586781205919\n", "-40.541 0.143 43.955 129.54768645560597\n", "-40.932 -0.337 43.169 129.7941156562962\n", "-39.631 -0.222 44.15 128.83782905653138\n", "-41.442 -0.086 45.176 130.7931587087031\n", "-41.08 0.426 45.955 130.57801674860895\n", "-42.367 0.232 44.968 131.52414365431162\n", "-41.488 -1.575 45.53 131.27457542875544\n", "-41.855 -2.091 44.756 131.50703464453906\n", "-40.564 -1.897 45.738 130.55557612756337\n", "-42.387 -1.779 46.752 132.52046526103052\n", "-42.02 -1.267 47.529 132.30303607627454\n", "-43.312 -1.458 46.547 133.24225837923942\n", "-42.463 -3.211 47.13 133.04045555018217\n", "-43.051 -3.34 47.928 133.85794600246936\n", "-41.557 -3.571 47.354 132.36144602186846\n", "-42.836 -3.76 46.382 133.2908622411904\n", "-38.111 2.147 43.029 126.58389065753981\n", "-37.98 2.248 44.015 126.72830571738895\n", "-36.954 2.307 42.152 125.21757588294065\n", "-37.325 2.591 41.268 125.25787083053903\n", "-36.215 0.983 41.972 124.76103654987801\n", "-35.945 0.289 42.952 124.94655627507305\n", "-36.019 3.395 42.687 124.27262249586592\n", "-35.862 3.239 43.662 124.4447125192549\n", "-35.149 3.346 42.197 123.32694281867202\n", "-36.629 4.792 42.492 124.51282873664061\n", "-37.029 4.839 41.576 124.61880916218064\n", "-37.346 4.923 43.176 125.35906763373761\n", "-35.626 5.932 42.631 123.39866970919905\n", "-34.425 5.762 42.786 122.34949055880861\n", "-36.082 7.16 42.534 123.58004996357623\n", "-35.45 7.934 42.587 122.86883677320299\n", "-37.061 7.321 42.407 124.43742945753901\n", "-35.872 0.665 40.728 124.16384484220839\n", "-36.157 1.284 39.996 124.09380790353723\n", "-35.112 -0.519 40.354 123.62379561395127\n", "-34.853 -0.965 41.211 123.72536872444552\n", "-33.851 -0.116 39.578 122.1413741203201\n", "-33.938 0.74 38.69 121.78739125623801\n", "-35.984 -1.466 39.528 124.4408196573777\n", "-36.331 -0.969 38.733 124.43829573728499\n", "-35.421 -2.233 39.222 124.0224754832768\n", "-37.168 -2.024 40.29 125.88354077082516\n", "-37.015 -3.195 41.055 126.23767325960978\n", "-36.134 -3.667 41.076 125.54618782742867\n", "-38.406 -1.354 40.264 126.87202398086033\n", "-38.513 -0.523 39.719 126.63509719663028\n", "-38.103 -3.701 41.791 127.57697390203296\n", "-37.997 -4.537 42.329 127.842252146933\n", "-39.494 -1.853 41.005 128.204378314471\n", "-40.372 -1.375 40.989 128.90835837524267\n", "-39.343 -3.028 41.769 128.55461491910742\n", "-40.395 -3.537 42.465 129.84916553447698\n", "-41.14 -3.657 41.876 130.4101581242811\n", "-32.689 -0.713 39.893 121.28606806224694\n", "-31.455 -0.45 39.167 119.87510392487674\n", "-31.363 0.535 39.022 119.51528490113722\n", "-31.477 -1.091 37.775 119.68171530355002\n", "-32.105 -2.131 37.565 120.47425133197547\n", "-30.336 -1.011 40.049 119.21648524847559\n", "-29.585 -1.365 39.491 118.45300334731914\n", "-29.987 -0.31 40.671 118.89755044154609\n", "-31.016 -2.14 40.826 120.34961509286182\n", "-30.966 -3.001 40.32 120.38309063153346\n", "-30.595 -2.257 41.725 120.25048187013638\n", "-32.462 -1.677 40.963 121.60979323640017\n", "-33.096 -2.443 40.859 122.35991540941829\n", "-32.615 -1.234 41.846 121.89496174986068\n", "-30.766 -0.455 36.845 118.62093276905217\n", "-30.408 0.447 37.087 118.13044773892969\n", "-30.459 -0.951 35.501 118.11993253469119\n", "-30.689 -1.924 35.492 118.57957176512318\n", "-28.976 -0.7 35.255 116.60785567876634\n", "-28.537 0.452 35.298 115.92293959350755\n", "-31.285 -0.22 34.416 118.45496524840145\n", "-31.052 0.751 34.463 118.0142687093387\n", "-32.799 -0.343 34.664 119.96834186150944\n", "-33.087 -1.273 34.436 120.41354296340589\n", "-32.981 -0.165 35.631 120.3270322828582\n", "-30.934 -0.771 33.015 117.9379984356187\n", "-31.462 -0.306 32.304 118.16444394571491\n", "-31.132 -1.749 32.955 118.35777619996077\n", "-29.964 -0.641 32.812 116.94620902791162\n", "-33.623 0.636 33.829 120.3222387466257\n", "-34.6 0.53 34.013 121.31279405734581\n", "-33.477 0.485 32.851 120.00126610165411\n", "-33.372 1.582 34.035 119.9154618971215\n", "-28.22 -1.746 34.94 116.09139980635946\n", "-28.629 -2.657 35.0 116.72835705602988\n", "-26.828 -1.646 34.511 114.6608439267739\n", "-26.724 -0.656 34.411 114.28238474060646\n", "-26.59 -2.338 33.184 114.30696729858596\n", "-27.15 -3.395 32.885 115.05037138140841\n", "-25.81 -2.147 35.54 114.1023045779532\n", "-24.894 -2.023 35.158 113.12109469944144\n", "-25.874 -3.535 35.734 114.59206894894602\n", "-25.889 -3.726 36.672 114.90180832345503\n", "-25.923 -1.422 36.874 114.36086675082521\n", "-25.249 -1.767 37.527 114.00276927338211\n", "-26.831 -1.547 37.274 115.34236784893919\n", "-25.769 -0.44 36.762 113.93446068683521\n", "-25.747 -1.731 32.348 113.16274291921347\n", "-25.513 -0.774 32.52 112.73034468145654\n", "-25.146 -2.398 31.189 112.52218320846782\n", "-25.305 -3.374 31.337 112.97543011203807\n", "-23.657 -2.124 31.157 111.04634894043116\n", "-23.208 -1.024 31.48 110.39902724662024\n", "-25.818 -2.009 29.861 112.76389732090674\n", "-26.112 -1.055 29.921 112.79855500404247\n", "-25.147 -2.106 29.126 112.00940433731445\n", "-27.04 -2.871 29.518 114.07827920336103\n", "-27.157 -2.868 28.525 113.99196180871701\n", "-26.863 -3.804 29.83 114.23596347910757\n", "-28.349 -2.392 30.157 115.30905808738531\n", "-28.225 -2.28 31.143 115.36835578701812\n", "-28.626 -1.52 29.754 115.25764348189668\n", "-29.432 -3.368 29.935 116.5478028192724\n", "-29.748 -3.455 28.99 116.68356574085315\n", "-30.045 -4.147 30.818 117.51836680706553\n", "-29.694 -4.247 32.07 117.48257737213632\n", "-28.92 -3.717 32.416 116.68731714286689\n", "-30.199 -4.854 32.684 118.25941224274708\n", "-31.062 -4.852 30.404 118.58550437975123\n", "-31.355 -4.794 29.45 118.65644587631975\n", "-31.548 -5.45 31.041 119.33981525878107\n", "-22.904 -3.142 30.76 110.54222460670853\n", "-23.358 -3.956 30.397 111.12259506509015\n", "-21.445 -3.133 30.827 109.1949897843303\n", "-21.174 -2.264 31.241 108.78637932204565\n", "-20.895 -3.217 29.417 108.4017323016565\n", "-21.342 -4.031 28.612 108.89328305272093\n", "-20.916 -4.257 31.724 109.23883140165863\n", "-21.16 -5.123 31.288 109.62824193609966\n", "-19.389 -4.175 31.874 107.83718208948153\n", "-19.046 -4.91 32.46 107.88568849017926\n", "-19.115 -3.304 32.282 107.4193961256532\n", "-18.937 -4.254 30.986 107.23828637198562\n", "-21.551 -4.174 33.12 110.13036758315118\n", "-21.211 -4.904 33.712 110.18047513057837\n", "-22.546 -4.259 33.067 111.0626898422688\n", "-21.341 -3.3 33.558 109.78624972190278\n", "-19.944 -2.347 29.112 107.19698513484416\n", "-19.603 -1.764 29.849 106.86957610564384\n", "-19.356 -2.17 27.797 106.3263419948227\n", "-19.739 -2.881 27.208 106.77649974128201\n", "-17.846 -2.355 27.915 104.99216433143951\n", "-17.178 -1.567 28.58 104.27640238328132\n", "-19.733 -0.797 27.202 106.17483687296156\n", "-19.404 -0.095 27.834 105.79803394203503\n", "-21.266 -0.629 27.064 107.54679918063576\n", "-21.585 -1.169 26.285 107.84999702364391\n", "-21.707 -0.957 27.9 108.21380211876856\n", "-19.05 -0.602 25.835 105.21925151796127\n", "-19.287 0.285 25.439 105.12918630903599\n", "-19.332 -1.312 25.189 105.56783039354364\n", "-18.055 -0.643 25.923 104.3090390618186\n", "-21.666 0.832 26.842 107.49628367994866\n", "-22.658 0.923 26.755 108.39727403860302\n", "-21.25 1.195 26.008 106.85387134774294\n", "-21.371 1.405 27.607 107.21759455425213\n", "-17.293 -3.357 27.243 104.6418932646003\n", "-17.884 -4.068 26.862 105.33648525083795\n", "-15.848 -3.457 27.04 103.2875135435063\n", "-15.391 -3.206 27.893 102.9582078175412\n", "-15.466 -2.474 25.937 102.4165725358938\n", "-15.818 -2.655 24.764 102.58562596192507\n", "-15.441 -4.9 26.715 103.30323335210761\n", "-15.676 -5.477 27.497 103.86352500757904\n", "-15.957 -5.2 25.913 103.7256034978828\n", "-13.945 -5.072 26.419 101.91833949294896\n", "-13.698 -4.47 25.66 101.3469961518347\n", "-13.426 -4.813 27.233 101.51619856456406\n", "-13.585 -6.521 26.041 102.0018405030027\n", "-12.573 -7.049 26.542 101.35420974483496\n", "-14.26 -7.118 25.161 102.665288242911\n", "-14.773 -1.406 26.328 101.52446690330365\n", "-14.566 -1.296 27.3 101.49253305046632\n", "-14.306 -0.395 25.397 100.61431720684685\n", "-14.96 -0.405 24.641 101.09375819999967\n", "-12.922 -0.761 24.857 99.32196101064456\n", "-11.932 -0.792 25.591 98.5427556241452\n", "-14.328 0.995 26.041 100.36696394232517\n", "-15.274 1.225 26.27 101.2403549282597\n", "-13.78 0.967 26.877 100.02520891755236\n", "-13.776 2.094 25.149 99.3788559503479\n", "-13.14 3.21 25.721 98.59415724068033\n", "-13.068 3.287 26.715 98.70436599765989\n", "-13.878 2.005 23.746 99.2465041500203\n", "-14.374 1.242 23.331 99.85209294751911\n", "-12.606 4.217 24.9 97.67598176624588\n", "-12.176 5.022 25.31 97.14753815202936\n", "-13.292 2.975 22.932 98.29588653651788\n", "-13.312 2.871 21.938 98.18144893002953\n", "-12.676 4.093 23.506 97.5215991357812\n", "-12.286 4.804 22.921 96.87318897403966\n", "-12.859 -0.993 23.545 99.0984077268651\n", "-13.712 -0.95 23.026 99.80017014514553\n", "-11.635 -1.306 22.81 97.92020222609837\n", "-10.904 -1.418 23.484 97.38430401763931\n", "-11.3 -0.134 21.885 97.10371104133971\n", "-12.133 0.324 21.104 97.63637768782698\n", "-11.797 -2.63 22.031 98.35781555626374\n", "-12.492 -2.479 21.328 98.853233705327\n", "-12.308 -3.787 22.924 99.35019040746725\n", "-11.567 -4.069 23.534 98.8563278551252\n", "-13.078 -3.453 23.467 100.05038532159683\n", "-10.465 -3.011 21.353 97.13062599407048\n", "-10.554 -3.867 20.844 97.41908317162506\n", "-9.739 -3.13 22.031 96.59860336982103\n", "-10.173 -2.301 20.712 96.53304589103152\n", "-12.776 -5.019 22.14 100.06711374872366\n", "-13.096 -5.737 22.758 100.70448737767349\n", "-12.032 -5.397 21.589 99.4198202523018\n", "-13.528 -4.787 21.523 100.59549955639169\n", "-10.063 0.339 21.923 95.80476559127943\n", "-9.435 -0.01 22.619 95.43199801429287\n", "-9.58 1.356 20.982 94.9063655873514\n", "-10.365 1.951 20.81 95.45595168977154\n", "-9.126 0.708 19.676 94.47548757746635\n", "-8.472 -0.337 19.679 94.17315147641602\n", "-8.448 2.186 21.588 93.69436241845077\n", "-8.015 2.767 20.899 93.01356373131824\n", "-7.489 1.289 22.068 93.12518519176216\n", "-7.886 0.425 22.178 93.7729313714784\n", "-8.938 3.023 22.768 94.12310070328112\n", "-8.192 3.563 23.159 93.33955356117791\n", "-9.308 2.44 23.492 94.75944757648178\n", "-9.659 3.655 22.484 94.58970134745114\n", "-9.468 1.328 18.55 94.46915257902972\n", "-10.152 2.055 18.606 94.92015247564659\n", "-8.908 1.015 17.237 93.8706384073316\n", "-8.595 0.066 17.269 93.86090822594888\n", "-7.725 1.938 16.965 92.44760821676242\n", "-7.711 3.075 17.433 92.16736362726232\n", "-9.984 1.155 16.149 94.73577893805486\n", "-10.357 2.082 16.192 94.83231721306824\n", "-9.553 1.01 15.259 94.28156367498366\n", "-11.145 0.163 16.288 96.14384825354142\n", "-11.506 0.245 17.217 96.56087151118717\n", "-12.232 0.492 15.266 96.98446158534881\n", "-12.999 -0.145 15.341 97.90722689362619\n", "-11.876 0.436 14.333 96.58198282288471\n", "-12.586 1.417 15.404 97.07168327581425\n", "-10.682 -1.28 16.068 96.1200328807684\n", "-11.445 -1.919 16.161 97.04964775824793\n", "-9.983 -1.538 16.735 95.60904809169475\n", "-10.293 -1.396 15.154 95.70215832466894\n", "-6.748 1.457 16.2 91.57632719212974\n", "-6.797 0.509 15.886 91.87527994515173\n", "-5.606 2.277 15.807 90.2095469171639\n", "-5.12 2.435 16.666 89.79388733093138\n", "-6.048 3.606 15.186 90.19218995567188\n", "-7.069 3.691 14.501 91.08349019443645\n", "-4.719 1.541 14.803 89.48744965636241\n", "-5.29 1.235 14.041 90.05525207893207\n", "-4.026 2.179 14.466 88.60750917388435\n", "-4.009 0.321 15.4 89.24979635270883\n", "-3.478 0.612 16.196 88.7397332033402\n", "-4.697 -0.347 15.684 90.13950492985857\n", "-3.064 -0.334 14.38 88.47428298098832\n", "-2.708 -1.509 14.617 88.55266457312281\n", "-2.71 0.344 13.378 87.83792450303\n", "-5.254 4.647 15.424 89.17180773091907\n", "-4.462 4.517 16.021 88.510212399474\n", "-5.486 5.968 14.854 88.99504717117689\n", "-6.365 6.3 15.196 89.7909799033288\n", "-5.544 5.87 13.326 88.94656639241336\n", "-4.57 5.444 12.689 88.0722286194689\n", "-4.35 6.893 15.303 87.71237670363287\n", "-4.304 6.877 16.302 87.77722329853\n", "-3.491 6.547 14.924 86.9343297495299\n", "-4.537 8.347 14.845 87.50110149020983\n", "-4.671 8.357 13.854 87.540447959786\n", "-5.346 8.725 15.295 88.24237763682481\n", "-3.324 9.225 15.19 86.15959601808726\n", "-3.36 10.426 14.859 85.90053910191716\n", "-2.289 8.682 15.652 85.32956545066897\n", "-6.667 6.295 12.743 89.88144906486544\n", "-7.448 6.524 13.324 90.62196749684924\n", "-6.81 6.441 11.301 89.89612291417244\n", "-6.436 5.626 10.858 89.71665932813147\n", "-5.989 7.659 10.852 88.7844974136814\n", "-6.523 8.755 10.697 89.04555098375212\n", "-8.306 6.529 10.939 91.3054530408781\n", "-8.794 5.78 11.386 91.98352120352861\n", "-8.669 7.403 11.262 91.46729085853586\n", "-8.546 6.433 9.44 91.50183935856151\n", "-7.655 6.19 8.645 90.67585061635761\n", "-9.776 6.58 9.006 92.64777737754963\n", "-9.976 6.492 8.03 92.84231852447459\n", "-10.513 6.78 9.651 93.33590017244168\n", "-4.662 7.497 10.736 87.53016608004351\n", "-4.253 6.611 10.957 87.3628981776589\n", "-3.802 8.597 10.291 86.4157583950983\n", "-4.057 9.356 10.891 86.51995694058105\n", "-4.094 8.889 8.819 86.58199463514339\n", "-3.965 7.979 7.998 86.65043751187872\n", "-2.302 8.37 10.5 85.02150733196865\n", "-2.068 7.443 10.207 85.00683216659705\n", "-1.792 9.032 9.951 84.347270104017\n", "-1.921 8.541 11.974 84.69266419826454\n", "-2.307 9.4 12.309 84.89101088454537\n", "-2.303 7.778 12.496 85.28056364729304\n", "-0.402 8.569 12.18 83.22763097673753\n", "-0.0 7.697 11.9 83.03461156650279\n", "0.004 9.31 11.646 82.62430074136783\n", "-0.16 8.804 13.673 83.05151922752526\n", "-0.585 9.667 13.944 83.28637999697189\n", "-0.566 8.054 14.195 83.67109303696229\n", "1.273 8.877 14.029 81.68000062438784\n", "1.391 9.031 15.01 81.6246693653334\n", "1.725 9.625 13.544 81.02219612550626\n", "1.745 8.028 13.792 81.41248108244827\n", "-4.413 10.143 8.473 86.60906711193695\n", "-4.76 10.532 7.118 86.84730073525601\n", "-5.356 9.853 6.688 87.57121032622535\n", "-3.503 10.595 6.241 85.60364434999248\n", "-2.907 11.653 6.059 84.80471221577253\n", "-5.464 11.883 7.289 87.26921021184963\n", "-5.336 12.457 6.48 87.0325921365094\n", "-6.442 11.758 7.458 88.25462141440526\n", "-4.783 12.502 8.502 86.50254786999051\n", "-3.923 12.946 8.25 85.57042089413841\n", "-5.38 13.163 8.957 86.98102971912897\n", "-4.54 11.281 9.378 86.52344543532695\n", "-3.697 11.381 9.907 85.6969580440286\n", "-5.308 11.127 10.0 87.32859315252935\n", "-3.058 9.459 5.708 85.41902803240035\n", "-3.48 8.599 5.995 86.02342203725681\n", "-1.974 9.413 4.717 84.38913713861518\n", "-1.545 10.316 4.745 83.76964684776938\n", "-2.559 9.158 3.338 85.05776571248505\n", "-3.271 8.173 3.144 85.98628402832628\n", "-0.896 8.378 5.066 83.57666703691886\n", "-0.281 8.281 4.283 83.02153302607704\n", "-1.449 7.099 5.268 84.42590951242396\n", "-2.403 7.167 5.314 85.33106630647481\n", "-0.158 8.763 6.35 82.75465687198515\n", "0.544 8.088 6.576 82.2383070898228\n", "-0.79 8.82 7.123 83.35655764245546\n", "0.29 9.652 6.253 82.11084039272767\n", "-2.273 10.041 2.376 84.62402016567162\n", "-1.818 10.896 2.626 83.98469639761757\n", "-2.603 9.801 0.965 85.07943477715398\n", "-3.572 9.556 0.933 86.07856837796501\n", "-1.778 8.616 0.426 84.5857379763279\n", "-0.651 8.436 0.899 83.50376763356249\n", "-2.413 11.086 0.138 84.67868955055928\n", "-2.857 10.958 -0.749 85.20976845996003\n", "-2.851 11.841 0.625 84.9188462827893\n", "-0.941 11.459 -0.108 83.18520554161057\n", "-0.485 11.6 0.77 82.64531311574783\n", "-0.49 10.716 -0.603 82.94335834773028\n", "-0.843 12.743 -0.935 82.90567033683521\n", "-1.524 12.729 -1.667 83.64294367727621\n", "-1.0 13.538 -0.349 82.86054671555094\n", "0.493 12.874 -1.547 81.63349242192201\n", "0.867 12.044 -1.961 81.47486246076147\n", "1.257 13.947 -1.617 80.69366972693706\n", "0.943 15.072 -1.031 80.74835897403736\n", "0.096 15.142 -0.505 81.52100363709955\n", "1.55 15.863 -1.109 80.03087995892585\n", "2.362 13.904 -2.304 79.69444362689283\n", "2.626 13.062 -2.774 79.64993861265681\n", "2.947 14.713 -2.362 78.98395128758752\n", "-2.297 7.836 -0.535 85.34947566915686\n", "-1.511 6.799 -1.196 84.90781486412189\n", "-1.099 6.194 -0.515 84.60950280553598\n", "-0.364 7.424 -1.999 83.72287681392703\n", "-0.433 8.597 -2.371 83.54013838868116\n", "-2.5 6.058 -2.091 86.13598231865704\n", "-2.048 5.706 -2.91 85.88166822436554\n", "-2.933 5.303 -1.598 86.70328128162161\n", "-3.521 7.136 -2.449 86.88093865169735\n", "-3.201 7.698 -3.212 86.51818668927359\n", "-4.407 6.733 -2.679 87.85812726208087\n", "-3.606 7.951 -1.165 86.64177825391165\n", "-3.801 8.912 -1.359 86.62492955841292\n", "-4.306 7.586 -0.551 87.35371081986156\n", "0.694 6.65 -2.244 82.93214004835518\n", "0.677 5.708 -1.908 83.16725882220717\n", "1.884 7.102 -2.98 81.75482119728474\n", "1.675 8.024 -3.306 81.75725487074526\n", "2.133 6.184 -4.165 81.90946998363498\n", "2.308 4.977 -3.982 82.05751418365048\n", "3.123 7.159 -2.067 80.45059881691373\n", "3.27 6.227 -1.737 80.52840464705605\n", "4.366 7.641 -2.827 79.21833203873962\n", "5.164 7.674 -2.225 78.37625105859554\n", "4.225 8.558 -3.2 79.16171776812325\n", "4.581 7.029 -3.588 79.27058168702939\n", "2.901 8.112 -0.882 80.29726605557626\n", "3.708 8.145 -0.293 79.45929445319786\n", "2.125 7.816 -0.324 81.07038016439789\n", "2.714 9.042 -1.2 80.27622405793636\n", "2.185 6.749 -5.367 81.87380024159131\n", "1.985 7.726 -5.447 81.82191494336953\n", "2.523 6.0 -6.58 81.9410438303052\n", "2.095 5.1 -6.501 82.58536241368684\n", "4.045 5.822 -6.646 80.56064540456462\n", "4.802 6.789 -6.652 79.57656357244889\n", "1.931 6.674 -7.836 82.53054283112404\n", "2.315 7.592 -7.939 81.9449744950842\n", "0.395 6.805 -7.704 83.93198292069597\n", "0.002 5.887 -7.642 84.53675977940011\n", "0.19 7.312 -6.867 83.85917141255331\n", "2.295 5.83 -9.069 82.6384797597342\n", "1.926 6.238 -9.904 83.03715658065369\n", "1.926 4.904 -8.991 83.23013078206714\n", "3.287 5.758 -9.174 81.74423390062444\n", "-0.279 7.528 -8.869 84.59475818867266\n", "-1.268 7.584 -8.732 85.49776432749572\n", "-0.115 7.049 -9.731 84.72085324169014\n", "0.072 8.46 -8.963 84.05051808287679\n", "4.499 4.568 -6.656 80.49800081989613\n", "3.827 3.833 -6.566 81.33599233426736\n", "5.916 4.184 -6.79 79.30663682819994\n", "6.442 4.936 -6.393 78.51844979366312\n", "6.297 4.029 -8.262 79.25995839640593\n", "7.409 4.365 -8.656 78.19524947846895\n", "6.198 2.876 -6.022 79.33015031499687\n", "5.614 2.182 -6.442 80.16802330730127\n", "7.666 2.437 -6.128 78.12547363056431\n", "7.824 1.588 -5.623 78.18696196937185\n", "8.277 3.135 -5.754 77.26582777010803\n", "7.925 2.28 -7.081 78.09870309422557\n", "5.871 3.027 -4.53 79.36445784480607\n", "6.055 2.178 -4.035 79.40232606794336\n", "4.907 3.258 -4.396 80.17635763739831\n", "6.422 3.751 -4.114 78.55966722180027\n", "5.372 3.516 -9.071 80.43490201398892\n", "4.534 3.171 -8.649 81.24197271730911\n", "5.48 3.415 -10.526 80.66164075940928\n", "6.097 4.128 -10.859 79.94144307554123\n", "4.074 3.603 -11.105 82.0309815313702\n", "3.136 3.066 -10.517 82.94226827137054\n", "6.064 2.05 -10.9 80.63986992177009\n", "6.987 1.949 -10.528 79.74525308129631\n", "5.483 1.313 -10.555 81.34461699461126\n", "6.162 1.879 -12.296 80.92011417441277\n", "6.184 0.945 -12.503 81.26105602931825\n", "3.872 4.372 -12.184 82.22762290739044\n", "4.888 5.046 -12.998 81.27954178635605\n", "5.658 4.421 -13.127 80.7825648206344\n", "5.502 6.294 -12.347 80.20038734320427\n", "4.985 6.8 -11.353 80.31642323335869\n", "4.137 5.407 -14.27 82.18622267144292\n", "4.532 6.221 -14.697 81.70432998929738\n", "4.154 4.647 -14.92 82.55455562232771\n", "2.715 5.68 -13.787 83.30937568485314\n", "2.632 6.597 -13.397 83.04511122877733\n", "2.051 5.571 -14.527 84.1394612889814\n", "2.538 4.607 -12.721 83.52186867521583\n", "1.931 4.918 -11.99 83.83370978311767\n", "2.18 3.76 -13.114 84.19161262857482\n", "6.599 6.8 -12.923 79.17874056209784\n", "6.932 6.36 -13.757 79.20165759629023\n", "7.347 7.958 -12.413 78.04535184749955\n", "6.809 8.315 -11.65 78.27387214773522\n", "7.439 9.128 -13.421 77.91100885625856\n", "8.5 9.728 -13.58 76.81335473080185\n", "8.712 7.475 -11.901 76.77907201184446\n", "8.605 6.72 -11.254 76.93673707663979\n", "9.201 8.212 -11.435 76.01208462474898\n", "9.285 7.154 -12.655 76.52111596807772\n", "6.324 9.473 -14.082 79.03912915765203\n", "5.489 8.963 -13.876 79.89058493339499\n", "6.234 10.548 -15.09 79.14072694257995\n", "5.337 10.437 -15.519 80.12188473819121\n", "7.263 10.385 -16.217 78.53707421339298\n", "8.086 11.266 -16.474 77.64818169796379\n", "6.276 11.93 -14.416 78.61585349660716\n", "7.113 12.002 -13.873 77.66940615840961\n", "6.275 12.637 -15.123 78.66229410588022\n", "5.098 12.175 -13.502 79.4379956066365\n", "4.069 11.524 -13.557 80.5603062121787\n", "5.198 13.15 -12.628 78.93091488764081\n", "4.434 13.353 -12.015 79.47266480369208\n", "6.038 13.69 -12.575 78.01553636295786\n", "7.215 9.229 -16.869 79.04775636284687\n", "6.437 8.626 -16.692 79.86310953124728\n", "8.222 8.779 -17.828 78.524107470254\n", "8.896 9.516 -17.882 77.73996386029518\n", "7.663 8.63 -19.248 79.5236625162599\n", "6.452 8.617 -19.483 80.70846326749134\n", "8.897 7.504 -17.296 78.07503741913928\n", "9.648 7.267 -17.912 77.64658559138321\n", "9.262 7.7 -16.386 77.41440763191305\n", "7.962 6.288 -17.188 79.23031960682728\n", "7.079 6.587 -16.826 79.8467099447435\n", "7.833 5.894 -18.098 79.73612885010157\n", "8.547 5.215 -16.257 78.73278596620344\n", "7.772 4.714 -15.407 79.34780078867969\n", "9.768 4.953 -16.351 77.73014279544326\n", "8.567 8.536 -20.221 79.04821185200838\n", "9.529 8.666 -19.981 78.06245543793764\n", "8.24 8.254 -21.623 79.89997653316301\n", "7.246 8.345 -21.677 80.79233505104305\n", "8.687 6.847 -21.983 79.99628077604608\n", "9.781 6.443 -21.592 78.99161621969763\n", "8.898 9.248 -22.587 79.40811070665264\n", "8.764 8.912 -23.519 79.95662878085844\n", "10.29 9.303 -22.366 78.06496787932473\n", "10.464 9.315 -21.425 77.56174089717172\n", "8.356 10.668 -22.438 79.5094391691955\n", "8.804 11.292 -23.079 79.20379035121992\n", "8.51 11.015 -21.513 78.95923866780885\n", "7.373 10.697 -22.617 80.45700823421163\n", "7.894 6.134 -22.78 81.18524474927693\n", "7.039 6.549 -23.092 81.9474226379329\n", "8.208 4.776 -23.223 81.45346940431696\n", "9.159 4.593 -22.973 80.57641740608724\n", "8.107 4.661 -24.746 82.14466542022068\n", "7.079 5.0 -25.331 83.17393714980673\n", "7.289 3.789 -22.493 82.29692027044511\n", "7.29 4.0 -21.516 81.89268602872907\n", "6.36 3.878 -22.852 83.22076421783207\n", "7.764 2.351 -22.692 82.39322475786466\n", "7.657 2.181 -23.672 82.8938557976404\n", "8.737 2.37 -22.461 81.45048894266995\n", "6.853 1.154 -21.693 83.23553321148367\n", "7.928 -0.277 -21.972 82.87300529122858\n", "7.587 -1.081 -21.485 83.28738858914954\n", "8.858 -0.095 -21.651 81.88837609209257\n", "7.977 -0.504 -22.945 83.24944406420981\n", "9.18 4.195 -25.386 81.59145672188968\n", "10.008 4.018 -24.854 80.7167598519663\n", "9.211 3.928 -26.828 82.21958545261585\n", "8.706 4.682 -27.248 82.60548168856592\n", "8.524 2.6 -27.133 83.34083862069063\n", "8.926 1.566 -26.596 83.10881703525806\n", "10.653 3.908 -27.363 81.2060385993554\n", "11.2 3.297 -26.79 80.6881774363506\n", "10.643 3.565 -28.302 81.71553904246119\n", "11.3 5.301 -27.355 80.23456812995256\n", "10.71 5.924 -27.868 80.78184836335448\n", "11.368 5.61 -26.406 79.68984934732904\n", "12.704 5.344 -27.978 79.28903316978962\n", "13.449 6.298 -27.658 78.23916188201405\n", "13.018 4.486 -28.835 79.65529211546462\n", "7.496 2.62 -27.988 84.56606563509976\n", "7.213 3.492 -28.388 84.71114842805521\n", "6.772 1.396 -28.355 85.71867230656339\n", "7.467 0.687 -28.239 85.3055758669971\n", "6.313 1.409 -29.811 86.70868513591934\n", "5.828 2.429 -30.306 87.01847929032085\n", "5.575 1.11 -27.422 86.46519410722443\n", "4.81 1.645 -27.782 87.10053296048193\n", "5.381 -0.404 -27.411 87.11983177784492\n", "4.616 -0.663 -26.822 87.63737664946389\n", "6.2 -0.868 -27.073 86.44204610026303\n", "5.191 -0.748 -28.331 87.759493326933\n", "5.737 1.523 -25.952 85.62609953162645\n", "4.917 1.301 -25.425 86.21294254344878\n", "5.897 2.507 -25.872 85.15047486068411\n", "6.511 1.051 -25.53 84.94494292775762\n", "6.456 0.273 -30.496 87.2384688425926\n", "6.868 -0.504 -30.02 86.94514947367679\n", "6.056 0.074 -31.892 88.24064730610264\n", "6.416 0.878 -32.365 87.88977839316696\n", "4.529 0.026 -32.069 89.61888473418982\n", "3.809 -0.596 -31.281 90.09237562080378\n", "6.669 -1.226 -32.435 88.3950625600774\n", "6.456 -1.969 -31.8 88.54793444231208\n", "6.262 -1.423 -33.327 89.19552308832546\n", "8.187 -1.153 -32.602 87.18644853989638\n", "8.628 -0.337 -33.44 86.92919747702724\n", "8.892 -1.934 -31.928 86.5743383052969\n", "4.039 0.627 -33.156 90.31707030788809\n", "4.672 1.136 -33.739 89.88682247137228\n", "2.627 0.582 -33.542 91.69273812031136\n", "2.089 0.915 -32.768 91.71319674398009\n", "2.204 -0.868 -33.839 92.63093957204579\n", "2.903 -1.579 -34.562 92.59176166916794\n", "2.426 1.499 -34.765 92.12986114718723\n", "2.789 2.404 -34.542 91.46064810616639\n", "2.938 1.115 -35.533 92.16035913015963\n", "0.959 1.663 -35.2 93.51756103000119\n", "0.549 0.751 -35.174 94.11899819377592\n", "0.191 2.603 -34.274 93.49691606144023\n", "-0.76 2.699 -34.569 94.41372893281994\n", "0.604 3.514 -34.265 92.89011147587239\n", "0.188 2.258 -33.335 93.18996874127599\n", "0.883 2.272 -36.601 94.04350821295428\n", "-0.067 2.383 -36.893 94.94865407155595\n", "1.344 1.69 -37.27 94.12969202648014\n", "1.318 3.172 -36.625 93.43952066443833\n", "1.058 -1.296 -33.308 93.50563709744989\n", "0.527 -0.651 -32.758 93.51996925256122\n", "0.527 -2.653 -33.48 94.46813662288464\n", "-0.457 -2.606 -33.308 95.21190894000601\n", "0.688 -2.911 -34.433 94.82615303279997\n", "1.144 -3.716 -32.563 93.92113247826603\n", "0.73 -4.871 -32.602 94.68756912076684\n", "2.127 -3.36 -31.73 92.62501435357514\n", "2.538 -2.453 -31.824 92.00830774446402\n", "2.621 -4.261 -30.682 92.09595668106174\n", "2.612 -5.177 -31.083 92.59615691269265\n", "1.682 -4.274 -29.468 92.41282190800148\n", "0.818 -3.411 -29.343 92.79891367359858\n", "4.066 -3.921 -30.31 90.60791714855827\n", "4.449 -4.62 -29.707 90.29624107901724\n", "4.632 -3.842 -31.13 90.44310172146905\n", "4.154 -2.695 -29.628 89.8245499960896\n", "4.174 -1.978 -30.262 89.81871988065738\n", "1.841 -5.258 -28.581 92.29101315404442\n", "2.508 -5.973 -28.789 92.07104267357897\n", "1.097 -5.356 -27.319 92.48947975310489\n", "0.344 -4.701 -27.377 92.91895902882253\n", "1.999 -4.962 -26.145 91.14650032228336\n", "3.197 -5.265 -26.161 90.23974453642917\n", "0.507 -6.767 -27.15 93.45720586985252\n", "-0.106 -6.759 -26.36 93.69694047299515\n", "-0.013 -6.991 -27.974 94.28417462649817\n", "1.56 -7.865 -26.931 92.90633904637508\n", "2.22 -7.837 -27.682 92.61240220402448\n", "2.031 -7.696 -26.065 92.13139814959935\n", "0.94 -9.255 -26.882 93.96476276775246\n", "-0.004 -9.54 -26.171 94.6281233355074\n", "1.466 -10.208 -27.62 94.17620298674183\n", "1.088 -11.133 -27.585 94.86302244288866\n", "2.243 -10.007 -28.216 93.66415701323533\n", "1.441 -4.325 -25.114 91.03070983464865\n", "0.464 -4.116 -25.151 91.81544330884647\n", "2.205 -3.919 -23.928 89.81411876202984\n", "2.911 -4.619 -23.821 89.4225434328503\n", "1.365 -3.958 -22.652 90.13687835730722\n", "0.145 -3.83 -22.689 91.17207333937294\n", "2.868 -2.542 -24.161 88.82752317834827\n", "3.263 -2.55 -25.08 88.80995216753581\n", "3.993 -2.318 -23.134 87.41668950492235\n", "3.583 -2.134 -22.241 87.41146776596305\n", "4.551 -3.146 -23.081 87.21016101922986\n", "1.863 -1.378 -24.158 89.3059082479989\n", "2.326 -0.505 -24.311 88.66311956501418\n", "1.382 -1.322 -23.283 89.4135804562148\n", "1.179 -1.494 -24.878 90.19359267708543\n", "4.9 -1.15 -23.496 86.34319895046741\n", "5.619 -1.029 -22.812 85.43749493635683\n", "4.381 -0.297 -23.55 86.52673194452683\n", "5.34 -1.299 -24.382 86.32498925571899\n", "2.037 -4.109 -21.511 89.23921706290345\n", "3.013 -4.317 -21.568 88.48084914262519\n", "1.442 -3.991 -20.183 89.31129300933897\n", "0.467 -3.817 -20.319 90.15000713255657\n", "2.076 -2.817 -19.436 88.1056967851682\n", "3.3 -2.747 -19.31 86.95949637618654\n", "1.623 -5.299 -19.405 89.40844413141299\n", "2.601 -5.495 -19.327 88.6025031136254\n", "1.231 -5.187 -18.492 89.45094349977533\n", "0.935 -6.482 -20.097 90.6662626173595\n", "-0.033 -6.267 -20.225 91.46899690058922\n", "1.364 -6.633 -20.988 90.61707361198549\n", "1.047 -7.761 -19.278 90.83441379235074\n", "2.103 -8.129 -18.785 89.92482061144186\n", "-0.025 -8.494 -19.105 92.0141162702767\n", "0.028 -9.341 -18.576 92.16668572754473\n", "-0.897 -8.207 -19.502 92.77184745923732\n", "1.25 -1.907 -18.926 88.37320685592438\n", "0.275 -1.989 -19.135 89.3331800508635\n", "1.678 -0.795 -18.08 87.36996768913217\n", "2.671 -0.72 -18.17 86.47895394834514\n", "1.318 -1.11 -16.629 87.4034124391033\n", "0.168 -1.399 -16.315 88.45823911315439\n", "1.046 0.525 -18.557 87.64218848819327\n", "0.058 0.461 -18.417 88.51613332607789\n", "1.416 1.264 -17.994 86.91301442822012\n", "1.294 0.884 -20.034 87.74020695781381\n", "0.9 0.149 -20.586 88.49607309931892\n", "0.639 2.23 -20.348 88.01282981474917\n", "0.786 2.486 -21.303 88.10101094766165\n", "1.018 2.956 -19.774 87.28023733354532\n", "-0.347 2.195 -20.188 88.86716573065667\n", "2.781 0.986 -20.38 86.48001725254221\n", "2.909 1.22 -21.344 86.59687169869359\n", "3.249 0.119 -20.209 86.28975942717652\n", "3.229 1.691 -19.83 85.68502546536355\n", "2.296 -1.059 -15.729 86.2674483858193\n", "3.202 -0.756 -16.024 85.42321432140095\n", "2.103 -1.428 -14.324 86.21778113591186\n", "1.224 -1.9 -14.263 87.1639006814174\n", "2.043 -0.161 -13.48 85.6385899755478\n", "2.99 0.621 -13.461 84.5090826065459\n", "3.204 -2.401 -13.848 85.45404733539542\n", "4.096 -1.959 -13.944 84.51388646843783\n", "3.195 -3.683 -14.716 86.14509535080914\n", "2.308 -4.132 -14.608 87.08001070854321\n", "3.32 -3.418 -15.672 86.17612874224508\n", "2.994 -2.746 -12.362 85.42717469868705\n", "3.699 -3.376 -12.037 84.9534326381224\n", "2.104 -3.179 -12.217 86.35877726670289\n", "3.032 -1.924 -11.794 84.97046421551431\n", "4.285 -4.7 -14.361 85.47472459739194\n", "4.231 -5.505 -14.952 85.9848647902641\n", "4.193 -5.008 -13.414 85.45029212354981\n", "5.196 -4.301 -14.468 84.53734042421728\n", "0.946 0.019 -12.748 86.4148501474139\n", "0.143 -0.546 -12.94 87.38112329330632\n", "0.868 1.002 -11.683 85.93465923595672\n", "1.607 1.653 -11.856 85.08207959964307\n", "1.068 0.314 -10.34 85.69864253884072\n", "0.285 -0.551 -9.972 86.63764932752966\n", "-0.452 1.754 -11.717 86.92698344012634\n", "-0.54 2.104 -12.65 87.10248945351677\n", "-1.159 1.067 -11.55 87.76134131267594\n", "-0.453 3.066 -10.48 86.27959093551614\n", "2.106 0.697 -9.608 84.47113868061682\n", "2.719 1.383 -10.0 83.75615595883087\n", "2.42 0.197 -8.281 84.1034168330871\n", "1.761 -0.519 -8.05 84.91550052257833\n", "2.268 1.323 -7.256 83.6963667909187\n", "2.969 2.336 -7.314 82.72715380091351\n", "3.833 -0.4 -8.311 83.01021195612019\n", "3.893 -1.048 -9.07 83.32246414983176\n", "4.493 0.339 -8.45 82.17200966874304\n", "4.196 -1.129 -7.032 82.71472254683563\n", "3.49 -1.153 -6.04 83.21642432837402\n", "5.343 -1.765 -7.014 81.89243824065808\n", "5.627 -2.261 -6.193 81.68623429929917\n", "5.933 -1.754 -7.821 81.4879757817066\n", "1.368 1.129 -6.301 84.44692607194177\n", "0.922 0.235 -6.265 85.15107878940817\n", "0.976 2.115 -5.297 84.35227657271616\n", "1.538 2.927 -5.453 83.59441968815861\n", "1.251 1.56 -3.91 84.08622928874857\n", "0.825 0.461 -3.573 84.80289956127679\n", "-0.508 2.476 -5.454 85.65874473163845\n", "-1.029 1.644 -5.263 86.37891467829402\n", "-0.944 3.554 -4.459 85.6154177820794\n", "-1.912 3.778 -4.574 86.48364077095736\n", "-0.417 4.394 -4.587 84.88993076331256\n", "-0.809 3.247 -3.517 85.46156157010003\n", "-0.812 2.948 -6.879 86.01431140223119\n", "-1.779 3.183 -6.98 86.87237812446484\n", "-0.598 2.235 -7.546 86.13497706506921\n", "-0.273 3.758 -7.111 85.30469839932616\n", "1.928 2.337 -3.071 83.10143841715377\n", "2.354 3.168 -3.429 82.4832732012982\n", "2.08 2.033 -1.645 82.90157727691313\n", "1.93 1.049 -1.549 83.35300577063792\n", "1.033 2.793 -0.838 83.57638042533308\n", "0.973 4.023 -0.893 83.26747426216312\n", "3.492 2.367 -1.163 81.41734952084843\n", "3.657 3.339 -1.33 80.97002737433154\n", "4.431 1.624 -1.898 80.8515936515787\n", "4.085 0.747 -2.065 81.48856654770655\n", "3.719 1.992 0.303 81.19909790755068\n", "4.649 2.221 0.592 80.22634171517483\n", "3.585 1.012 0.447 81.63973964314192\n", "3.083 2.48 0.9 81.59762413207874\n", "0.238 2.072 -0.051 84.48757270746982\n", "0.386 1.084 -0.008 84.65956697857602\n", "-0.838 2.645 0.753 85.27231585338818\n", "-0.437 3.359 1.326 84.63878038464401\n", "-1.498 3.054 0.123 85.82224053239347\n", "-1.546 1.619 1.638 86.205168534143\n", "-0.971 0.608 2.051 85.9607328551822\n", "-2.804 1.897 1.956 87.2963051108121\n", "-3.154 2.803 1.719 87.37061548941955\n", "-3.713 0.971 2.628 88.41295554951208\n", "-3.142 0.373 3.191 88.03742369583516\n", "-4.468 0.126 1.598 89.44616285229903\n", "-4.716 0.573 0.486 89.60877221567092\n", "-4.693 1.755 3.515 89.06987792738911\n", "-5.16 2.441 2.957 89.33286527924646\n", "-5.366 1.121 3.897 89.89080283877766\n", "-3.964 2.46 4.666 88.1318837481646\n", "-3.437 1.782 5.179 87.82348260573592\n", "-3.344 3.145 4.284 87.34741602360083\n", "-4.919 3.155 5.625 88.82781189469883\n", "-5.658 2.526 6.362 89.71195234192598\n", "-4.897 4.467 5.711 88.43956260633585\n", "-5.481 4.934 6.374 88.87247447888461\n", "-4.296 4.997 5.113 87.72548621124878\n", "-4.914 -1.072 1.985 90.23408827045353\n", "-4.693 -1.395 2.905 90.09044785103467\n", "-5.72 -1.934 1.104 91.32740625354471\n", "-5.169 -2.013 0.273 90.88952363171455\n", "-7.079 -1.326 0.719 92.43217040078632\n", "-7.703 -1.775 -0.233 93.23131807499023\n", "-5.947 -3.292 1.784 91.96434724391838\n", "-6.339 -3.124 2.689 92.23138819837854\n", "-6.598 -3.811 1.23 92.78441840093625\n", "-4.685 -4.148 1.963 91.07791172946379\n", "-4.002 -3.603 2.449 90.22263699870447\n", "-5.073 -5.401 2.738 91.8596583109256\n", "-4.28 -5.994 2.881 91.34078875288958\n", "-5.766 -5.927 2.245 92.71930419820892\n", "-5.447 -5.166 3.635 92.08777276598668\n", "-4.068 -4.576 0.631 90.7360282908614\n", "-3.249 -5.131 0.777 90.1723160731718\n", "-3.806 -3.78 0.085 90.2419364043126\n", "-4.715 -5.118 0.094 91.57153874430635\n", "-7.547 -0.331 1.475 92.51421165421017\n", "-7.039 -0.095 2.303 91.91667442852791\n", "-8.755 0.438 1.172 93.44337352643043\n", "-9.377 -0.236 0.772 94.2630966179236\n", "-8.536 1.558 0.153 92.96800340977533\n", "-9.511 2.17 -0.281 93.75557871934873\n", "-9.285 1.059 2.465 93.6986170335507\n", "-10.081 1.635 2.28 94.30124209680379\n", "-9.534 0.348 3.122 94.12069632657845\n", "-8.293 1.877 3.07 92.48774263111842\n", "-7.496 1.365 3.206 91.87064785882376\n", "-7.281 1.898 -0.154 91.69349795923372\n", "-6.528 1.467 0.343 91.06733914527206\n", "-6.971 2.878 -1.191 91.19910932130861\n", "-7.567 3.665 -1.031 91.53843244233539\n", "-7.283 2.261 -2.57 91.79932329271277\n", "-7.301 1.042 -2.729 92.18884336512743\n", "-5.512 3.369 -1.074 89.6564697609715\n", "-4.91 2.586 -1.23 89.31916542937466\n", "-5.36 4.054 -1.786 89.38454636568896\n", "-5.127 4.0 0.28 89.00677571960462\n", "-6.001 4.501 1.029 89.6599760985915\n", "-3.912 4.058 0.58 87.80561365311446\n", "-7.553 3.097 -3.573 91.92653902981445\n", "-7.53 4.08 -3.391 91.61721732294644\n", "-7.883 2.645 -4.934 92.52658202376222\n", "-7.86 1.646 -4.903 92.78561156774254\n", "-6.815 3.109 -5.923 91.50990847990177\n", "-6.404 4.269 -5.871 90.7949751638272\n", "-9.312 3.071 -5.347 93.8227617318953\n", "-9.427 2.85 -6.316 94.12035584293122\n", "-9.549 4.592 -5.221 93.6322704466788\n", "-9.568 4.828 -4.25 93.47309018642744\n", "-8.789 5.067 -5.665 92.84013654664668\n", "-10.341 2.29 -4.509 94.91644764212364\n", "-11.275 2.548 -4.757 95.7663442812766\n", "-10.221 2.472 -3.533 94.64265848442763\n", "-10.246 1.305 -4.652 95.12011500203307\n", "-10.851 5.09 -5.853 94.83704780833278\n", "-10.949 6.079 -5.74 94.67678472043714\n", "-11.645 4.652 -5.431 95.65418575786424\n", "-10.874 4.889 -6.832 95.04206553942309\n", "-6.386 2.22 -6.82 91.48129339378625\n", "-6.754 1.292 -6.759 92.09122806217755\n", "-5.422 2.491 -7.884 90.654495608326\n", "-5.229 3.472 -7.878 90.1935701699406\n", "-6.032 2.114 -9.242 91.56383317118173\n", "-6.496 0.988 -9.404 92.35868661365859\n", "-4.126 1.725 -7.598 89.61211905763639\n", "-3.745 1.984 -6.711 89.03965986570253\n", "-3.436 1.915 -8.296 89.01988904733594\n", "-4.288 0.738 -7.587 90.06276337088485\n", "-6.069 3.043 -10.196 91.50475059252388\n", "-5.639 3.927 -10.011 90.82196327981464\n", "-6.706 2.843 -11.504 92.40789835290055\n", "-6.528 1.888 -11.743 92.5582373967871\n", "-6.081 3.738 -12.575 91.79110414958521\n", "-5.52 4.794 -12.269 90.91867457238914\n", "-8.219 3.095 -11.404 93.74419039599199\n", "-8.633 2.886 -12.29 94.36449391587918\n", "-8.595 2.484 -10.708 94.13586935913429\n", "-8.603 4.518 -11.033 93.6610811650175\n", "-8.581 4.926 -9.685 93.29215170098715\n", "-8.339 4.269 -8.97 93.10893300323013\n", "-8.968 5.432 -12.038 93.97141827704849\n", "-8.982 5.144 -12.995 94.2498895383968\n", "-8.897 6.252 -9.339 93.20732518960085\n", "-8.862 6.545 -8.383 92.94567421348881\n", "-9.314 6.752 -11.695 93.917550724026\n", "-9.596 7.396 -12.407 94.18018690786295\n", "-9.264 7.167 -10.35 93.52182736666344\n", "-9.549 8.454 -10.013 93.4490565013901\n", "-9.616 8.985 -10.807 93.54487502263285\n", "-6.193 3.339 -13.835 92.27524249764937\n", "-6.663 2.474 -14.009 92.99271264459381\n", "-5.68 4.073 -14.979 91.85776868071639\n", "-4.972 4.669 -14.601 90.94934679809414\n", "-6.735 4.974 -15.614 92.76107090800537\n", "-7.945 4.754 -15.566 93.94012978487946\n", "-5.06 3.108 -15.994 91.78609413740188\n", "-5.708 2.368 -16.171 92.63812009102946\n", "-4.881 3.605 -16.843 91.69608716842828\n", "-3.771 2.489 -15.548 90.65608353000917\n", "-3.629 1.29 -14.939 90.73081986293302\n", "-4.382 0.686 -14.679 91.54820825117224\n", "-2.424 3.019 -15.691 89.29239270508995\n", "-2.29 1.022 -14.729 89.52705138671774\n", "-1.94 0.19 -14.299 89.36361699259939\n", "-1.501 2.053 -15.191 88.59871571303954\n", "-1.89 4.213 -16.221 88.59738480903371\n", "-2.508 4.909 -16.588 89.077464793291\n", "-0.116 2.258 -15.241 87.27374832101574\n", "0.51 1.552 -14.91 86.83233276262938\n", "-0.5 4.439 -16.241 87.25361344379955\n", "-0.141 5.3 -16.601 86.78217547976082\n", "0.386 3.461 -15.758 86.58705174562765\n", "1.373 3.623 -15.783 85.63738360085505\n", "-6.243 6.036 -16.244 92.18840384777252\n", "-5.274 6.245 -16.113 91.19647507990646\n", "-7.012 6.917 -17.111 92.91733717127283\n", "-7.853 6.42 -17.324 93.87707524204191\n", "-6.243 7.193 -18.389 92.46822462878801\n", "-5.028 7.403 -18.362 91.27721679586863\n", "-7.35 8.231 -16.396 92.7589409059849\n", "-6.497 8.658 -16.097 91.78662190646303\n", "-7.815 8.834 -17.044 93.230261911034\n", "-8.257 8.035 -15.17 93.36522633721829\n", "-9.036 7.464 -15.43 94.29001816205148\n", "-7.735 7.579 -14.449 92.8067758625414\n", "-8.781 9.372 -14.631 93.45491399065114\n", "-9.154 9.239 -13.713 93.63433478697864\n", "-8.033 10.034 -14.594 92.59992829370873\n", "-9.877 9.901 -15.549 94.60336100794727\n", "-9.52 9.986 -16.479 94.46925177008653\n", "-10.65 9.266 -15.545 95.4649695857072\n", "-10.369 11.229 -15.122 94.7216426008333\n", "-11.086 11.559 -15.735 95.4893040868976\n", "-9.63 11.902 -15.123 93.89387069452403\n", "-10.748 11.19 -14.198 94.8847476942422\n", "-6.971 7.307 -19.488 93.42349311067318\n", "-7.942 7.072 -19.434 94.36842220255672\n", "-6.446 7.753 -20.771 93.20105885128129\n", "-5.542 8.147 -20.606 92.22461191027047\n", "-7.351 8.842 -21.352 93.97902136115272\n", "-8.575 8.761 -21.271 95.1133620370976\n", "-6.289 6.556 -21.705 93.60778572853863\n", "-5.67 5.892 -21.286 93.06919776703783\n", "-7.184 6.134 -21.85 94.57794555286131\n", "-5.732 6.934 -23.036 93.4179604412342\n", "-4.434 7.191 -23.312 92.25454615356361\n", "-3.68 7.114 -22.659 91.37043321556487\n", "-6.461 7.15 -24.276 94.43715262543655\n", "-4.307 7.575 -24.631 92.48626759687083\n", "-3.441 7.817 -25.069 91.79065217112252\n", "-5.534 7.582 -25.269 93.82163282527117\n", "-7.818 7.038 -24.65 95.83013810383453\n", "-8.492 6.739 -23.975 96.30050136421927\n", "-5.946 7.902 -26.571 94.57575098300832\n", "-5.28 8.216 -27.248 94.14205207557353\n", "-8.235 7.341 -25.959 96.57883676044146\n", "-9.199 7.246 -26.209 97.56667741088654\n", "-7.303 7.777 -26.917 95.96055009221236\n", "-7.605 7.998 -27.844 96.51508675849594\n", "-6.753 9.914 -21.883 93.36231750015634\n", "-5.754 9.927 -21.919 92.44113311183501\n", "-7.482 11.075 -22.417 93.98166954784321\n", "-6.807 11.809 -22.496 93.2422135784002\n", "-8.56 11.635 -21.451 94.5961455610111\n", "-9.677 11.971 -21.841 95.7011111847715\n", "-8.018 10.714 -23.813 94.98652322303411\n", "-7.281 10.304 -24.351 94.55541573595876\n", "-8.766 10.057 -23.717 95.77586528452771\n", "-8.538 11.925 -24.559 95.49128531442017\n", "-8.078 13.041 -24.395 94.82147197233336\n", "-9.501 11.741 -25.431 96.70367849259922\n", "-9.854 12.515 -25.957 97.07500853978844\n", "-9.882 10.827 -25.57 97.26550201381782\n", "-8.251 11.666 -20.15 93.92247017620437\n", "-7.35 11.336 -19.869 93.05473824583034\n", "-9.164 12.158 -19.113 94.40903199376635\n", "-8.61 12.329 -18.298 93.63545402250153\n", "-9.541 13.022 -19.447 94.71146076901145\n", "-10.321 11.22 -18.741 95.57120707095834\n", "-11.039 11.531 -17.785 95.94895358470565\n", "-10.457 10.067 -19.396 96.0904367614176\n", "-9.803 9.874 -20.128 95.71279174697601\n", "-11.49 9.056 -19.13 97.19254134448794\n", "-12.167 9.497 -18.541 97.59133620357906\n", "-10.903 7.86 -18.385 96.69250254802593\n", "-9.711 7.587 -18.504 95.66090257257663\n", "-12.159 8.622 -20.437 98.26236278962561\n", "-11.499 8.202 -21.06 97.90285197071634\n", "-12.909 7.984 -20.266 99.05160927516523\n", "-12.692 9.775 -21.066 98.71145827106396\n", "-12.812 9.603 -22.0 99.12229968074791\n", "-11.717 7.203 -17.559 97.39355002257592\n", "-12.603 7.608 -17.333 98.08758710968478\n", "-11.359 5.901 -16.967 97.20548938203025\n", "-10.435 5.975 -16.591 96.22717677454742\n", "-11.383 4.853 -18.081 97.75246766194702\n", "-12.061 5.068 -19.088 98.59353037598359\n", "-12.307 5.54 -15.802 97.91022773949614\n", "-13.216 5.444 -16.207 98.88434851886318\n", "-11.937 4.225 -15.109 97.72327207988891\n", "-12.57 4.023 -14.362 98.20859922634065\n", "-11.014 4.269 -14.726 96.75754156653629\n", "-11.967 3.46 -15.752 98.08902933559898\n", "-12.262 6.638 -14.723 97.37381131495263\n", "-12.872 6.417 -13.962 97.84042024644008\n", "-12.545 7.521 -15.098 97.53076585877915\n", "-11.338 6.742 -14.356 96.39302960795452\n", "-10.604 3.785 -17.936 97.25283423119348\n", "-9.979 3.743 -17.156 96.48564411869778\n", "-10.633 2.67 -18.882 97.81157485696669\n", "-10.486 3.04 -19.799 97.82080697888358\n", "-12.015 2.016 -18.81 99.25063187708177\n", "-12.512 1.744 -17.719 99.51347099764935\n", "-9.491 1.679 -18.587 96.94491436893428\n", "-9.687 1.25 -17.705 97.02149055235132\n", "-8.12 2.387 -18.46 95.44816183667446\n", "-8.14 2.956 -17.638 95.09978879576967\n", "-7.416 1.684 -18.361 94.96757420298782\n", "-9.442 0.589 -19.67 97.49333730055609\n", "-8.704 -0.062 -19.49 96.95676542150115\n", "-9.286 0.988 -20.574 97.4838253917028\n", "-10.301 0.078 -19.703 98.4391122318766\n", "-7.718 3.285 -19.638 95.15071166312946\n", "-6.824 3.704 -19.48 94.1701365879863\n", "-8.383 4.02 -19.771 95.61070091260706\n", "-7.666 2.76 -20.487 95.48054334784652\n", "-12.664 1.862 -19.96 100.19317955330092\n", "-12.243 2.198 -20.802 99.94103799741124\n", "-13.973 1.218 -20.032 101.59778519239482\n", "-14.544 1.567 -19.288 101.8430105112766\n", "-13.792 -0.293 -19.835 101.79640065837299\n", "-12.878 -0.877 -20.415 101.2745062639162\n", "-14.648 1.587 -21.363 102.48033646997847\n", "-14.491 2.557 -21.548 102.13449321850086\n", "-14.244 1.038 -22.094 102.45497212434348\n", "-16.154 1.333 -21.338 103.93518481245894\n", "-16.54 0.179 -21.064 104.52749268015567\n", "-16.903 2.316 -21.558 104.43748679473285\n", "-14.628 -0.919 -19.002 102.53573598507009\n", "-15.338 -0.384 -18.544 102.92848570245263\n", "-14.547 -2.362 -18.731 102.81819619600414\n", "-13.605 -2.512 -18.43 101.92220768802056\n", "-14.805 -3.197 -19.999 103.62727788569957\n", "-14.288 -4.309 -20.112 103.53026771915543\n", "-15.544 -2.757 -17.619 103.59080848704674\n", "-16.453 -2.435 -17.882 104.39666259512322\n", "-15.553 -3.754 -17.543 103.88713776498031\n", "-15.202 -2.168 -16.235 102.78196389444987\n", "-14.277 -2.461 -15.992 101.95867753653927\n", "-15.228 -1.171 -16.306 102.52838620596735\n", "-16.161 -2.599 -15.1 103.55786010245673\n", "-15.931 -2.163 -13.945 102.97708004211422\n", "-17.141 -3.339 -15.352 104.74580536231508\n", "-15.554 -2.645 -20.962 104.39740982419056\n", "-15.93 -1.735 -20.787 104.42895645844595\n", "-15.867 -3.266 -22.252 105.21723642065494\n", "-15.67 -4.238 -22.122 105.30045272932117\n", "-14.953 -2.764 -23.399 104.55439038605695\n", "-15.236 -3.028 -24.576 105.23342401062506\n", "-17.364 -3.059 -22.573 106.61138998718663\n", "-17.57 -2.085 -22.477 106.48946927748301\n", "-17.52 -3.341 -23.52 107.10013526602101\n", "-18.346 -3.837 -21.682 107.50455384773241\n", "-18.08 -5.026 -21.388 107.54903311978215\n", "-19.453 -3.301 -21.426 108.2949355833411\n", "-13.863 -2.029 -23.113 103.26099398127059\n", "-13.688 -1.766 -22.164 102.75457734329892\n", "-12.922 -1.602 -24.16 102.58655520583581\n", "-13.496 -1.151 -24.844 103.18297990463348\n", "-12.225 -2.836 -24.781 102.5142533943451\n", "-11.605 -3.638 -24.08 101.99263222409743\n", "-11.91 -0.545 -23.671 101.21322598850408\n", "-12.408 0.168 -23.177 101.3187481466288\n", "-11.261 -0.988 -23.053 100.56827494294609\n", "-11.121 0.115 -24.818 100.65829810303768\n", "-10.404 -0.602 -25.557 100.44840117194498\n", "-11.22 1.355 -25.0 100.46217034287085\n", "-12.296 -3.025 -26.112 103.05051478765158\n", "-11.747 -4.217 -26.758 103.13821893459281\n", "-12.023 -5.017 -26.225 103.47057037631521\n", "-10.211 -4.26 -26.773 101.7901058895215\n", "-9.631 -5.314 -27.052 101.71358166931297\n", "-12.326 -4.183 -28.177 104.10881197574005\n", "-11.677 -4.563 -28.836 103.87597641899688\n", "-13.186 -4.692 -28.224 105.04938587635819\n", "-12.56 -2.695 -28.442 103.94840086312054\n", "-11.725 -2.251 -28.768 103.1816036171177\n", "-13.293 -2.558 -29.109 104.78732236773683\n", "-12.962 -2.163 -27.073 103.69702967298534\n", "-12.656 -1.22 -26.945 103.10440497864289\n", "-13.952 -2.214 -26.939 104.55928669420042\n", "-9.547 -3.125 -26.537 100.76075330206696\n", "-10.079 -2.322 -26.267 100.89829380618882\n", "-8.09 -2.974 -26.646 99.45364383973067\n", "-7.761 -3.853 -26.991 99.56041077657322\n", "-7.433 -2.75 -25.286 98.35091206491172\n", "-6.31 -3.214 -25.07 97.4315363370608\n", "-7.736 -1.857 -27.648 99.13129567396967\n", "-8.138 -1.014 -27.29 99.11076337613387\n", "-6.223 -1.668 -27.799 97.78608453660468\n", "-6.016 -0.94 -28.452 97.61256452424554\n", "-5.788 -2.507 -28.126 97.78097644225075\n", "-5.803 -1.425 -26.925 97.03491955991925\n", "-8.289 -2.2 -29.039 100.21306288603296\n", "-8.066 -1.483 -29.7 100.03578426743101\n", "-9.284 -2.298 -29.015 101.11409532800063\n", "-7.904 -3.059 -29.376 100.26143532784677\n", "-8.116 -2.055 -24.377 98.4528583790232\n", "-9.039 -1.758 -24.62 99.26651612704055\n", "-7.618 -1.694 -23.051 97.4833023753299\n", "-6.642 -1.914 -23.041 96.67109806969195\n", "-8.315 -2.522 -21.964 98.04830723679017\n", "-9.523 -2.436 -21.811 99.0693027784086\n", "-7.839 -0.186 -22.826 97.1577444159754\n", "-8.824 -0.015 -22.828 98.00174601505832\n", "-7.461 0.051 -21.931 96.47718069056538\n", "-7.196 0.742 -23.871 96.6274376872325\n", "-7.563 0.477 -24.763 97.31926899643256\n", "-7.523 2.202 -23.557 96.4159197902504\n", "-7.11 2.815 -24.231 96.08781397763194\n", "-7.179 2.46 -22.654 95.75326296267923\n", "-8.511 2.358 -23.565 97.27600413771115\n", "-5.674 0.608 -23.889 95.29809797682218\n", "-5.269 1.216 -24.572 94.9778263385723\n", "-5.399 -0.328 -24.109 95.40027778261444\n", "-5.283 0.842 -22.999 94.59543408114368\n", "-7.557 -3.271 -21.164 97.3754342994166\n", "-6.577 -3.331 -21.354 96.56778067761523\n", "-8.094 -4.013 -20.016 97.78520897354568\n", "-9.045 -3.734 -19.885 98.51769563383017\n", "-8.059 -4.988 -20.235 98.14231242945114\n", "-7.304 -3.747 -18.741 96.64197540923922\n", "-6.075 -3.723 -18.78 95.53289796190629\n", "-7.982 -3.565 -17.608 96.90718440858757\n", "-8.981 -3.553 -17.651 97.82375884211359\n", "-7.341 -3.381 -16.3 95.94303812679688\n", "-6.38 -3.229 -16.532 95.07219651401769\n", "-7.464 -4.627 -15.417 96.27125990138488\n", "-8.564 -5.106 -15.151 97.37869402492517\n", "-7.906 -2.161 -15.554 95.88699016029234\n", "-8.904 -2.212 -15.573 96.82528999181979\n", "-7.588 -2.194 -14.606 95.39066420253083\n", "-7.481 -0.819 -16.158 95.21582066547552\n", "-6.506 -0.851 -16.378 94.38199524273683\n", "-8.006 -0.652 -16.992 95.84987090758129\n", "-7.739 0.318 -15.159 94.87603434482283\n", "-6.767 0.761 -14.508 93.69517166321859\n", "-8.889 0.76 -14.971 95.7712669906794\n", "-6.332 -5.093 -14.889 95.2847718106099\n", "-5.469 -4.723 -15.232 94.4492353648244\n", "-6.272 -6.111 -13.841 95.36501834006009\n", "-7.206 -6.458 -13.763 96.32175543458497\n", "-5.813 -5.49 -12.516 94.44755202756713\n", "-4.812 -4.767 -12.46 93.26476062264888\n", "-5.326 -7.25 -14.23 95.0161834689228\n", "-4.447 -6.852 -14.491 94.13331933486675\n", "-5.202 -7.84 -13.432 94.95752145564877\n", "-5.822 -8.113 -15.39 96.04833929850115\n", "-6.97 -8.598 -15.307 97.24331077251534\n", "-4.999 -8.374 -16.298 95.62569957914032\n", "-6.509 -5.817 -11.424 94.98655406424636\n", "-7.266 -6.463 -11.525 95.93099800898561\n", "-6.23 -5.287 -10.088 94.29589813984487\n", "-5.524 -4.593 -10.228 93.42577090931601\n", "-5.68 -6.37 -9.158 94.02829255601742\n", "-6.286 -7.426 -8.967 94.94563498128811\n", "-7.488 -4.644 -9.486 95.12073379132437\n", "-8.162 -5.364 -9.321 95.96697276667635\n", "-7.238 -4.215 -8.618 94.59793470261387\n", "-8.143 -3.586 -10.354 95.5129985918147\n", "-7.722 -2.242 -10.295 94.66758132539353\n", "-7.0 -1.972 -9.658 93.79708471482469\n", "-9.174 -3.957 -11.238 96.75031411835313\n", "-9.471 -4.911 -11.286 97.3573257901017\n", "-8.319 -1.275 -11.135 95.06671997076579\n", "-8.007 -0.325 -11.104 94.47580113976277\n", "-9.787 -2.989 -12.054 97.15079324946349\n", "-10.534 -3.255 -12.663 98.04674674358145\n", "-9.356 -1.648 -12.019 96.31612516084728\n", "-9.98 -0.74 -12.817 96.77403940107078\n", "-10.126 -1.123 -13.682 97.20301901690091\n", "-4.563 -6.072 -8.5 92.78869696250723\n", "-4.132 -5.19 -8.692 92.09986417470984\n", "-3.922 -6.94 -7.519 92.3783972907086\n", "-4.595 -7.649 -7.311 93.2333708389866\n", "-3.593 -6.17 -6.24 91.59735980911239\n", "-3.26 -4.986 -6.257 90.85150183678859\n", "-2.657 -7.574 -8.111 91.5695539849354\n", "-1.971 -6.856 -8.228 90.6855212037732\n", "-2.317 -8.259 -7.466 91.43419435309745\n", "-2.845 -8.255 -9.451 92.23318410420404\n", "-3.386 -9.554 -9.512 93.25436558681851\n", "-3.63 -10.034 -8.669 93.52886041217437\n", "-2.505 -7.575 -10.637 91.87165091582929\n", "-2.139 -6.645 -10.594 91.17118784462555\n", "-3.584 -10.178 -10.759 93.91009373863919\n", "-3.979 -11.096 -10.804 94.65179729936457\n", "-2.681 -8.206 -11.882 92.5197822738467\n", "-2.421 -7.732 -12.723 92.27127655451615\n", "-3.223 -9.504 -11.946 93.53886973873482\n", "-3.396 -10.092 -13.155 94.17923702175548\n", "-3.437 -11.042 -13.045 94.58641069942341\n", "-3.63 -6.861 -5.104 91.74392844215903\n", "-3.912 -7.82 -5.14 92.37960883766503\n", "-3.279 -6.287 -3.805 91.04547570307928\n", "-2.75 -5.462 -4.004 90.26960527774561\n", "-2.417 -7.25 -3.006 90.54399805619364\n", "-2.751 -8.431 -2.893 91.30895994369884\n", "-4.543 -5.924 -3.022 91.9843148803099\n", "-4.309 -5.459 -2.168 91.50968847613896\n", "-5.141 -5.338 -3.568 92.3770396797819\n", "-5.278 -7.088 -2.686 93.06724126673143\n", "-6.207 -6.869 -2.61 93.830805799588\n", "-1.345 -6.743 -2.403 89.30297326517186\n", "-1.132 -5.778 -2.555 88.74619339442116\n", "-0.457 -7.515 -1.529 88.71968296832443\n", "-0.86 -8.424 -1.421 89.4483862235647\n", "-0.393 -6.821 -0.172 88.26756553230636\n", "0.118 -5.704 -0.049 87.34782088867472\n", "0.934 -7.701 -2.164 87.59494404359192\n", "1.331 -6.786 -2.233 86.86655352320591\n", "1.829 -8.592 -1.295 87.07920372281777\n", "2.73 -8.709 -1.712 86.35865023262\n", "1.425 -9.499 -1.176 87.8215255674826\n", "1.959 -8.193 -0.388 86.71514403493774\n", "0.857 -8.318 -3.568 88.07201330729302\n", "1.77 -8.43 -3.961 87.34432099455579\n", "0.325 -7.738 -4.186 88.3846461100569\n", "0.422 -9.218 -3.541 88.83989037588914\n", "-0.942 -7.477 0.853 88.96088135242366\n", "-1.411 -8.342 0.675 89.75249757527642\n", "-0.882 -6.976 2.228 88.6264316386483\n", "-1.181 -6.023 2.171 88.52628528295988\n", "0.557 -7.043 2.743 87.31518890777251\n", "1.222 -8.075 2.641 87.14236978072148\n", "-1.845 -7.735 3.168 89.77177929059889\n", "-2.76 -7.744 2.764 90.62837101592415\n", "-1.521 -8.674 3.282 89.85648023375943\n", "-1.908 -7.049 4.551 89.5126825595122\n", "-1.022 -7.173 4.999 88.74154938358919\n", "-2.075 -6.074 4.405 89.2866391628669\n", "-3.0 -7.581 5.502 90.70981121135684\n", "-2.654 -7.996 6.637 90.55310555690511\n", "-4.197 -7.449 5.172 91.76141767104517\n", "1.03 -5.95 3.339 86.41765427272368\n", "0.489 -5.11 3.307 86.58467738000759\n", "2.308 -5.937 4.035 85.21971355854231\n", "2.901 -6.626 3.619 84.97444371691996\n", "2.102 -6.322 5.514 85.53332876136646\n", "1.61 -5.494 6.29 85.64427892743332\n", "2.952 -4.563 3.841 84.08698222079325\n", "3.042 -4.387 2.861 83.97256868168317\n", "2.358 -3.871 4.251 84.3523557169567\n", "4.324 -4.443 4.471 82.76220714190747\n", "4.752 -5.214 5.321 82.6647697268915\n", "5.063 -3.441 4.063 81.69909699623368\n", "5.977 -3.305 4.446 80.7947081249756\n", "4.713 -2.812 3.369 81.8019164139814\n", "2.511 -7.532 5.946 85.6585238490601\n", "2.276 -7.997 7.313 86.06921727888549\n", "1.31 -7.856 7.529 86.88766548826132\n", "3.05 -7.192 8.366 85.04341219048068\n", "2.622 -7.129 9.516 85.43753820189343\n", "2.686 -9.474 7.309 86.3384727337703\n", "3.095 -9.733 8.184 86.0984044741829\n", "1.899 -10.062 7.122 87.30276440067632\n", "3.713 -9.57 6.183 85.45805603335474\n", "4.626 -9.318 6.504 84.52789781486345\n", "3.738 -10.491 5.795 85.85320706298629\n", "3.19 -8.56 5.168 85.49363869317997\n", "3.939 -8.147 4.65 84.64984749543262\n", "2.541 -8.984 4.536 86.27485054174247\n", "4.168 -6.555 7.996 83.75442057587168\n", "4.471 -6.636 7.047 83.50266762804647\n", "4.966 -5.746 8.918 82.71301697435537\n", "4.958 -6.234 9.791 82.95322509703887\n", "4.352 -4.359 9.16 82.7174456931547\n", "4.475 -3.799 10.248 82.42464197677779\n", "6.389 -5.63 8.357 81.35781165321495\n", "6.787 -6.534 8.2 81.37926794952139\n", "6.985 -5.137 8.991 80.62684182082292\n", "6.392 -5.137 7.487 81.13459135904981\n", "3.703 -3.785 8.145 83.06228310129694\n", "3.681 -4.258 7.264 83.25570457332037\n", "3.025 -2.502 8.26 83.20196656329703\n", "2.657 -2.449 9.188 83.54773084291398\n", "1.853 -2.428 7.281 84.24885903678458\n", "2.03 -2.073 6.115 83.95224930280307\n", "4.043 -1.369 8.033 81.83322597820519\n", "4.817 -1.498 8.653 81.1747366426279\n", "4.364 -1.406 7.087 81.53660396410926\n", "3.455 0.008 8.284 81.89546385484363\n", "2.259 0.222 8.404 82.94646034641863\n", "4.298 1.009 8.39 80.76152065185498\n", "3.958 1.933 8.567 80.77609692848498\n", "5.28 0.848 8.294 79.8929251248194\n", "0.642 -2.672 7.79 85.47076031602855\n", "0.573 -2.867 8.768 85.62598064255965\n", "-0.596 -2.671 6.995 86.61624440600042\n", "-0.452 -3.393 6.318 86.74450388353142\n", "-0.836 -1.37 6.22 86.3804705995516\n", "-1.476 -1.403 5.173 87.00289311856243\n", "-1.793 -2.976 7.908 87.85206178570881\n", "-1.79 -2.335 8.676 87.63640534618018\n", "-2.638 -2.866 7.385 88.59570880127322\n", "-1.725 -4.409 8.453 88.32339242805384\n", "-1.615 -5.045 7.689 88.44794531248309\n", "-0.941 -4.488 9.069 87.6419380719071\n", "-2.999 -4.768 9.22 89.65858734109074\n", "-3.07 -4.206 10.044 89.54553115035947\n", "-3.8 -4.615 8.641 90.33086309230085\n", "-2.911 -6.245 9.605 90.14897384884644\n", "-2.669 -6.789 8.802 90.11430377581574\n", "-2.216 -6.368 10.313 89.58341925825336\n", "-4.199 -6.743 10.13 91.54756178621034\n", "-4.135 -7.709 10.38 91.87562893934385\n", "-4.924 -6.65 9.448 92.1569030132849\n", "-4.475 -6.233 10.944 91.64249119813363\n", "-0.287 -0.24 6.692 85.47785479292281\n", "0.234 -0.298 7.543 85.01271543716268\n", "-0.397 1.085 6.045 85.14624897198937\n", "-1.336 1.091 5.7 86.03640725878782\n", "0.54 1.275 4.851 84.21395601086554\n", "0.473 2.305 4.19 83.96566958584918\n", "-0.16 2.212 7.064 84.5640526051111\n", "0.792 2.171 7.368 83.6752575974523\n", "-0.329 3.089 6.614 84.45462394090686\n", "-1.065 2.12 8.296 85.46900439340567\n", "-2.021 2.146 8.005 86.36512819998589\n", "-0.885 1.26 8.774 85.57933033157013\n", "-0.794 3.29 9.244 84.88039197011285\n", "0.187 3.37 9.42 83.92664704371312\n", "-1.132 4.142 8.844 84.94253467492008\n", "-1.482 3.07 10.526 85.65208626180683\n", "-1.739 2.125 10.73 86.1919057742663\n", "-1.799 3.963 11.435 85.74076886755799\n", "-1.445 5.211 11.336 85.04573078644218\n", "-0.913 5.519 10.547 84.40970983245943\n", "-1.705 5.863 12.049 85.16219026070196\n", "-2.504 3.614 12.464 86.57922270960857\n", "-2.806 2.666 12.565 87.15153787512874\n", "-2.746 4.293 13.157 86.66775425150924\n", "1.456 0.331 4.621 83.6668114069133\n", "1.506 -0.426 5.273 83.86572984240941\n", "2.397 0.308 3.492 82.82385055043021\n", "2.133 1.055 2.882 82.84571953335912\n", "2.261 -1.01 2.732 83.44104117279457\n", "3.259 -1.672 2.445 82.76296793252402\n", "3.837 0.577 3.961 81.3635169716747\n", "4.118 -0.162 4.573 81.34048626606555\n", "4.437 0.594 3.161 80.82451957791027\n", "3.98 1.909 4.706 80.7596866388175\n", "3.592 2.639 4.143 80.90400728641319\n", "3.48 1.853 5.57 81.23495977717967\n", "5.45 2.235 5.001 79.25869988209496\n", "5.507 2.838 5.797 78.99490632312946\n", "5.951 1.389 5.186 79.06960311649478\n", "6.108 2.915 3.867 78.44427904570223\n", "5.63 2.893 2.989 78.93790265138794\n", "7.267 3.55 3.898 77.14136436439273\n", "8.03 3.541 4.958 76.39378384397514\n", "7.743 3.044 5.777 76.8158097594499\n", "8.902 4.031 4.951 75.40997744993695\n", "7.686 4.213 2.859 76.57513676775248\n", "7.13 4.245 2.029 77.13604731252438\n", "8.564 4.69 2.891 75.59078580091624\n", "1.015 -1.396 2.486 84.75310422633497\n", "0.275 -0.923 2.963 85.25873990389489\n", "0.658 -2.469 1.562 85.51935978478791\n", "1.3 -3.22 1.716 85.19091393452707\n", "0.794 -1.966 0.127 85.30766920974925\n", "0.837 -0.754 -0.105 84.85929481795144\n", "-0.764 -2.957 1.85 87.00290653765538\n", "-1.424 -2.211 1.757 87.3569368224413\n", "-1.017 -3.705 1.236 87.54654933805215\n", "-0.837 -3.442 3.182 87.18574103602033\n", "-0.853 -2.703 3.79 86.91065721187476\n", "0.891 -2.88 -0.831 85.62638157133581\n", "0.839 -3.847 -0.58 86.01283451322831\n", "1.071 -2.527 -2.243 85.46440172375864\n", "1.188 -1.534 -2.244 84.99964369925323\n", "-0.166 -2.89 -3.048 86.82722820060536\n", "-0.631 -4.03 -2.99 87.6686947319281\n", "2.329 -3.157 -2.848 84.60052941323713\n", "2.309 -3.031 -3.84 84.68791427942949\n", "2.34 -4.538 -2.61 85.09175678642437\n", "2.343 -4.699 -1.667 85.05534876772887\n", "3.605 -2.593 -2.223 83.14649682337794\n", "4.418 -3.013 -2.627 82.60185796336543\n", "3.628 -2.765 -1.238 83.09166775315079\n", "3.667 -1.605 -2.364 82.73918987396479\n", "-0.677 -1.927 -3.806 87.04520187236054\n", "-0.306 -1.006 -3.69 86.36728608101564\n", "-1.735 -2.103 -4.794 88.21187723317081\n", "-2.158 -2.995 -4.638 88.89767156680763\n", "-1.094 -2.04 -6.176 87.78468545822784\n", "-0.309 -1.131 -6.447 86.7832202790378\n", "-2.804 -1.014 -4.632 88.8167003496527\n", "-2.384 -0.133 -4.85 88.16160702936398\n", "-3.539 -1.203 -5.283 89.65024166169324\n", "-3.424 -0.911 -3.232 89.1977904546968\n", "-2.694 -0.836 -2.553 88.41629740042274\n", "-4.313 0.324 -3.18 89.62946796673513\n", "-4.735 0.424 -2.279 89.90308716056417\n", "-5.045 0.267 -3.858 90.41343024683887\n", "-3.786 1.153 -3.366 88.89425372879846\n", "-4.247 -2.155 -2.899 90.3493473468403\n", "-4.649 -2.085 -1.986 90.61082143430772\n", "-3.679 -2.977 -2.922 90.10548314614377\n", "-4.992 -2.278 -3.555 91.15805440003642\n", "-1.397 -3.014 -7.023 88.53443009925573\n", "-2.043 -3.716 -6.723 89.33606645134986\n", "-0.842 -3.12 -8.366 88.27843920799687\n", "-0.281 -2.306 -8.516 87.49898433696245\n", "-2.001 -3.142 -9.356 89.5220730099566\n", "-2.818 -4.056 -9.31 90.58968292802442\n", "0.088 -4.343 -8.509 87.90039305372872\n", "-0.444 -5.17 -8.326 88.66571513837803\n", "1.246 -4.293 -7.483 86.65524816766727\n", "1.825 -3.506 -7.695 85.8659568688313\n", "0.856 -4.183 -6.569 86.82632809810627\n", "0.636 -4.409 -9.945 87.68508937670076\n", "1.243 -5.195 -10.061 87.45706051543237\n", "1.156 -3.584 -10.169 86.94792076869922\n", "-0.107 -4.493 -10.609 88.5175612745855\n", "2.128 -5.548 -7.479 86.3397508335529\n", "2.86 -5.469 -6.802 85.53866523391629\n", "2.551 -5.692 -8.374 86.16532567106097\n", "1.591 -6.362 -7.258 87.11319229600072\n", "-2.039 -2.171 -10.262 89.38402182157614\n", "-1.362 -1.438 -10.199 88.49856176232468\n", "-3.021 -2.116 -11.35 90.47867870388028\n", "-3.624 -2.902 -11.214 91.27480963003975\n", "-2.298 -2.228 -12.681 90.12724128697161\n", "-1.513 -1.346 -13.046 89.18901797867268\n", "-3.885 -0.854 -11.296 90.84704193313065\n", "-3.334 -0.037 -11.466 90.10853403535094\n", "-4.42 -0.702 -10.0 91.04895169632651\n", "-5.375 -0.668 -10.051 91.93553150441889\n", "-5.041 -0.969 -12.283 92.1515992807504\n", "-5.615 -0.151 -12.259 92.42057761126576\n", "-5.619 -1.756 -12.068 92.89680078452648\n", "-4.704 -1.081 -13.218 92.07237276186596\n", "-2.534 -3.323 -13.395 90.87635786605887\n", "-3.179 -3.992 -13.026 91.6196252775572\n", "-1.91 -3.612 -14.687 90.70503063226427\n", "-1.084 -3.051 -14.736 89.77057797519184\n", "-2.88 -3.223 -15.792 91.7111480137502\n", "-3.971 -3.77 -15.877 92.90998467872008\n", "-1.493 -5.09 -14.804 90.89199104431587\n", "-2.33 -5.638 -14.787 91.84360777974697\n", "-0.733 -5.337 -16.114 90.62086978726258\n", "-0.46 -6.296 -16.195 90.7614046497739\n", "0.094 -4.777 -16.159 89.68483485517493\n", "-1.301 -5.111 -16.906 91.24514926833096\n", "-0.582 -5.5 -13.637 89.95886974612341\n", "-0.312 -6.46 -13.714 90.10257166696186\n", "-1.047 -5.381 -12.76 90.1398162467619\n", "0.251 -4.946 -13.621 88.99801472504878\n", "-2.475 -2.28 -16.637 91.23189166623696\n", "-1.629 -1.79 -16.427 90.24643723161596\n", "-3.193 -1.92 -17.85 92.07697303886569\n", "-4.154 -2.173 -17.736 93.00158672839942\n", "-2.623 -2.717 -19.023 92.14818929311633\n", "-1.493 -2.484 -19.456 91.17687816546473\n", "-3.108 -0.402 -18.053 91.56275427268449\n", "-3.569 0.042 -17.285 91.64071829159786\n", "-2.143 -0.141 -18.058 90.60404885544574\n", "-3.75 0.1 -19.356 92.34790666279338\n", "-3.298 -0.366 -20.116 92.29931274392025\n", "-5.248 -0.201 -19.401 93.8159562281385\n", "-5.655 0.13 -20.253 94.32491983033964\n", "-5.725 0.24 -18.641 93.91017093478213\n", "-5.418 -1.185 -19.341 94.26006205705575\n", "-3.583 1.614 -19.455 91.7681925996148\n", "-3.994 1.966 -20.296 92.28250987592394\n", "-2.616 1.869 -19.455 90.81098631222986\n", "-4.022 2.074 -18.683 91.82049615418117\n", "-3.416 -3.648 -19.531 93.31994842476071\n", "-4.285 -3.816 -19.065 94.02888082392558\n", "-3.127 -4.445 -20.71 93.67631327608916\n", "-2.136 -4.576 -20.749 92.85408543516003\n", "-3.594 -3.695 -21.957 94.2015280290081\n", "-4.767 -3.35 -22.073 95.16496143539385\n", "-3.839 -5.798 -20.584 94.7558883447356\n", "-4.826 -5.642 -20.553 95.56756814945119\n", "-3.615 -6.357 -21.383 94.99377372228139\n", "-3.438 -6.564 -19.339 94.33246744361138\n", "-2.269 -6.84 -19.117 93.34054624331272\n", "-4.404 -6.935 -18.537 95.11266857259342\n", "-4.195 -7.461 -17.713 94.91063138553024\n", "-5.351 -6.692 -18.749 95.92207959067609\n", "-2.679 -3.47 -22.895 93.60209025977998\n", "-1.732 -3.718 -22.69 92.78574684185065\n", "-2.961 -2.885 -24.205 94.07411623820869\n", "-3.921 -2.605 -24.232 94.84015590982546\n", "-2.693 -3.977 -25.24 94.55185724775583\n", "-1.533 -4.31 -25.503 93.74258746695655\n", "-2.11 -1.617 -24.441 92.98165558323856\n", "-1.146 -1.873 -24.509 92.23647679199374\n", "-2.213 -0.636 -23.247 92.36726175978151\n", "-3.179 -0.425 -23.098 93.11671126602356\n", "-1.841 -1.089 -22.437 91.92145965986397\n", "-2.526 -0.966 -25.775 93.5942082075595\n", "-1.99 -0.141 -25.954 92.92506392787683\n", "-3.492 -0.708 -25.762 94.364291917017\n", "-2.386 -1.595 -26.54 93.93788461531375\n", "-1.466 0.691 -23.426 91.34629622486068\n", "-1.574 1.274 -22.621 91.00557812573908\n", "-1.812 1.193 -24.218 91.76699172360397\n", "-0.488 0.536 -23.564 90.56671954421226\n", "-3.756 -4.565 -25.79 95.87121813140791\n", "-4.665 -4.211 -25.57 96.47398742148062\n", "-3.653 -5.711 -26.706 96.4952701068814\n", "-3.018 -6.339 -26.256 96.0153422219595\n", "-3.05 -5.339 -28.063 96.31903290108346\n", "-2.324 -6.137 -28.65 96.19114193105308\n", "-5.026 -6.365 -26.884 97.98260211894763\n", "-4.966 -7.162 -27.485 98.42371048685371\n", "-5.406 -6.641 -26.001 98.1150762879997\n", "-5.934 -5.46 -27.472 98.65834983923052\n", "-5.503 -4.616 -27.605 98.03968580631009\n", "-3.295 -4.116 -28.534 96.27896040153321\n", "-3.917 -3.534 -28.011 96.43526645890496\n", "-2.721 -3.564 -29.759 96.05125725881989\n", "-1.835 -4.009 -29.892 95.48907783092262\n", "-2.503 -2.054 -29.603 95.30853106097061\n", "-3.426 -1.295 -29.305 95.75947018963711\n", "-3.648 -3.877 -30.948 97.40851353962854\n", "-3.844 -4.857 -30.959 97.9115615389725\n", "-4.501 -3.367 -30.839 97.93465912535765\n", "-2.998 -3.483 -32.283 97.24391314113187\n", "-2.808 -2.501 -32.259 96.75216315411247\n", "-2.139 -3.987 -32.371 96.71392208984184\n", "-3.856 -3.776 -33.527 98.57447652409824\n", "-3.455 -3.29 -34.613 98.52280680634306\n", "-4.884 -4.482 -33.418 99.64042320765202\n", "-1.272 -1.582 -29.803 94.1672119689226\n", "-0.538 -2.224 -30.024 93.82770363277574\n", "-0.961 -0.155 -29.71 93.41392295048955\n", "-1.475 0.187 -28.923 93.45512727507248\n", "-1.447 0.565 -30.957 94.10884998766056\n", "-0.874 0.453 -32.041 94.08528349853657\n", "0.528 0.091 -29.43 91.93692034215633\n", "1.075 -0.397 -30.111 91.88603664322451\n", "0.808 -0.413 -28.003 91.30236625082614\n", "0.35 0.185 -27.345 91.26723856346263\n", "0.458 -1.345 -27.907 91.86975199161037\n", "0.903 1.585 -29.539 91.20214046830259\n", "1.876 1.725 -29.353 90.24161028594291\n", "0.383 2.134 -28.884 91.23809873073857\n", "0.711 1.937 -30.455 91.63203170289306\n", "2.29 -0.42 -27.698 89.90233201091058\n", "2.463 -0.749 -26.77 89.50950707606427\n", "2.676 0.499 -27.776 89.30496419572653\n", "2.784 -1.016 -28.332 89.91350875702716\n", "-2.481 1.374 -30.77 94.69821328831921\n", "-2.898 1.4 -29.862 94.70213377215953\n", "-3.044 2.223 -31.803 95.36207792933205\n", "-2.872 1.714 -32.646 95.69628703873519\n", "-2.37 3.599 -31.886 94.43505680625178\n", "-1.909 4.177 -30.9 93.4810482878749\n", "-4.529 2.429 -31.54 96.50095442533197\n", "-4.626 2.83 -30.629 96.12230073193213\n", "-4.876 3.07 -32.225 96.90686593838436\n", "-5.383 1.155 -31.598 97.62420235269529\n", "-5.289 0.726 -32.497 98.01794387253794\n", "-5.084 0.515 -30.89 97.26944878017969\n", "-6.845 1.535 -31.361 98.7124201405274\n", "-7.582 0.841 -30.641 99.28179746056172\n", "-7.228 2.65 -31.785 98.91557285887798\n", "-2.437 4.219 -33.069 94.82012344434064\n", "-2.901 3.756 -33.824 95.66041509422796\n", "-1.859 5.551 -33.312 94.08471077172953\n", "-0.894 5.428 -33.079 93.17535445599334\n", "-2.442 6.654 -32.41 93.95371495050102\n", "-1.787 7.671 -32.163 93.04178436595032\n", "-2.026 5.95 -34.778 94.76407155140602\n", "-1.542 6.804 -34.969 94.22750994269136\n", "-1.683 5.23 -35.381 94.90643344368178\n", "-3.396 6.154 -35.088 96.04133371106421\n", "-3.505 6.2 -36.038 96.54093078067974\n", "-3.667 6.468 -31.891 94.86442773242244\n", "-4.17 5.644 -32.152 95.60907446994767\n", "-4.31 7.409 -30.96 94.84780721766845\n", "-4.184 8.304 -31.387 94.71010897470237\n", "-3.604 7.465 -29.605 93.6753447338199\n", "-3.573 8.54 -29.007 93.18149913475312\n", "-5.824 7.122 -30.825 96.21011773197245\n", "-6.213 7.806 -30.208 96.17096686630532\n", "-6.237 7.217 -31.731 96.91290957349283\n", "-6.201 5.729 -30.28 96.65703494831608\n", "-5.893 5.034 -30.93 96.79867875131353\n", "-5.743 5.591 -29.402 95.94815531838013\n", "-7.722 5.579 -30.076 97.97751047051561\n", "-8.021 6.139 -29.303 97.83043036806083\n", "-8.208 5.863 -30.902 98.65861942070748\n", "-8.084 4.183 -29.793 98.53331166158985\n", "-7.416 3.514 -30.118 98.22479992853128\n", "-9.129 3.652 -29.188 99.38284097368117\n", "-10.1 4.378 -28.712 99.90956449209453\n", "-10.069 5.374 -28.799 99.67598716340862\n", "-10.877 3.94 -28.259 100.56072901983158\n", "-9.228 2.366 -29.045 99.7504021144777\n", "-8.508 1.767 -29.395 99.39150580909819\n", "-10.025 1.974 -28.585 100.40645601254931\n", "-3.0 6.367 -29.152 93.21566815723631\n", "-2.958 5.568 -29.752 93.60280017713146\n", "-2.395 6.267 -27.823 92.19624012941091\n", "-3.069 6.662 -27.199 92.47679969051697\n", "-1.126 7.112 -27.663 90.79765982667175\n", "-0.848 7.573 -26.564 90.03056195537157\n", "-2.151 4.79 -27.495 92.22510862557982\n", "-1.562 4.408 -28.207 92.06584451358712\n", "-1.682 4.743 -26.613 91.49528662723561\n", "-3.395 3.916 -27.405 93.53115113693404\n", "-4.622 4.418 -26.922 94.32734619928624\n", "-4.686 5.372 -26.629 94.04164910293736\n", "-3.308 2.562 -27.769 93.95186338758799\n", "-2.436 2.187 -28.084 93.39939060829037\n", "-5.755 3.591 -26.849 95.53454239174435\n", "-6.623 3.959 -26.517 96.10670835066614\n", "-4.439 1.731 -27.693 95.16192678797543\n", "-4.37 0.77 -27.96 95.47229108490065\n", "-5.666 2.246 -27.243 95.95311464460129\n", "-6.473 1.657 -27.203 96.82389197920108\n", "-0.428 7.444 -28.753 90.51436048495287\n", "-0.7 7.053 -29.632 91.19374793262968\n", "0.723 8.359 -28.717 89.26502478574685\n", "1.262 8.035 -27.94 88.55414080662744\n", "0.349 9.827 -28.45 89.17356328531454\n", "1.227 10.646 -28.192 88.11629817462827\n", "1.493 8.26 -30.037 89.13662569897966\n", "0.885 8.53 -30.783 89.92044095198821\n", "2.273 8.884 -30.0 88.29228068183536\n", "2.015 6.873 -30.336 89.12710342538907\n", "3.213 6.426 -29.752 87.94647977036944\n", "3.719 7.025 -29.131 87.09802905921579\n", "1.287 6.024 -31.182 90.32542775985064\n", "0.426 6.337 -31.583 91.16868692155218\n", "3.703 5.137 -30.039 87.97167245198875\n", "4.556 4.82 -29.625 87.14390423890818\n", "1.766 4.736 -31.467 90.35823153426585\n", "1.242 4.13 -32.065 91.22583578131798\n", "2.983 4.296 -30.913 89.18811093974352\n", "3.447 3.069 -31.244 89.26944810516082\n", "2.713 2.46 -31.322 90.10857126822064\n", "-0.936 10.203 -28.537 90.28254628110574\n", "-1.631 9.502 -28.696 91.11311400671146\n", "-1.364 11.609 -28.407 90.34287169998528\n", "-0.62 12.118 -28.839 89.74651593237478\n", "-1.486 12.086 -26.962 89.81558529008203\n", "-1.3 13.271 -26.709 89.34184100968594\n", "-2.7 11.834 -29.124 91.78578332726697\n", "-3.373 11.192 -28.757 92.3714318877866\n", "-3.004 12.771 -28.95 91.82744052841721\n", "-2.594 11.624 -30.639 92.32853200392606\n", "-1.878 12.217 -31.007 91.72951901650852\n", "-2.365 10.669 -30.827 92.37945738095672\n", "-3.931 11.967 -31.304 93.73444618175326\n", "-4.643 11.357 -30.956 94.34417510901243\n", "-4.173 12.915 -31.097 93.7055922877605\n", "-3.807 11.792 -32.819 94.27705876298856\n", "-3.097 12.402 -33.171 93.68647531527697\n", "-3.567 10.844 -33.029 94.32477948556254\n", "-5.082 12.114 -33.507 95.64499511213327\n", "-4.995 11.998 -34.496 96.00623208938053\n", "-5.355 13.06 -33.332 95.65771151350005\n", "-5.82 11.518 -33.191 96.27619918754581\n", "-1.836 11.189 -26.044 89.96543459573793\n", "-1.92 10.234 -26.328 90.33408949560514\n", "-2.105 11.517 -24.645 89.65169389364598\n", "-1.709 12.424 -24.503 89.07006422474389\n", "-1.443 10.489 -23.73 88.93094249472452\n", "-1.422 9.308 -24.081 89.27898215145599\n", "-3.616 11.543 -24.369 90.9416549387573\n", "-3.991 10.633 -24.543 91.5203030043061\n", "-3.765 11.788 -23.411 90.7125188989921\n", "-4.374 12.525 -25.219 91.75443620337929\n", "-5.113 12.211 -26.335 92.88035918319868\n", "-5.235 11.298 -26.723 93.29493909639471\n", "-4.461 13.879 -25.041 91.54640118540979\n", "-4.03 14.405 -24.308 90.81300416790538\n", "-5.641 13.35 -26.81 93.3416889497935\n", "-6.238 13.409 -27.61 94.16878515729084\n", "-5.26 14.397 -26.066 92.56113686639766\n", "-0.967 10.902 -22.548 88.0128141124916\n", "-0.332 9.985 -21.621 87.31372732279844\n", "0.282 9.369 -22.115 87.0432198565747\n", "-1.369 9.093 -20.93 88.24526435452499\n", "-2.482 9.528 -20.613 89.08398077095566\n", "0.418 10.885 -20.643 86.12012142931522\n", "0.477 10.459 -19.74 85.8730676813167\n", "1.339 11.086 -20.978 85.33376447807748\n", "-0.433 12.153 -20.594 86.64476626432781\n", "-1.188 12.056 -19.945 87.16649437714011\n", "0.119 12.949 -20.347 85.90562311048095\n", "-0.949 12.264 -22.027 87.56165688816081\n", "-1.874 12.643 -22.051 88.35827324591624\n", "-0.343 12.828 -22.588 87.08271366924666\n", "-0.977 7.857 -20.631 88.07223536393293\n", "-0.151 7.497 -21.065 87.53358266402671\n", "-1.704 7.005 -19.695 88.66360950807268\n", "-2.682 7.13 -19.862 89.58690016403067\n", "-1.346 7.44 -18.281 87.81748303156951\n", "-0.171 7.506 -17.932 86.612171754321\n", "-1.357 5.535 -19.929 88.78274689375182\n", "-0.362 5.437 -19.957 87.90382983124226\n", "-1.725 4.991 -19.175 89.04209419145529\n", "-1.925 5.003 -21.223 89.83512801794184\n", "-3.226 4.47 -21.252 91.17412403198617\n", "-3.775 4.447 -20.416 91.43260268088183\n", "-1.163 5.056 -22.401 89.49936053961501\n", "-0.242 5.445 -22.386 88.55576522169518\n", "-3.757 3.969 -22.454 92.16446595624585\n", "-4.679 3.583 -22.471 93.11316666293763\n", "-1.698 4.561 -23.6 90.50897050569075\n", "-1.156 4.6 -24.439 90.29308565997731\n", "-2.991 4.011 -23.629 91.8355373806894\n", "-3.364 3.651 -24.484 92.55333600686687\n", "-2.341 7.778 -17.469 88.4382407841766\n", "-3.279 7.664 -17.795 89.4291016671866\n", "-2.133 8.311 -16.117 87.7611284909213\n", "-1.144 8.388 -15.99 86.7830235760428\n", "-2.709 7.349 -15.093 88.27040424740333\n", "-3.908 7.084 -15.121 89.46746893703879\n", "-2.778 9.694 -15.972 88.02272141328055\n", "-3.769 9.59 -16.057 89.00115590822402\n", "-2.361 10.545 -17.017 87.7256317047646\n", "-2.267 10.038 -17.823 87.96278716025316\n", "-2.4 10.377 -14.658 87.19303730229839\n", "-2.831 11.276 -14.585 87.40161079179262\n", "-1.41 10.504 -14.592 86.21293546214511\n", "-2.693 9.831 -13.873 87.39885867675846\n", "-1.881 6.851 -14.18 87.39405328167358\n", "-0.897 6.979 -14.302 86.46791072415246\n", "-2.352 6.129 -13.012 87.74981088298709\n", "-3.142 5.606 -13.332 88.69857670222223\n", "-2.763 7.114 -11.918 87.65394323132303\n", "-2.057 8.086 -11.637 86.69218032210287\n", "-1.298 5.16 -12.487 86.89794408385045\n", "-1.054 4.577 -13.262 87.0016523176428\n", "-0.512 5.724 -12.234 85.95416432611044\n", "-1.968 4.223 -11.088 87.4887343033376\n", "-3.892 6.835 -11.283 88.66105433052326\n", "-4.427 6.06 -11.62 89.42845209439777\n", "-4.417 7.558 -10.142 88.76399143796993\n", "-3.785 8.311 -9.961 87.95128752894979\n", "-4.474 6.644 -8.93 88.81942200329836\n", "-5.061 5.567 -8.986 89.65895386964985\n", "-5.809 8.094 -10.477 90.03125644463704\n", "-6.329 7.378 -10.942 90.78114103711188\n", "-6.273 8.346 -9.628 90.26181024109808\n", "-5.765 9.308 -11.373 89.89546340611409\n", "-5.734 10.59 -10.798 89.48669139598356\n", "-5.774 10.69 -9.804 89.31762095465821\n", "-5.685 9.164 -12.768 90.13875637038709\n", "-5.701 8.253 -13.181 90.44357061726387\n", "-5.647 11.731 -11.612 89.34291560610724\n", "-5.64 12.642 -11.2 89.08606856854779\n", "-5.582 10.306 -13.581 89.98012937310102\n", "-5.517 10.205 -14.574 90.16630879103346\n", "-5.57 11.588 -13.007 89.5903239306567\n", "-5.507 12.397 -13.591 89.50991488097841\n", "-3.94 7.125 -7.814 88.00323654275448\n", "-3.39 7.958 -7.878 87.28780579783181\n", "-4.105 6.518 -6.507 88.10717369771885\n", "-4.595 5.654 -6.619 88.81155814982641\n", "-4.935 7.451 -5.626 88.54942604557073\n", "-4.567 8.609 -5.429 87.89871301674445\n", "-2.732 6.226 -5.919 86.78249981419064\n", "-2.21 5.614 -6.514 86.53212929889105\n", "-2.811 5.789 -5.023 86.84729981985623\n", "-2.205 7.068 -5.805 86.04853795968877\n", "-6.064 6.987 -5.093 89.67491062164488\n", "-6.288 6.02 -5.215 90.1431537833018\n", "-6.994 7.834 -4.334 90.27714515313386\n", "-6.487 8.651 -4.061 89.56978654658053\n", "-7.434 7.184 -3.031 90.70581122508082\n", "-7.675 5.985 -2.962 91.22062944860663\n", "-8.167 8.23 -5.246 91.43487783116461\n", "-7.818 8.822 -5.972 91.06448895700233\n", "-8.55 7.399 -5.648 92.04506043237734\n", "-9.291 8.976 -4.509 92.2692219594378\n", "-9.716 8.358 -3.847 92.73733669887226\n", "-8.903 9.763 -4.03 91.67194635765077\n", "-10.36 9.467 -5.486 93.32564437495193\n", "-9.946 10.093 -6.147 92.88555906598182\n", "-10.756 8.686 -5.968 93.93520492871669\n", "-11.456 10.197 -4.706 94.14803807833702\n", "-11.788 9.613 -3.965 94.50106612626124\n", "-11.09 11.045 -4.324 93.58430051028859\n", "-12.603 10.536 -5.584 95.30814468868859\n", "-13.318 11.013 -5.072 95.85258372104529\n", "-13.007 9.711 -5.98 95.91127784051258\n", "-12.316 11.129 -6.336 95.01723080578596\n", "-7.624 8.022 -2.017 90.59436531043195\n", "-7.203 8.927 -2.071 89.98976731829013\n", "-8.409 7.701 -0.832 91.32462789959781\n", "-9.079 7.0 -1.077 92.15626030281393\n", "-9.232 8.916 -0.374 91.82019096582188\n", "-9.363 9.901 -1.103 91.80044661111404\n", "-7.473 7.105 0.224 90.47600825080646\n", "-8.041 6.72 0.951 91.07029467943978\n", "-6.949 6.374 -0.213 90.17721309177834\n", "-6.476 8.035 0.883 89.2476478289484\n", "-6.479 9.249 0.726 88.98946115692576\n", "-5.63 7.442 1.689 88.51775696435149\n", "-4.961 7.984 2.198 87.7138172239699\n", "-5.653 6.448 1.795 88.77656576484584\n", "-9.824 8.86 0.82 92.3268355409195\n", "-9.722 8.029 1.367 92.37602794556605\n", "-10.623 9.973 1.368 92.84471078634473\n", "-11.245 10.194 0.617 93.45430019533612\n", "-9.795 11.215 1.705 91.77380601239112\n", "-10.367 12.283 1.893 92.13045558337373\n", "-11.379 9.535 2.631 93.61075044032069\n", "-11.783 10.338 3.069 93.82950596161102\n", "-10.483 8.972 3.566 92.8166494978137\n", "-10.932 8.845 4.402 93.2589964024919\n", "-12.435 8.475 2.313 94.87643090884059\n", "-12.922 8.195 3.14 95.37806170184\n", "-12.016 7.66 1.913 94.66277493291648\n", "-13.109 8.825 1.662 95.49282620699839\n", "-8.468 11.092 1.796 90.4917884064626\n", "-8.063 10.214 1.542 90.2830580120102\n", "-7.566 12.156 2.243 89.38423399011707\n", "-8.163 12.844 2.656 89.82870977588401\n", "-6.818 12.84 1.098 88.58920510423377\n", "-6.327 13.954 1.271 87.90455713442847\n", "-6.576 11.572 3.257 88.47891155524009\n", "-6.004 10.89 2.801 88.0705945137195\n", "-5.999 12.307 3.612 87.76145591887133\n", "-7.264 10.91 4.418 89.24675990197066\n", "-7.337 9.557 4.66 89.58992486323447\n", "-6.923 8.837 4.103 89.35520518693916\n", "-7.989 11.537 5.392 89.81851170554987\n", "-8.135 12.523 5.476 89.77951468458716\n", "-8.062 9.374 5.777 90.32046652891026\n", "-8.255 8.486 6.195 90.69874206955684\n", "-8.489 10.554 6.25 90.49281297429094\n", "-6.705 12.201 -0.065 88.67326394128051\n", "-7.114 11.294 -0.163 89.25242128928491\n", "-6.004 12.786 -1.196 87.97206368501308\n", "-6.47 13.64 -1.426 88.30094996657736\n", "-5.071 12.985 -0.898 86.99618449679272\n", "-5.959 11.892 -2.423 88.20920691741877\n", "-6.436 10.755 -2.427 88.89621298458107\n", "-5.376 12.458 -3.472 87.6479230387121\n", "-5.065 13.403 -3.371 87.16355253200732\n", "-5.153 11.814 -4.759 87.7078887272975\n", "-5.357 10.84 -4.657 88.08403068093557\n", "-3.683 12.026 -5.114 86.2845446415521\n", "-3.173 13.137 -4.958 85.56060841882787\n", "-6.102 12.383 -5.841 88.67078357046361\n", "-5.878 13.348 -5.98 88.3011071787891\n", "-7.582 12.297 -5.396 90.067116874029\n", "-7.826 11.331 -5.305 90.47184014377069\n", "-7.668 12.748 -4.508 89.95710814049104\n", "-5.899 11.626 -7.164 88.80955520663302\n", "-6.505 11.98 -7.876 89.4429612658257\n", "-6.093 10.651 -7.053 89.17120935593506\n", "-4.957 11.717 -7.488 87.93037116377934\n", "-8.59 12.946 -6.351 91.06663196802657\n", "-9.523 12.854 -6.004 91.94408017920456\n", "-8.555 12.518 -7.254 91.23923307437431\n", "-8.399 13.921 -6.465 90.7343609334413\n", "-3.026 10.973 -5.571 85.9187761260599\n", "-3.464 10.079 -5.473 86.51586635409714\n", "-1.714 11.011 -6.207 84.73422266711366\n", "-1.381 11.954 -6.2 84.22038007513383\n", "-1.864 10.558 -7.664 85.20513231607589\n", "-2.758 9.764 -7.978 86.28833008582329\n", "-0.728 10.155 -5.396 83.84538683791732\n", "-0.887 10.323 -4.423 83.82917338254028\n", "-0.901 9.192 -5.601 84.25785915272236\n", "0.741 10.456 -5.703 82.40695325638487\n", "1.008 11.555 -6.24 81.99657416014402\n", "1.594 9.634 -5.298 81.71134071229037\n", "-1.052 11.108 -8.562 84.46403554768148\n", "-0.336 11.729 -8.243 83.59133095602677\n", "-1.161 10.844 -9.993 84.89117068930078\n", "-1.547 9.925 -10.076 85.47290359523302\n", "0.214 10.846 -10.66 83.70860713809542\n", "1.001 11.774 -10.465 82.72349584610166\n", "-2.103 11.868 -10.641 85.71654804645365\n", "-3.0 11.86 -10.199 86.4929406483558\n", "-2.237 11.668 -11.612 86.08406296173524\n", "-1.732 12.794 -10.567 85.16932293965944\n", "0.475 9.833 -11.481 83.85287168606689\n", "-0.206 9.105 -11.562 84.68213375913481\n", "1.696 9.722 -12.269 82.89356902679482\n", "2.026 10.653 -12.428 82.4103055570115\n", "1.401 9.073 -13.621 83.63825252837364\n", "0.438 8.317 -13.751 84.75454670399694\n", "2.744 8.939 -11.479 81.90777317813004\n", "2.927 9.374 -10.598 81.44127837896454\n", "3.607 8.887 -11.982 81.2181788086879\n", "2.435 8.005 -11.302 82.38932878109883\n", "2.206 9.369 -14.64 83.06547507839824\n", "3.05 9.875 -14.462 82.11129424141357\n", "1.889 8.974 -16.012 83.81402932683764\n", "1.195 8.262 -15.907 84.60272587216087\n", "3.032 8.292 -16.769 83.12047144957732\n", "4.204 8.433 -16.42 81.90029942558208\n", "1.337 10.192 -16.764 84.26060457888964\n", "0.983 9.882 -17.646 84.90707739641024\n", "0.592 10.583 -16.224 84.72777729882922\n", "2.345 11.295 -17.03 83.15694826651588\n", "2.421 12.4 -16.161 82.62010361286167\n", "1.794 12.467 -15.385 82.98903047391263\n", "3.222 11.205 -18.129 82.67693760051833\n", "3.161 10.426 -18.753 83.08857180743931\n", "3.376 13.41 -16.381 81.58970980460708\n", "3.428 14.194 -15.763 81.22676599496006\n", "4.183 12.209 -18.35 81.64307020807094\n", "4.811 12.139 -19.125 81.31433852648621\n", "4.26 13.313 -17.477 81.09430206247538\n", "5.188 14.281 -17.688 80.11136672158327\n", "6.058 13.884 -17.738 79.38509727272493\n", "2.657 7.582 -17.836 83.94777324027123\n", "1.681 7.385 -17.926 84.92488976148276\n", "3.536 7.064 -18.887 83.58273734450194\n", "4.458 7.375 -18.658 82.5874785303438\n", "3.065 7.643 -20.223 84.2837056968902\n", "1.908 7.473 -20.617 85.51000509297143\n", "3.556 5.518 -18.932 83.98891386962924\n", "2.635 5.188 -19.139 84.9827332874155\n", "3.968 4.937 -17.565 83.36924101249812\n", "4.881 5.278 -17.342 82.3733694102651\n", "3.315 5.258 -16.879 83.68224720333458\n", "4.511 5.035 -20.042 83.6001437379147\n", "4.535 4.036 -20.084 83.87834786165021\n", "5.443 5.359 -19.879 82.61353406070944\n", "4.221 5.374 -20.937 84.05686216484648\n", "4.005 3.404 -17.506 83.76578790890706\n", "4.278 3.087 -16.598 83.35673085000394\n", "4.657 3.035 -18.169 83.47952542989209\n", "3.106 3.016 -17.71 84.7586771310171\n", "3.957 8.326 -20.936 83.53169836654824\n", "4.849 8.513 -20.525 82.53706419542677\n", "3.701 8.817 -22.289 84.1026837027214\n", "2.711 8.82 -22.431 85.05171991794168\n", "4.323 7.868 -23.315 84.12553779322899\n", "5.545 7.733 -23.383 83.08332904981599\n", "4.227 10.253 -22.414 83.34069954710003\n", "3.712 10.832 -21.782 83.46916142504368\n", "5.193 10.257 -22.157 82.37026875032034\n", "4.098 10.843 -23.829 83.83344088727361\n", "4.511 11.754 -23.836 83.27272218439842\n", "4.586 10.25 -24.47 83.75405853449729\n", "2.654 10.969 -24.299 85.2891565616638\n", "1.834 11.632 -23.686 85.68396529689787\n", "2.288 10.342 -25.393 86.15276906751168\n", "1.344 10.411 -25.717 87.11247035298678\n", "2.953 9.796 -25.903 85.86131464751747\n", "3.491 7.248 -24.152 85.3275983958297\n", "2.505 7.35 -24.02 86.1429302961073\n", "3.978 6.424 -25.257 85.50565332187107\n", "4.736 5.885 -24.891 84.83652191715545\n", "4.494 7.324 -26.384 85.24548795684144\n", "3.823 8.286 -26.771 85.75874939036832\n", "2.89 5.453 -25.746 86.91102398430246\n", "2.16 5.994 -26.164 87.57514431047201\n", "3.299 4.855 -26.435 86.96803680663372\n", "2.26 4.564 -24.654 87.31450613157013\n", "1.751 5.168 -24.041 87.38941435322701\n", "1.349 3.529 -25.313 88.65076404634084\n", "0.925 2.937 -24.628 88.95380648966068\n", "1.864 2.949 -25.945 88.5893144515748\n", "0.617 3.973 -25.83 89.36512356059268\n", "3.291 3.82 -23.805 86.30266891006326\n", "2.844 3.256 -23.111 86.62362803531147\n", "3.899 4.461 -23.336 85.4133635270266\n", "3.856 3.22 -24.371 86.17601154613736\n", "5.675 7.018 -26.914 84.48474579472912\n", "6.173 6.244 -26.522 84.09247076879117\n", "6.301 7.734 -28.033 84.20575788507576\n", "5.583 8.325 -28.4 84.84400054806467\n", "6.729 6.75 -29.125 84.53537449494146\n", "7.001 5.581 -28.854 84.4950496833986\n", "7.464 8.639 -27.566 82.77152874026189\n", "7.907 9.01 -28.382 82.63537992893842\n", "8.548 7.858 -26.796 81.69683708075851\n", "8.18 7.601 -25.902 81.72575928065764\n", "8.773 7.033 -27.314 81.92581339846433\n", "6.918 9.801 -26.717 82.6358613375573\n", "7.659 10.397 -26.406 81.71925702672533\n", "6.439 9.46 -25.908 82.81804919218999\n", "6.275 10.358 -27.243 83.29489084571753\n", "9.841 8.652 -26.573 80.27267994155919\n", "10.514 8.108 -26.071 79.61402744491701\n", "9.664 9.484 -26.047 80.01021023594426\n", "10.251 8.921 -27.444 80.21237972407998\n", "6.767 7.223 -30.373 84.91688271480531\n", "6.444 8.152 -30.554 85.04733423805827\n", "7.27 6.413 -31.479 85.17861930672508\n", "6.728 5.573 -31.452 85.85214409669685\n", "8.76 6.099 -31.276 83.8981554862799\n", "9.504 6.988 -30.847 82.83563917783214\n", "7.055 7.114 -32.826 85.79363463567678\n", "7.363 8.062 -32.746 85.26160420728665\n", "7.598 6.644 -33.522 85.77353650747996\n", "5.612 7.126 -33.285 87.23282915279086\n", "5.038 5.949 -33.804 88.25516772404887\n", "5.587 5.116 -33.877 88.03979911948913\n", "4.839 8.299 -33.179 87.56790988712702\n", "5.248 9.136 -32.815 86.86000035689614\n", "3.693 5.942 -34.22 89.59369437633431\n", "3.29 5.108 -34.597 90.32251780148734\n", "3.491 8.293 -33.585 88.91452831793013\n", "2.941 9.124 -33.505 89.16877202810409\n", "2.916 7.112 -34.105 89.92000941948349\n", "1.611 7.107 -34.488 91.21689188412418\n", "1.559 7.106 -35.444 91.69591722645016\n", "9.208 4.88 -31.616 84.0069766686077\n", "10.606 4.498 -31.492 82.88200632827369\n", "10.919 4.658 -30.556 82.14577844296078\n", "11.472 5.365 -32.402 82.33330884884926\n", "11.182 5.556 -33.59 83.08962195725769\n", "10.674 3.012 -31.846 83.43103540649605\n", "11.507 2.804 -32.358 83.0413766986073\n", "10.639 2.446 -31.022 83.25996550563782\n", "9.437 2.791 -32.709 84.927252245672\n", "9.639 2.97 -33.672 85.1555338659796\n", "9.096 1.856 -32.608 85.45255938238479\n", "8.426 3.793 -32.176 85.23220709332828\n", "7.842 4.144 -32.909 85.95792313684643\n", "7.857 3.388 -31.461 85.5094283047197\n", "12.553 5.907 -31.844 81.01449011750923\n", "12.752 5.718 -30.882 80.44932741173166\n", "13.457 6.771 -32.602 80.38829908015221\n", "12.886 7.369 -33.164 80.9781500282638\n", "14.322 5.894 -33.502 80.36076048047329\n", "15.194 5.155 -33.043 79.63164714483808\n", "14.29 7.68 -31.679 79.00358841217277\n", "14.844 7.084 -31.098 78.42187004273744\n", "15.193 8.612 -32.504 78.41617004164384\n", "15.736 9.204 -31.909 77.52033940844169\n", "14.65 9.197 -33.106 79.02145719992765\n", "15.825 8.087 -33.074 78.31607424405286\n", "13.381 8.56 -30.81 79.1235553801774\n", "13.921 9.151 -30.21 78.23617749481375\n", "12.784 8.001 -30.234 79.50229145125314\n", "12.801 9.145 -31.377 79.73724498626723\n", "14.12 5.979 -34.82 81.16653358373756\n", "13.371 6.547 -35.16 81.79535628017032\n", "14.965 5.263 -35.784 81.18255537367617\n", "14.87 4.298 -35.539 81.41377869869447\n", "16.416 5.72 -35.646 79.81646234330358\n", "16.76 6.863 -35.955 79.3863589982561\n", "14.494 5.455 -37.232 82.26846077325138\n", "15.228 5.18 -37.853 82.09596329905631\n", "14.25 6.816 -37.492 82.2316154833407\n", "14.195 6.956 -38.437 82.74891905638405\n", "13.213 4.681 -37.528 83.6686115159084\n", "12.922 4.818 -38.475 84.36459917524648\n", "12.468 4.979 -36.931 83.87114046559758\n", "13.346 3.7 -37.386 83.77312708142152\n", "17.292 4.825 -35.187 79.13805564328706\n", "16.971 3.9 -34.983 79.56808981620709\n", "18.699 5.14 -34.971 77.81364598192272\n", "18.738 6.054 -34.567 77.29687891499889\n", "19.463 5.227 -36.309 77.91307588588708\n", "20.019 4.245 -36.81 78.05900871135887\n", "19.29 4.143 -33.959 77.11852816930572\n", "18.676 4.07 -33.173 77.21997048691483\n", "19.382 3.248 -34.395 77.56346081757827\n", "20.657 4.583 -33.465 75.64088189596946\n", "21.299 5.454 -34.032 75.16795628457646\n", "21.153 3.999 -32.4 74.87952479149423\n", "22.053 4.267 -32.056 73.90331830844944\n", "20.631 3.285 -31.932 75.28731960297165\n", "19.519 6.43 -36.886 77.83814653497345\n", "19.045 7.187 -36.436 77.74766358547373\n", "20.231 6.712 -38.138 77.91562269532342\n", "19.942 5.969 -38.742 78.69535342064357\n", "21.763 6.633 -38.027 76.70076783188027\n", "22.442 6.709 -39.056 76.76988314436852\n", "19.803 8.083 -38.681 78.186856657625\n", "19.901 8.76 -37.952 77.51557951792658\n", "20.402 8.325 -39.444 78.10868918372654\n", "18.372 8.132 -39.176 79.56824779395359\n", "18.033 7.525 -40.401 80.69607458854487\n", "18.738 7.068 -40.943 80.59364782661223\n", "17.38 8.786 -38.422 79.74997369905522\n", "17.616 9.216 -37.551 78.96864095322901\n", "16.706 7.561 -40.863 81.97981333840666\n", "16.465 7.122 -41.729 82.78202827304969\n", "16.058 8.834 -38.893 81.04683950654707\n", "15.357 9.311 -38.363 81.19430348244882\n", "15.718 8.214 -40.107 82.15226527613221\n", "14.773 8.237 -40.433 83.07435583861002\n", "22.342 6.452 -36.829 75.61909080384396\n", "21.763 6.331 -36.023 75.64154002927226\n", "23.802 6.427 -36.67 74.42298302271952\n", "24.082 7.323 -37.013 74.14988034380096\n", "24.455 5.321 -37.499 74.75353911354297\n", "25.485 5.565 -38.122 74.28551727624973\n", "24.218 6.257 -35.203 73.31368196319156\n", "23.663 5.531 -34.797 73.73257376492427\n", "25.183 5.995 -35.174 72.64380442267598\n", "24.035 7.534 -34.373 72.60482232606867\n", "24.575 8.269 -34.782 72.2107468525288\n", "23.068 7.789 -34.375 73.2838135129443\n", "24.488 7.334 -32.93 71.50647741988134\n", "24.234 6.32 -32.305 71.67027254029385\n", "25.191 8.278 -32.343 70.35733946789063\n", "25.506 8.155 -31.402 69.62952834825178\n", "25.411 9.119 -32.838 70.22368461566225\n", "23.853 4.126 -37.581 75.62904598763625\n", "22.989 3.982 -37.099 76.04335961147429\n", "24.431 3.018 -38.363 76.0260916856838\n", "25.368 2.928 -38.025 75.17108735411507\n", "24.502 3.339 -39.859 76.76207211246971\n", "25.525 3.08 -40.489 76.49529512983135\n", "23.662 1.712 -38.11 76.88992545841099\n", "22.683 1.89 -38.213 77.61056413272615\n", "23.951 1.033 -38.785 77.31198733702296\n", "23.919 1.152 -36.701 76.0890593252407\n", "24.903 1.037 -36.567 75.32928510214337\n", "23.563 1.794 -36.022 75.74086136293936\n", "23.225 -0.206 -36.522 76.99967244086172\n", "22.241 -0.092 -36.658 77.76392371787833\n", "23.583 -0.849 -37.199 77.35942136546782\n", "23.478 -0.763 -35.115 76.24484839646544\n", "24.455 -0.94 -34.996 75.5242411415037\n", "23.174 -0.099 -34.432 75.84785353587799\n", "22.743 -2.035 -34.886 77.1644732308852\n", "22.916 -2.388 -33.966 76.6864394074989\n", "23.025 -2.735 -35.542 77.58967223155412\n", "21.757 -1.902 -34.984 77.90146273337875\n", "23.457 3.956 -40.413 77.65895230429005\n", "22.654 4.146 -39.848 77.84988917782734\n", "23.444 4.365 -41.82 78.4002655990399\n", "23.769 3.571 -42.334 78.73285579095933\n", "24.417 5.516 -42.092 77.51868448316186\n", "25.145 5.469 -43.082 77.63985098517384\n", "22.013 4.712 -42.251 79.6008483434693\n", "21.603 5.32 -41.571 79.30716808082356\n", "22.039 5.173 -43.138 79.99300905079143\n", "21.146 3.486 -42.377 80.68590177967894\n", "21.301 2.483 -43.309 81.4574546496513\n", "21.999 2.449 -44.025 81.40816918467088\n", "20.079 3.144 -41.59 81.10620605107849\n", "19.713 3.678 -40.828 80.7632329714456\n", "20.352 1.559 -43.089 82.31121718818157\n", "20.229 0.726 -43.628 83.0021375628363\n", "19.594 1.915 -42.043 82.1252917620388\n", "24.502 6.5 -41.192 76.60635535645851\n", "23.894 6.479 -40.398 76.56598347830452\n", "25.453 7.61 -41.323 75.68560579793227\n", "25.296 7.984 -42.237 76.27822429763293\n", "26.91 7.139 -41.262 74.7330477499747\n", "27.723 7.556 -42.087 74.57179083943203\n", "25.164 8.674 -40.252 74.93447775890614\n", "24.971 8.222 -39.381 74.65815192596183\n", "25.963 9.266 -40.151 74.12989367994534\n", "23.956 9.526 -40.653 75.85608828564784\n", "23.223 8.867 -40.822 76.6722257991771\n", "23.74 10.064 -39.838 75.37908944130328\n", "24.284 10.574 -42.1 76.27129581303834\n", "22.594 10.864 -42.679 77.81701216315106\n", "22.589 11.442 -43.495 78.21109274904678\n", "22.048 11.32 -41.976 77.67896632293711\n", "22.141 10.003 -42.909 78.49704681069218\n", "27.238 6.21 -40.357 74.1962987351795\n", "26.545 5.918 -39.697 74.36804473024687\n", "28.574 5.601 -40.292 73.39526664574494\n", "29.227 6.354 -40.21 72.65120100865504\n", "28.879 4.849 -41.596 74.25935526921842\n", "29.955 5.031 -42.167 73.8370135501159\n", "28.702 4.703 -39.037 72.79881902201436\n", "27.933 4.064 -39.039 73.55629099540025\n", "28.661 5.563 -37.75 71.74881588569946\n", "29.541 6.027 -37.649 70.90772853504757\n", "27.934 6.243 -37.844 72.11716631981598\n", "30.014 3.894 -39.066 72.16760176838358\n", "30.096 3.314 -38.255 71.8020256678041\n", "30.809 4.501 -39.092 71.42696634325162\n", "30.053 3.303 -39.872 72.8556759696868\n", "28.397 4.752 -36.474 71.42594279391766\n", "28.379 5.346 -35.669 70.75992143155615\n", "29.109 4.064 -36.333 71.05997833520637\n", "27.518 4.278 -36.526 72.25487007115852\n", "27.926 4.067 -42.117 75.50699683473049\n", "27.062 3.975 -41.623 75.82240536279497\n", "28.091 3.339 -43.38 76.45146437446441\n", "28.857 2.706 -43.263 76.06733841143648\n", "27.251 2.82 -43.538 77.30016747717949\n", "28.362 4.25 -44.584 76.76755578367727\n", "29.26 3.969 -45.385 76.7937970086126\n", "27.645 5.373 -44.691 76.97877155424085\n", "26.943 5.556 -44.003 76.95130104813043\n", "27.838 6.355 -45.772 77.2845301855423\n", "27.802 5.845 -46.631 78.03986403755454\n", "29.228 7.002 -45.673 76.09611697057872\n", "29.952 7.052 -46.67 76.29115857686261\n", "26.69 7.393 -45.768 77.7753292889204\n", "26.612 7.765 -44.843 77.10897765500461\n", "25.357 6.716 -46.169 79.14962317661404\n", "25.379 6.528 -47.151 79.843753049315\n", "25.274 5.856 -45.666 79.11560799867495\n", "26.99 8.557 -46.733 77.91668023600594\n", "26.247 9.226 -46.729 78.2552807738877\n", "27.1 8.226 -47.67 78.57109158590072\n", "27.832 9.03 -46.473 77.04402358392245\n", "24.114 7.566 -45.872 79.59207913479833\n", "23.279 7.089 -46.147 80.48860765350584\n", "24.148 8.435 -46.365 79.6699924626581\n", "24.044 7.769 -44.895 78.94791875027485\n", "29.648 7.431 -44.479 74.8756570522089\n", "29.039 7.327 -43.693 74.78694331231888\n", "30.962 8.047 -44.27 73.67711694956583\n", "31.013 8.796 -44.93 73.89637171065978\n", "32.129 7.089 -44.574 73.38921635363059\n", "33.104 7.485 -45.22 73.09473692407681\n", "31.037 8.568 -42.829 72.49427591886135\n", "30.703 7.825 -42.249 72.53732298617035\n", "32.007 8.726 -42.643 71.66843763470779\n", "30.039 10.077 -42.681 72.67666003608035\n", "30.835 11.13 -42.645 71.84242635796761\n", "32.036 5.818 -44.164 73.5482294348409\n", "31.237 5.545 -43.628 73.79251957346354\n", "33.063 4.802 -44.47 73.41558384975221\n", "33.933 5.198 -44.177 72.52669509222103\n", "33.134 4.536 -45.976 74.51069378954942\n", "34.219 4.48 -46.549 74.25717724907135\n", "32.814 3.504 -43.676 73.45963725066983\n", "31.874 3.23 -43.877 74.2988340285364\n", "33.776 2.379 -44.082 73.51645341010405\n", "33.598 1.548 -43.556 73.5691400588589\n", "34.727 2.645 -43.923 72.7141700770902\n", "33.678 2.156 -45.052 74.32826305652513\n", "33.018 3.743 -42.173 72.22433990698704\n", "32.858 2.905 -41.652 72.27207320950464\n", "32.389 4.441 -41.833 72.1728926259714\n", "33.95 4.05 -41.982 71.3832331643783\n", "31.99 4.455 -46.656 75.74060568809837\n", "31.125 4.557 -46.166 75.92076720502763\n", "31.966 4.22 -48.108 76.85693785859543\n", "32.542 3.415 -48.251 76.8585889735168\n", "32.57 5.4 -48.879 76.66780825092106\n", "33.402 5.202 -49.765 76.8611194427976\n", "30.541 3.92 -48.591 78.19339537966106\n", "29.978 4.737 -48.462 78.20893269953247\n", "29.973 2.886 -47.818 78.34717549471709\n", "29.844 3.192 -46.92 77.70957836071432\n", "30.524 3.435 -50.04 79.38487769090533\n", "29.59 3.243 -50.343 80.24769012875073\n", "31.059 2.597 -50.144 79.39573528219258\n", "30.91 4.124 -50.653 79.3687114044319\n", "32.224 6.64 -48.508 76.25054188004174\n", "31.558 6.749 -47.77 76.11164180334043\n", "32.777 7.847 -49.135 76.02238079671011\n", "32.606 7.731 -50.113 76.87890396591251\n", "34.292 7.973 -48.928 74.89861861209457\n", "35.013 8.301 -49.87 75.07441479625399\n", "32.057 9.092 -48.586 75.7452202584427\n", "31.976 8.994 -47.594 75.1035145449266\n", "32.615 9.894 -48.798 75.34441983319003\n", "30.648 9.322 -49.162 77.00609851823425\n", "30.14 8.465 -49.076 77.48972828704458\n", "29.965 10.45 -48.39 76.61938410089185\n", "29.046 10.621 -48.744 77.43749948184019\n", "30.486 11.301 -48.463 76.13410086813923\n", "29.883 10.222 -47.42 76.03562251997415\n", "30.693 9.723 -50.641 77.95664034577169\n", "29.772 9.869 -51.001 78.77250232790627\n", "31.129 9.012 -51.192 78.26165495311226\n", "31.21 10.57 -50.767 77.5214081528451\n", "34.795 7.68 -47.727 73.78468267194756\n", "34.17 7.419 -46.991 73.70829437044382\n", "36.242 7.728 -47.449 72.68271187841026\n", "36.506 8.641 -47.759 72.49846433546023\n", "37.015 6.682 -48.252 73.12640685826153\n", "38.046 7.021 -48.836 72.8638915650269\n", "36.563 7.6 -45.953 71.4188124026156\n", "37.533 7.369 -45.87 70.83759660660431\n", "35.864 6.543 -45.353 71.72788095991683\n", "34.952 6.8 -45.216 72.11883837805486\n", "36.191 8.86 -45.176 70.71793475491206\n", "36.407 8.759 -44.205 69.90364266617298\n", "35.213 9.054 -45.255 71.33464665224045\n", "36.691 9.654 -45.521 70.44463716281034\n", "36.498 5.454 -48.385 73.90676977111094\n", "35.666 5.23 -47.878 74.0982753982844\n", "37.098 4.416 -49.245 74.52795248764049\n", "38.04 4.315 -48.924 73.7785154499601\n", "37.135 4.864 -50.709 75.46752375028612\n", "38.182 4.757 -51.346 75.39712091320197\n", "36.363 3.069 -49.083 75.28011340320894\n", "35.394 3.261 -49.236 75.89652333275879\n", "36.839 2.012 -50.091 76.11690291255944\n", "36.348 1.15 -49.965 76.60835694622357\n", "37.816 1.828 -49.983 75.54863163552335\n", "36.686 2.318 -51.031 76.8004845427423\n", "36.608 2.49 -47.683 74.30799882919737\n", "36.135 1.616 -47.569 74.81379956264753\n", "36.277 3.113 -46.974 73.77085129643007\n", "37.583 2.335 -47.525 73.67918345095852\n", "36.048 5.442 -51.235 76.31261600810183\n", "35.233 5.535 -50.663 76.32926326121587\n", "35.998 5.948 -52.619 77.24504389279612\n", "36.244 5.17 -53.197 77.7794313298831\n", "37.036 7.054 -52.847 76.51391090514194\n", "37.742 7.027 -53.86 76.91870398024138\n", "34.569 6.425 -52.974 78.204602249484\n", "34.265 7.046 -52.251 77.66033693591599\n", "33.611 5.215 -53.059 79.1798056198675\n", "33.816 4.704 -53.894 79.84210716783468\n", "33.766 4.63 -52.263 78.66632343004214\n", "34.547 7.195 -54.312 79.0290494754935\n", "33.621 7.5 -54.535 79.65708883081278\n", "34.87 6.618 -55.063 79.58130651101426\n", "35.135 8.003 -54.27 78.44284177029795\n", "32.127 5.604 -53.087 79.9702339936554\n", "31.545 4.793 -53.142 80.59761309741127\n", "31.923 6.183 -53.877 80.52031014595013\n", "31.873 6.109 -52.262 79.36659678353357\n", "37.169 8.008 -51.919 75.45463639167575\n", "36.571 7.979 -51.118 75.18887152365035\n", "38.153 9.098 -52.021 74.68623426709904\n", "37.995 9.535 -52.906 75.3591758513852\n", "39.577 8.534 -52.01 74.0358123343021\n", "40.38 8.882 -52.877 74.19714637369823\n", "37.933 10.144 -50.902 73.66896252832667\n", "37.888 9.657 -50.03 73.1411875894834\n", "36.609 10.907 -51.143 74.4380482683419\n", "36.736 11.529 -51.915 74.82041723353325\n", "35.895 10.243 -51.364 75.18779287224754\n", "39.104 11.148 -50.833 72.70230492907359\n", "38.957 11.821 -50.108 72.05591462884917\n", "39.203 11.642 -51.696 73.21444100722206\n", "39.967 10.679 -50.646 72.18422869990368\n", "36.14 11.731 -49.937 73.59343282521884\n", "35.283 12.205 -50.139 74.15781109229155\n", "36.821 12.419 -49.687 72.8394954815037\n", "35.987 11.146 -49.141 73.21345461730377\n", "39.887 7.625 -51.081 73.38578441360424\n", "39.185 7.36 -50.42 73.33453524772622\n", "41.212 6.996 -50.986 72.77495418754998\n", "41.876 7.74 -50.918 72.14928105670909\n", "41.526 6.207 -52.259 73.85519623560687\n", "42.571 6.438 -52.869 73.73416164167054\n", "41.31 6.133 -49.712 71.98268918288618\n", "40.518 5.523 -49.726 72.61563353713854\n", "42.594 5.299 -49.666 71.52774433742475\n", "42.634 4.749 -48.832 71.0352164915403\n", "43.403 5.886 -49.687 70.93264050491845\n", "42.645 4.677 -50.447 72.31970485282693\n", "41.32 7.026 -48.463 70.72814880936726\n", "41.383 6.476 -47.63 70.21810515814279\n", "40.485 7.574 -48.407 70.98334636377746\n", "42.099 7.653 -48.477 70.12452165968763\n", "40.611 5.356 -52.732 74.97211945783579\n", "39.777 5.213 -52.199 75.0418025236601\n", "40.766 4.622 -53.99 76.1178781167736\n", "41.59 4.067 -53.875 75.77987967132172\n", "40.98 5.564 -55.181 76.67173125735455\n", "41.884 5.333 -55.98 76.93145862389454\n", "39.534 3.736 -54.221 77.2257931911353\n", "38.743 4.329 -54.075 77.34316193433004\n", "39.573 3.463 -55.182 78.05143625199986\n", "39.558 2.315 -53.091 76.8005943922311\n", "39.564 2.745 -51.843 75.684388528943\n", "40.217 6.655 -55.275 76.82201021842633\n", "39.515 6.805 -54.579 76.5904908066269\n", "40.357 7.647 -56.35 77.3439631580901\n", "40.265 7.118 -57.194 78.2223403638628\n", "41.729 8.328 -56.327 76.44442787410995\n", "42.361 8.481 -57.373 76.9546691890752\n", "39.256 8.707 -56.253 77.56048836230984\n", "39.295 9.182 -55.374 76.70822954546662\n", "39.335 9.372 -56.996 77.95580855843905\n", "37.983 8.103 -56.355 78.47703634822099\n", "37.308 8.782 -56.378 78.68716765140297\n", "42.24 8.681 -55.141 75.118428917277\n", "41.678 8.547 -54.325 74.77343182574944\n", "43.587 9.256 -54.974 74.15684569882944\n", "43.632 10.018 -55.62 74.47843573142497\n", "44.672 8.241 -55.347 74.21068507297315\n", "45.622 8.605 -56.045 74.24884766109169\n", "43.787 9.792 -53.54 72.7310491605889\n", "43.55 9.036 -52.929 72.54645015436661\n", "45.234 10.241 -53.279 71.6839087313185\n", "45.34 10.584 -52.346 70.76683113577998\n", "45.501 10.972 -53.907 71.89784642810936\n", "45.873 9.481 -53.402 71.67607905710244\n", "42.896 11.015 -53.285 72.66701680267326\n", "43.024 11.364 -52.357 71.75393997544664\n", "41.929 10.784 -53.396 73.31453757611787\n", "43.111 11.754 -53.924 72.9110365582605\n", "44.533 6.975 -54.943 74.29869790245317\n", "43.756 6.747 -54.356 74.25866073395075\n", "45.463 5.902 -55.317 74.48782161534864\n", "46.365 6.24 -55.047 73.74315139048505\n", "45.473 5.653 -56.827 75.81713794387123\n", "46.546 5.64 -57.433 75.84633558715937\n", "45.133 4.609 -54.555 74.41770325668482\n", "44.155 4.598 -54.349 74.71894978517831\n", "45.36 3.827 -55.135 75.04279820875551\n", "45.891 4.464 -53.251 73.0389449882732\n", "47.237 4.053 -53.268 72.56829655572741\n", "47.69 3.864 -54.139 73.14904323366095\n", "45.263 4.719 -52.02 72.25096935681901\n", "44.304 5.002 -52.001 72.61188300822393\n", "47.947 3.907 -52.063 71.30426872214593\n", "48.903 3.613 -52.079 70.99302519262015\n", "45.972 4.58 -50.816 70.98028803125554\n", "45.52 4.77 -49.945 70.43490136288969\n", "47.315 4.174 -50.836 70.49829220626553\n", "47.821 4.075 -49.979 69.60015803142979\n", "44.298 5.53 -57.45 76.91706786533142\n", "43.468 5.544 -56.893 76.84314968817974\n", "44.151 5.375 -58.903 78.243863669939\n", "44.648 4.547 -59.163 78.48376190652432\n", "44.795 6.568 -59.615 78.20447253834016\n", "45.622 6.374 -60.504 78.64536276857015\n", "42.659 5.196 -59.277 79.30524182549348\n", "42.149 5.93 -58.827 78.96242659011942\n", "42.151 3.817 -58.791 79.56305495643062\n", "42.543 3.108 -59.378 80.0828047710618\n", "42.458 3.678 -57.849 78.68718743226243\n", "42.423 5.319 -60.797 80.64628999526263\n", "41.455 5.201 -61.02 81.32328653589943\n", "42.941 4.625 -61.297 81.02654773591183\n", "42.708 6.217 -61.132 80.54001722125469\n", "40.624 3.675 -58.823 80.37429257542489\n", "40.341 2.771 -58.502 80.53836663975748\n", "40.272 3.795 -59.751 81.26664739608741\n", "40.188 4.359 -58.238 79.9061829522597\n", "44.509 7.801 -59.187 77.6344550183744\n", "43.857 7.914 -58.437 77.2743802628012\n", "45.119 8.992 -59.779 77.55079561809795\n", "44.898 8.931 -60.752 78.49913970229228\n", "46.647 9.004 -59.634 76.74360703016245\n", "47.348 9.351 -60.581 77.17423836358866\n", "44.508 10.255 -59.165 76.99645380795144\n", "43.53 10.273 -59.371 77.62523864697616\n", "44.64 10.229 -58.174 76.09673676314905\n", "45.135 11.53 -59.699 76.87353443806262\n", "46.072 12.238 -58.921 75.62151991331568\n", "46.318 11.906 -58.01 74.79538900894893\n", "44.808 11.982 -60.992 78.04110371464515\n", "44.144 11.478 -61.544 78.92839547970046\n", "46.663 13.413 -59.425 75.55083767900922\n", "47.314 13.926 -58.866 74.67236255134827\n", "45.415 13.143 -61.509 77.97953809814469\n", "45.194 13.454 -62.433 78.82505963207386\n", "46.334 13.865 -60.722 76.74288695377572\n", "46.894 15.007 -61.2 76.70832063081554\n", "47.836 14.878 -61.312 76.42655123057692\n", "47.194 8.612 -58.477 75.60966132710818\n", "46.587 8.342 -57.73 75.30925488942245\n", "48.649 8.56 -58.253 74.80571085819584\n", "48.99 9.454 -58.545 74.68255133563662\n", "49.335 7.498 -59.112 75.55639623486552\n", "50.398 7.787 -59.657 75.5253961194511\n", "48.942 8.322 -56.762 73.45755787527924\n", "48.328 7.607 -56.429 73.63524006207896\n", "49.89 8.017 -56.67 73.06467831996524\n", "48.748 9.573 -55.891 72.45391210279814\n", "47.902 10.028 -56.169 72.94675377287189\n", "48.675 9.288 -54.935 71.73959969918985\n", "49.907 10.574 -56.017 71.81068572991069\n", "50.773 10.113 -55.825 71.39931606115005\n", "49.928 10.951 -56.943 72.51787312793998\n", "49.689 11.705 -55.004 70.74515667520991\n", "48.902 12.255 -55.284 71.20278762801355\n", "49.517 11.313 -54.1 70.1303786457766\n", "50.865 12.606 -54.898 69.9422562118209\n", "50.7 13.334 -54.233 69.26496553092335\n", "51.069 13.034 -55.778 70.53701068233612\n", "51.678 12.102 -54.606 69.46518420763022\n", "48.737 6.314 -59.248 76.25732400235403\n", "47.862 6.173 -58.784 76.26553458804311\n", "49.287 5.202 -60.04 77.04834048829345\n", "50.254 5.126 -59.795 76.47604928341944\n", "49.206 5.517 -61.537 78.28470662268589\n", "50.197 5.386 -62.252 78.56209533865552\n", "48.563 3.882 -59.678 77.4404842960063\n", "47.578 4.035 -59.757 77.86693657130733\n", "48.912 3.472 -58.227 76.192829938256\n", "49.866 3.175 -58.202 75.883579106418\n", "48.795 4.269 -57.635 75.47831499179085\n", "48.942 2.746 -60.65 78.48729716966943\n", "48.471 1.897 -60.41 78.75440691796237\n", "49.926 2.568 -60.628 78.14077461223428\n", "48.693 2.981 -61.59 79.3161360443132\n", "48.043 2.335 -57.673 76.46778596245612\n", "48.306 2.107 -56.736 75.65043908663056\n", "48.137 1.509 -58.228 77.18090106366989\n", "47.077 2.593 -57.667 76.78632616553548\n", "48.05 5.991 -62.001 79.01439718810744\n", "47.335 6.219 -61.34 78.6721896797083\n", "47.766 6.197 -63.42 80.30539093983666\n", "48.472 5.678 -63.901 80.58966729054042\n", "47.946 7.648 -63.877 80.24158247442531\n", "47.521 7.99 -64.973 81.28791175199422\n", "46.377 5.632 -63.752 81.32117684834621\n", "45.7 6.077 -63.166 80.97601211469973\n", "46.17 5.829 -64.71 82.18165387724926\n", "46.274 4.135 -63.543 81.61882642503505\n", "46.837 3.258 -64.488 82.46663737536531\n", "47.303 3.624 -65.294 82.86539265580052\n", "45.631 3.613 -62.406 81.07594341726774\n", "45.235 4.234 -61.73 80.48267679445061\n", "46.745 1.868 -64.301 82.78049205579778\n", "47.141 1.246 -64.976 83.4025132954637\n", "45.542 2.225 -62.215 81.38994028133943\n", "45.085 1.859 -61.404 81.02291207430156\n", "46.096 1.351 -63.165 82.24718559926534\n", "46.029 0.362 -63.034 82.49671287996874\n", "48.594 8.522 -63.093 79.06783954301521\n", "48.999 8.181 -62.245 78.24738202649338\n", "48.746 9.959 -63.406 78.93246892122404\n", "47.825 10.339 -63.315 79.13531609843987\n", "49.22 10.216 -64.84 79.96235659984015\n", "48.667 11.069 -65.528 80.6021594561833\n", "49.733 10.599 -62.414 77.51131559327321\n", "49.422 10.414 -61.482 76.85065429129409\n", "50.638 10.196 -62.55 77.37635916092201\n", "49.83 12.12 -62.614 77.31383160211374\n", "50.071 12.312 -63.565 78.0323911526489\n", "48.946 12.537 -62.404 77.39091320045269\n", "50.895 12.725 -61.699 75.95137498426213\n", "50.624 12.608 -60.744 75.22510613485366\n", "51.771 12.269 -61.855 75.85519685558795\n", "51.024 14.217 -62.021 75.89548536639053\n", "51.196 14.336 -62.999 76.69306517541204\n", "50.178 14.689 -61.771 75.91216900471228\n", "52.142 14.842 -61.274 74.67739048065351\n", "52.218 15.815 -61.491 74.67399452955493\n", "53.013 14.407 -61.503 74.64477850459467\n", "52.006 14.757 -60.287 73.84961564558071\n", "50.261 9.501 -65.271 80.11891820288139\n", "50.666 8.83 -64.651 79.57568338380764\n", "50.841 9.652 -66.613 81.07726897842575\n", "51.036 10.625 -66.735 80.89589934601135\n", "49.817 9.225 -67.668 82.50167286182747\n", "49.579 9.971 -68.613 83.27033067065364\n", "52.172 8.871 -66.729 80.89672242433558\n", "52.009 7.922 -66.46 80.94654102554351\n", "53.232 9.489 -65.785 79.52714004036608\n", "53.451 10.408 -66.114 79.53816585765603\n", "52.841 9.548 -64.866 78.81261660419605\n", "52.682 8.864 -68.183 82.04557449369223\n", "53.542 8.359 -68.259 81.95366053447522\n", "52.842 9.795 -68.511 82.07339409942786\n", "52.018 8.433 -68.794 82.92963707867048\n", "54.54 8.692 -65.695 79.2070206357997\n", "55.187 9.134 -65.074 78.32147189628141\n", "54.977 8.617 -66.592 79.9058146132057\n", "54.373 7.766 -65.356 79.19037411200934\n", "49.169 8.076 -67.478 82.84855315574315\n", "49.384 7.542 -66.66 82.17227725334135\n", "48.16 7.553 -68.401 84.18274523321271\n", "48.599 7.561 -69.3 84.81778297621318\n", "46.918 8.447 -68.477 84.51332261247336\n", "46.459 8.739 -69.574 85.60048140635658\n", "47.779 6.125 -67.99 84.33183148135701\n", "47.502 6.124 -67.029 83.59170072441401\n", "47.017 5.814 -68.558 85.2109246751847\n", "48.95 5.162 -68.166 84.30723381181474\n", "49.421 5.009 -69.318 85.20082453239522\n", "49.401 4.573 -67.165 83.42079672359884\n", "46.42 8.95 -67.343 83.5883751845913\n", "46.859 8.684 -66.485 82.7162015871135\n", "45.273 9.867 -67.268 83.78316628655186\n", "44.522 9.409 -67.743 84.6187152998673\n", "45.59 11.175 -67.996 84.01446917049466\n", "44.778 11.649 -68.786 84.95565912874785\n", "44.873 10.125 -65.793 82.59853358262482\n", "45.697 10.41 -65.304 81.75597039972065\n", "44.313 8.837 -65.143 82.57048527167561\n", "43.402 8.662 -65.516 83.33459423912737\n", "44.919 8.075 -65.372 82.69392948094799\n", "43.827 11.254 -65.684 82.71279187646853\n", "43.573 11.416 -64.731 81.96080634669231\n", "42.995 11.022 -66.189 83.56984518951796\n", "44.184 12.11 -66.057 82.7086236011699\n", "44.199 8.916 -63.614 81.27751248654205\n", "43.834 8.065 -63.237 81.3254071185629\n", "43.591 9.66 -63.338 81.13474010557994\n", "45.093 9.079 -63.196 80.48356722337796\n", "46.771 11.763 -67.769 83.2117721118833\n", "47.412 11.333 -67.134 82.47659271575178\n", "47.155 13.024 -68.426 83.40277359896372\n", "46.367 13.628 -68.307 83.50141448502534\n", "47.382 12.828 -69.923 84.69920465978414\n", "46.976 13.684 -70.707 85.41145837649653\n", "48.383 13.661 -67.748 82.19355749083988\n", "49.086 12.952 -67.703 82.0151358591815\n", "48.935 14.863 -68.535 82.48751717684318\n", "49.73 15.258 -68.075 81.70423250970539\n", "48.244 15.58 -68.625 82.71805151235128\n", "49.216 14.59 -69.455 83.2662958585285\n", "47.995 14.169 -66.351 80.9942824772218\n", "48.778 14.587 -65.891 80.19689636762759\n", "47.665 13.42 -65.776 80.7466723772565\n", "47.27 14.855 -66.408 81.21784979916669\n", "48.009 11.724 -70.338 85.04585525468009\n", "48.386 11.097 -69.656 84.4141152533153\n", "48.163 11.402 -71.758 86.33807113898247\n", "48.571 12.214 -72.175 86.409421621719\n", "46.804 11.142 -72.418 87.49844012895316\n", "46.541 11.698 -73.477 88.44748709262463\n", "49.102 10.197 -71.931 86.39968256307426\n", "48.793 9.472 -71.316 86.11150452756007\n", "49.032 9.883 -72.878 87.35246081250374\n", "50.584 10.481 -71.629 85.54108446237983\n", "50.636 10.87 -70.709 84.60062516317477\n", "51.367 9.173 -71.736 85.65776992777712\n", "52.338 9.32 -71.545 85.12733200329961\n", "51.29 8.783 -72.654 86.6115819160463\n", "51.025 8.496 -71.084 85.33530090179562\n", "51.205 11.491 -72.596 86.00904041436574\n", "52.166 11.655 -72.375 85.453209483319\n", "50.726 12.368 -72.554 85.9636551863635\n", "51.159 11.16 -73.539 86.9586725577156\n", "45.913 10.391 -71.768 87.41132073707615\n", "46.185 9.979 -70.898 86.61271456893611\n", "44.559 10.139 -72.262 88.44353960013133\n", "44.681 9.768 -73.183 89.29402565121589\n", "43.734 11.424 -72.369 88.61683915599788\n", "43.066 11.63 -73.379 89.75270412639387\n", "43.858 9.123 -71.356 88.14281623592474\n", "44.364 8.261 -71.382 88.15289868177904\n", "43.846 9.475 -70.42 87.24383282501978\n", "42.447 8.839 -71.757 89.148519281029\n", "42.068 8.02 -72.763 90.37570973441925\n", "42.688 7.476 -73.329 90.73934655925179\n", "41.216 9.426 -71.231 89.0898067906761\n", "40.693 8.049 -72.89 91.06856391203279\n", "40.179 7.518 -73.564 91.99983384767603\n", "40.117 8.9 -71.973 90.33422399622415\n", "40.919 10.367 -70.22 88.14106119737836\n", "41.662 10.765 -69.682 87.26046152754407\n", "38.791 9.277 -71.726 90.63611249937853\n", "38.044 8.889 -72.266 91.52744184123142\n", "39.588 10.752 -69.961 88.43986195149786\n", "39.396 11.417 -69.24 87.7734491403864\n", "38.527 10.209 -70.708 89.68508320228062\n", "37.586 10.486 -70.515 89.90463521977051\n", "43.825 12.318 -71.381 87.52997112418123\n", "44.36 12.078 -70.571 86.63201192399954\n", "43.181 13.631 -71.426 87.60627984910671\n", "42.214 13.452 -71.605 88.20831397323045\n", "43.734 14.493 -72.569 88.25435628341526\n", "42.964 15.124 -73.286 89.11910774351368\n", "43.354 14.336 -70.074 86.21187447793952\n", "42.969 13.755 -69.357 85.83985110658102\n", "44.33 14.472 -69.905 85.62594839182805\n", "42.668 15.688 -70.009 86.23762361057962\n", "43.383 16.868 -70.3 86.02007314574894\n", "44.359 16.821 -70.512 85.8037508562417\n", "41.296 15.756 -69.704 86.5645641183504\n", "40.787 14.919 -69.502 86.74465853872502\n", "42.724 18.114 -70.292 86.13713924318591\n", "43.23 18.95 -70.504 86.01055979936417\n", "40.639 17.0 -69.683 86.66874913716016\n", "39.667 17.047 -69.454 86.91008047976942\n", "41.347 18.179 -69.984 86.46443109741715\n", "40.694 19.37 -69.985 86.62631278081734\n", "41.332 20.084 -69.985 86.26422710486658\n", "45.057 14.497 -72.795 87.91934793889226\n", "45.652 14.005 -72.16 87.18971002360313\n", "45.671 15.197 -73.941 88.60614557692936\n", "45.352 16.141 -73.857 88.51741511702654\n", "45.209 14.627 -75.283 90.0920948252398\n", "44.962 15.406 -76.197 90.90261973122666\n", "47.201 15.125 -73.864 87.96183009123901\n", "47.462 14.189 -73.629 87.79748854608542\n", "47.574 15.36 -74.761 88.60948936767437\n", "47.808 16.073 -72.823 86.64104890293052\n", "47.615 17.021 -73.075 86.81312261403802\n", "47.418 15.882 -71.922 85.99214829855106\n", "49.323 15.841 -72.793 86.09248967244471\n", "49.51 14.891 -72.543 85.94095542289486\n", "49.707 16.03 -73.697 86.76333212250438\n", "50.013 16.709 -71.819 84.8223927391818\n", "49.448 17.287 -71.23 84.40330895172298\n", "51.327 16.777 -71.669 84.21489484645812\n", "52.159 16.18 -72.472 84.76736593760596\n", "51.813 15.642 -73.241 85.67833143216549\n", "53.144 16.259 -72.32 84.29290331931864\n", "51.86 17.418 -70.671 83.01698025103057\n", "51.275 17.872 -69.999 82.53519397808427\n", "52.855 17.457 -70.576 82.5886799325428\n", "45.091 13.305 -75.383 90.44227906239425\n", "45.275 12.752 -74.57 89.73021245934949\n", "44.707 12.615 -76.617 91.82698898472061\n", "45.168 13.11 -77.353 92.23413191438405\n", "43.182 12.71 -76.885 92.65201732288402\n", "42.775 12.741 -78.046 93.85531968407545\n", "45.214 11.149 -76.571 91.85695441826927\n", "44.904 10.746 -75.71 91.27574447245006\n", "44.799 10.658 -77.337 92.80186330564705\n", "46.753 10.957 -76.66 91.39979790459057\n", "47.488 11.928 -76.948 91.2145373556211\n", "47.245 9.811 -76.484 91.28877622687247\n", "42.342 12.79 -75.839 92.03954642434957\n", "42.743 12.878 -74.927 91.04310188586503\n", "40.866 12.757 -75.94 92.7517948829024\n", "40.732 12.402 -76.865 93.69247462843533\n", "40.191 14.126 -75.833 92.72229087441703\n", "39.199 14.37 -76.51 93.71667437548133\n", "40.25 11.847 -74.867 92.22477386797975\n", "40.382 12.234 -73.954 91.29207865417457\n", "39.273 11.712 -75.034 92.8233282316466\n", "40.857 10.572 -74.874 92.20982954110694\n", "40.18 9.896 -74.876 92.63621879696947\n", "40.703 15.033 -74.997 91.62044524013186\n", "41.543 14.8 -74.507 90.85885967257128\n", "40.105 16.353 -74.755 91.47965342085637\n", "39.174 16.282 -75.114 92.21872586953259\n", "40.795 17.473 -75.545 91.74261828615968\n", "40.649 18.646 -75.201 91.3632461605869\n", "40.052 16.647 -73.247 90.12609821244898\n", "41.002 16.636 -72.936 89.43188456585268\n", "39.685 17.574 -73.165 90.10002790787581\n", "39.027 15.415 -72.393 90.00738619691164\n", "37.822 15.912 -72.186 90.31355821248546\n", "41.546 17.13 -76.598 92.41124702653892\n", "41.651 16.159 -76.815 92.68764799044152\n", "42.221 18.113 -77.446 92.78137324377128\n", "42.868 18.58 -76.843 91.91941922140283\n", "41.252 19.17 -78.0 93.57001949876893\n", "41.587 20.352 -77.991 93.3116299128892\n", "42.968 17.392 -78.575 93.58818591040217\n", "43.639 16.769 -78.172 93.03267230924841\n", "42.309 16.869 -79.116 94.4066094349331\n", "43.698 18.343 -79.503 94.0397775146241\n", "43.047 18.822 -80.655 95.2968562807819\n", "42.128 18.499 -80.88 95.897355948952\n", "44.999 18.787 -79.191 93.2079916852627\n", "45.463 18.441 -78.375 92.31943761743784\n", "43.687 19.754 -81.49 95.72579990786181\n", "43.223 20.094 -82.308 96.62493096504649\n", "45.647 19.718 -80.028 93.64543395168822\n", "46.572 20.029 -79.812 93.07872812839676\n", "44.983 20.209 -81.173 94.90497454822903\n", "45.583 21.119 -81.984 95.36070409240904\n", "45.724 20.733 -82.848 96.1434656229949\n", "40.034 18.77 -78.377 94.46304196880385\n", "39.798 17.805 -78.265 94.56785150885051\n", "39.022 19.672 -78.948 95.32085791158197\n", "39.502 20.16 -79.677 95.72640495704411\n", "38.514 20.736 -77.955 94.5597703783168\n", "37.976 21.761 -78.365 95.08514152589773\n", "37.854 18.835 -79.504 96.40837929350332\n", "37.482 18.277 -78.763 95.9706867902903\n", "37.148 19.458 -79.839 96.9583117942964\n", "38.263 17.903 -80.654 97.3569056667271\n", "39.268 18.202 -81.342 97.515621563932\n", "37.599 16.856 -80.813 97.90634833860366\n", "38.725 20.532 -76.649 93.31765055443691\n", "39.166 19.677 -76.374 92.95461293556119\n", "38.351 21.482 -75.595 92.47002849031679\n", "37.662 22.072 -76.017 93.11478751519545\n", "39.508 22.389 -75.153 91.49196915030302\n", "39.302 23.305 -74.353 90.81314153248967\n", "37.768 20.713 -74.402 91.74257956914009\n", "38.438 20.035 -74.1 91.22816809516674\n", "37.59 21.359 -73.66 91.11818333351471\n", "36.475 19.99 -74.717 92.68795141225206\n", "35.267 20.711 -74.771 93.24749177323751\n", "35.265 21.695 -74.593 93.0155084166076\n", "36.477 18.607 -74.974 93.05012428256073\n", "37.335 18.094 -74.94 92.67668101523705\n", "34.064 20.05 -75.074 94.15319257996512\n", "33.206 20.563 -75.11 94.56287742026466\n", "35.274 17.946 -75.278 93.95856270186341\n", "35.276 16.963 -75.46 94.23203449995123\n", "34.068 18.667 -75.326 94.50448371373709\n", "33.212 18.196 -75.54 95.16001711328134\n", "40.734 22.154 -75.635 91.40282998901073\n", "40.885 21.349 -76.209 91.9142348387887\n", "41.857 23.041 -75.345 90.60326739141364\n", "41.789 23.291 -74.379 89.74500256838817\n", "41.737 24.304 -76.211 91.36985166344532\n", "41.565 24.194 -77.425 92.5478398937544\n", "43.196 22.312 -75.552 90.28065994995828\n", "43.146 21.792 -76.405 91.11463183265352\n", "43.923 22.995 -75.62 90.00245323878677\n", "43.539 21.343 -74.405 89.1701516540148\n", "42.698 20.85 -74.182 89.35866024622348\n", "44.642 20.373 -74.829 89.1932702113786\n", "44.868 19.741 -74.087 88.48687529232795\n", "45.476 20.865 -75.079 89.04932657241153\n", "44.357 19.83 -75.619 90.0787831900498\n", "44.062 22.097 -73.174 87.77879148176967\n", "44.283 21.463 -72.433 87.0641375653604\n", "43.379 22.743 -72.833 87.70833256880442\n", "44.89 22.613 -73.395 87.60628033993909\n", "41.864 25.513 -75.627 90.73888341279056\n", "41.79 26.746 -76.398 91.43617713465495\n", "40.897 26.831 -76.84 92.21277100814181\n", "42.844 26.712 -77.505 92.00951393198422\n", "44.008 26.388 -77.242 91.30882181366705\n", "42.01 27.885 -75.395 90.4184253070136\n", "42.568 28.611 -75.797 90.54722115559372\n", "41.137 28.265 -75.09 90.51331387702032\n", "42.745 27.217 -74.233 89.06246175578126\n", "43.733 27.221 -74.384 88.7891279887352\n", "42.538 27.674 -73.368 88.36078852635936\n", "42.198 25.792 -74.242 89.33469129627079\n", "42.884 25.137 -73.925 88.78031188839111\n", "41.376 25.714 -73.678 89.18204954473741\n", "42.43 27.04 -78.734 93.29466778439162\n", "41.458 27.232 -78.866 93.80962656891882\n", "43.313 27.135 -79.899 94.00957401243768\n", "43.723 26.234 -80.044 94.00100222869966\n", "44.387 28.172 -79.568 93.27773414915265\n", "44.176 29.378 -79.682 93.46697209709963\n", "42.527 27.5 -81.185 95.49620489317887\n", "42.064 28.372 -81.027 95.52925837668792\n", "41.454 26.432 -81.506 96.23585916382729\n", "41.917 25.589 -81.778 96.32212678818922\n", "40.916 26.265 -80.68 95.70394937514335\n", "43.491 27.658 -82.381 96.22288543272852\n", "42.992 27.894 -83.215 97.18234684344682\n", "43.992 26.81 -82.552 96.20293000215742\n", "44.16 28.381 -82.209 95.8062711673928\n", "40.49 26.833 -82.632 97.64741933097874\n", "39.818 26.113 -82.802 98.0927372744792\n", "40.985 26.999 -83.485 98.2257824300728\n", "39.993 27.668 -82.398 97.62616145275814\n", "45.55 27.711 -79.105 92.41115497059866\n", "45.639 26.738 -78.891 92.19343903445625\n", "46.696 28.592 -78.903 91.79570071631895\n", "46.385 29.376 -78.366 91.4142055043963\n", "47.172 29.039 -80.276 92.90636145065632\n", "47.457 28.191 -81.13 93.60446184343992\n", "47.806 27.918 -78.086 90.63517926831722\n", "47.95 26.991 -78.431 90.9175068014956\n", "48.65 28.445 -78.183 90.42573710509636\n", "47.424 27.849 -76.601 89.38970877567506\n", "47.179 28.765 -76.284 89.18273651890259\n", "46.64 27.238 -76.493 89.58684560804672\n", "48.586 27.323 -75.753 88.18391841486745\n", "48.806 26.387 -76.026 88.3784077362791\n", "49.388 27.905 -75.883 88.01517184554035\n", "48.166 27.345 -74.281 86.96498819065062\n", "47.869 28.266 -74.03 86.83388557469947\n", "47.414 26.701 -74.136 87.12172389249422\n", "49.285 26.959 -73.39 85.73385812501382\n", "49.002 26.976 -72.431 84.94343636797372\n", "50.058 27.585 -73.493 85.54519714747286\n", "49.607 26.036 -73.599 85.83561026170898\n", "47.264 30.358 -80.458 93.06011807965858\n", "46.865 30.958 -79.765 92.5689961326145\n", "47.912 30.974 -81.608 93.92548849487024\n", "47.306 30.856 -82.394 94.86914915292537\n", "49.246 30.266 -81.899 93.73430570500855\n", "49.915 29.79 -80.977 92.63629211599523\n", "48.107 32.47 -81.324 93.64253198200056\n", "47.232 32.916 -81.137 93.79072989373736\n", "48.526 32.931 -82.106 94.25549275241204\n", "48.699 32.61 -80.531 92.70188671758521\n", "49.588 30.127 -83.182 94.8327386191077\n", "48.959 30.455 -83.887 95.70957683534077\n", "50.852 29.512 -83.595 94.81673935545346\n", "50.796 28.543 -83.356 94.6020509608539\n", "52.008 30.182 -82.85 93.76386882483037\n", "52.165 31.394 -82.93 93.82198337276824\n", "51.042 29.658 -85.106 96.19843267434246\n", "50.208 29.414 -85.601 96.9225378227376\n", "51.314 30.589 -85.349 96.36329854773548\n", "52.067 28.783 -85.52 96.2825609806885\n", "51.713 27.898 -85.614 96.47833765151637\n", "52.79 29.407 -82.1 92.80469749964168\n", "52.644 28.418 -82.138 92.88038596496033\n", "53.852 29.912 -81.221 91.66053077524698\n", "53.503 30.779 -80.864 91.43696716864575\n", "55.143 30.266 -81.981 92.03475700516626\n", "56.172 30.51 -81.36 91.16582994192505\n", "54.081 28.924 -80.051 90.46485320277704\n", "54.803 29.296 -79.468 89.70209099012129\n", "53.231 28.86 -79.529 90.21536018328585\n", "54.492 27.498 -80.455 90.73983487972633\n", "54.465 27.161 -81.66 91.90807708248497\n", "54.763 26.663 -79.56 89.8184913533956\n", "55.115 30.258 -83.321 93.33200793404157\n", "54.238 30.078 -83.766 93.99593613023916\n", "56.28 30.495 -84.182 93.86249646157937\n", "55.943 30.576 -85.12 94.85692969941627\n", "56.687 31.363 -83.897 93.50586733462238\n", "57.346 29.391 -84.12 93.52006465994343\n", "58.352 29.467 -84.822 93.96268234783423\n", "57.14 28.347 -83.305 92.77744102420588\n", "56.277 28.31 -82.801 92.50878892840399\n", "58.097 27.256 -83.105 92.35895894281182\n", "59.006 27.649 -83.243 92.27529881284589\n", "57.908 26.166 -84.155 93.44510154095826\n", "56.798 25.68 -84.379 93.94650055217596\n", "58.007 26.721 -81.668 90.9956050202426\n", "57.058 26.483 -81.463 91.03851072485752\n", "58.581 25.906 -81.583 90.79492235251925\n", "58.489 27.788 -80.673 89.8981780516157\n", "59.399 28.099 -80.948 89.9482114385828\n", "57.853 28.559 -80.692 90.06900413016677\n", "58.566 27.251 -79.243 88.49864109126196\n", "57.642 27.103 -78.89 88.38997405814757\n", "59.068 26.386 -79.237 88.38845373689935\n", "59.295 28.277 -78.367 87.46325954365068\n", "60.022 28.711 -78.899 87.80977792364583\n", "58.646 28.973 -78.061 87.32460759144584\n", "59.911 27.665 -77.164 86.15262069722544\n", "60.379 28.354 -76.611 85.50123849980186\n", "60.582 26.969 -77.42 86.25635233419044\n", "59.219 27.228 -76.59 85.76716129148731\n", "59.014 25.772 -84.78 93.80690405828346\n", "59.883 26.173 -84.491 93.32146223672237\n", "59.04 24.785 -85.869 94.8958858275742\n", "58.143 24.854 -86.305 95.52099451429513\n", "59.216 23.363 -85.344 94.41280505312824\n", "58.621 22.439 -85.894 95.13644221327598\n", "60.156 25.123 -86.868 95.61641167707559\n", "61.033 25.08 -86.389 94.96914931176333\n", "59.975 26.435 -87.348 96.08551743629214\n", "59.934 26.422 -88.304 97.02892095143592\n", "60.153 24.212 -88.097 96.85484504659536\n", "60.89 24.457 -88.727 97.31116048532152\n", "59.288 24.283 -88.594 97.5192720748058\n", "60.279 23.255 -87.834 96.61951807476582\n", "59.994 23.191 -84.275 93.21052912090994\n", "60.349 24.007 -83.819 92.64590701158902\n", "60.361 21.888 -83.726 92.68088290472852\n", "59.995 21.197 -84.349 93.41828177610633\n", "59.709 21.662 -82.357 91.50827515039282\n", "59.544 22.574 -81.54 90.68730123341416\n", "61.89 21.773 -83.679 92.32818132618014\n", "62.246 22.499 -83.091 91.6323634694642\n", "62.131 20.883 -83.293 91.97322089608475\n", "62.557 21.895 -85.037 93.51907894114441\n", "62.57 20.792 -85.909 94.45514866856121\n", "62.144 19.931 -85.63 94.33747714455798\n", "63.191 23.096 -85.417 93.69664999881266\n", "63.204 23.874 -84.789 93.03548614372905\n", "63.18 20.895 -87.173 95.57416351190315\n", "63.184 20.109 -87.792 96.24639973526281\n", "63.806 23.202 -86.68 94.82253840200653\n", "64.256 24.054 -86.948 94.96537169410752\n", "63.786 22.105 -87.567 95.7659309096925\n", "64.369 22.19 -88.789 96.86473028404095\n", "65.321 22.21 -88.688 96.61285997215899\n", "59.328 20.422 -82.081 91.42834659994678\n", "59.422 19.729 -82.795 92.16328771804965\n", "58.778 20.013 -80.791 90.34480161580963\n", "58.193 20.769 -80.496 90.13206750652067\n", "59.868 19.821 -79.74 89.09257781656112\n", "59.638 20.122 -78.565 87.97894635650053\n", "57.957 18.737 -80.965 90.83984732483867\n", "58.504 18.056 -81.452 91.25333791703183\n", "57.705 18.381 -80.065 90.07511952809166\n", "56.691 19.025 -81.761 91.89228578068999\n", "55.939 19.937 -81.333 91.58677442731565\n", "56.465 18.312 -82.758 92.9842667551882\n", "61.059 19.386 -80.156 89.27625800849854\n", "61.15 19.085 -81.105 90.21018165927835\n", "62.231 19.329 -79.296 88.2009188444202\n", "62.14 20.124 -78.696 87.55555087485887\n", "63.545 19.465 -80.077 88.69131153613638\n", "63.676 18.917 -81.169 89.79129963977579\n", "62.216 18.024 -78.494 87.5708197803355\n", "61.362 17.928 -77.982 87.26558142246002\n", "62.972 17.997 -77.84 86.78582592797052\n", "62.303 17.231 -79.098 88.23814137321797\n", "64.517 20.136 -79.464 87.84722581846282\n", "64.261 20.712 -78.688 87.08014595761769\n", "65.93 20.096 -79.838 87.97720152971449\n", "65.991 19.919 -80.82 88.94903464906182\n", "66.615 18.97 -79.056 87.21646278083054\n", "66.377 18.858 -77.848 86.08134315866592\n", "66.566 21.451 -79.503 87.42646324197267\n", "66.025 22.174 -79.932 87.87892429928804\n", "66.558 21.573 -78.51 86.44042638719455\n", "67.994 21.588 -79.98 87.67500967208387\n", "69.056 21.045 -79.228 86.83539889929682\n", "68.871 20.611 -78.346 86.02727874924325\n", "68.256 22.238 -81.199 88.79428302542905\n", "67.504 22.626 -81.732 89.3981716871212\n", "70.375 21.112 -79.714 87.15138518692632\n", "71.125 20.709 -79.189 86.58546602057413\n", "69.578 22.34 -81.666 89.08150464041343\n", "69.77 22.834 -82.514 89.86619387177805\n", "70.634 21.749 -80.944 88.2894148921602\n", "71.879 21.779 -81.472 88.68506997798445\n", "72.525 21.786 -80.766 87.92504937729635\n", "67.443 18.152 -79.705 87.8226075506757\n", "67.576 18.294 -80.686 88.75088881245078\n", "68.172 17.052 -79.058 87.22174575758044\n", "67.721 16.912 -78.177 86.43977649786007\n", "69.628 17.453 -78.825 86.75156170928568\n", "70.36 17.709 -79.772 87.56655072571947\n", "68.078 15.748 -79.88 88.22150921969086\n", "68.596 15.911 -80.72 88.95240173261203\n", "66.639 15.385 -80.314 88.90796968213816\n", "66.327 16.076 -80.966 89.49398131718131\n", "66.665 14.491 -80.761 89.47700932641858\n", "68.697 14.578 -79.091 87.54409739668345\n", "68.643 13.726 -79.612 88.20020727866799\n", "68.22 14.439 -78.223 86.78208383646938\n", "69.66 14.753 -78.887 87.19509978777477\n", "65.605 15.31 -79.191 87.9877755429696\n", "64.703 15.071 -79.55 88.52722686834825\n", "65.525 16.188 -78.718 87.41169976610682\n", "65.86 14.619 -78.515 87.394349811644\n", "70.045 17.461 -77.561 85.45616582786757\n", "69.356 17.312 -76.852 84.86319509068699\n", "71.42 17.668 -77.121 84.84309111530531\n", "71.966 17.971 -77.902 85.52124663497369\n", "71.988 16.34 -76.612 84.4656789530517\n", "71.425 15.738 -75.694 83.70909324559668\n", "71.418 18.755 -76.034 83.63704529692569\n", "70.943 19.558 -76.394 83.95371019794182\n", "70.923 18.403 -75.239 82.94827536483203\n", "72.821 19.188 -75.577 82.99947682365233\n", "73.359 18.376 -75.349 82.82351417924743\n", "73.528 19.954 -76.689 83.95914417143614\n", "74.442 20.24 -76.402 83.57777755480221\n", "73.014 20.774 -76.942 84.17252031987636\n", "73.626 19.388 -77.508 84.82294628813597\n", "72.688 20.107 -74.36 81.70726370403061\n", "73.586 20.407 -74.038 81.27984061254057\n", "72.231 19.637 -73.604 81.05261094499053\n", "72.154 20.922 -74.583 81.89881641391406\n", "73.082 15.872 -77.202 85.01667829902553\n", "73.541 16.453 -77.874 85.55786353690699\n", "73.653 14.554 -76.924 84.90412216141218\n", "73.446 14.336 -75.97 84.01923320883141\n", "75.186 14.573 -77.08 84.95023605617585\n", "75.714 15.467 -77.747 85.43627105041512\n", "72.988 13.529 -77.858 86.04898531650447\n", "73.214 12.61 -77.536 85.88026025228382\n", "71.997 13.661 -77.823 86.08040937402656\n", "73.422 13.636 -79.305 87.4160279468245\n", "72.809 14.568 -80.167 88.1594046769827\n", "72.053 15.134 -79.838 87.81428450998162\n", "74.467 12.818 -79.777 87.94802215513432\n", "74.893 12.152 -79.165 87.44286898884323\n", "73.264 14.699 -81.493 89.40739796571646\n", "72.837 15.364 -82.106 89.94515266538825\n", "74.912 12.935 -81.103 89.2021046556638\n", "75.644 12.343 -81.442 89.60029094818833\n", "74.322 13.891 -81.954 89.91428114598925\n", "74.806 14.053 -83.206 91.0912407753896\n", "75.762 14.091 -83.176 91.00405761283395\n", "75.913 13.625 -76.459 84.46121598698423\n", "77.368 13.585 -76.531 84.47786419530267\n", "77.723 14.507 -76.373 84.15249977273403\n", "77.823 13.152 -77.914 85.90135367967143\n", "77.442 12.086 -78.391 86.57820881723067\n", "77.839 12.603 -75.455 83.5869213812783\n", "78.584 12.032 -75.8 84.0182768747372\n", "78.145 13.093 -74.639 82.68523097869412\n", "76.614 11.751 -75.139 83.48783007720345\n", "76.662 10.879 -75.626 84.14128034443023\n", "76.554 11.581 -74.155 82.56254416501469\n", "75.408 12.558 -75.613 83.85414724389008\n", "74.782 11.988 -76.145 84.5232558175559\n", "74.918 12.959 -74.839 83.04922368691955\n", "78.683 13.958 -78.537 86.35490235649624\n", "78.877 14.852 -78.134 85.80730938562284\n", "79.356 13.593 -79.785 87.63754817998961\n", "78.747 13.003 -80.315 88.26971980243282\n", "80.619 12.808 -79.436 87.42866975998206\n", "81.624 13.399 -79.046 86.95082363037167\n", "79.634 14.854 -80.627 88.26055994610503\n", "80.169 15.498 -80.08 87.6201801869866\n", "80.155 14.593 -81.439 89.10155510427413\n", "78.33 15.542 -81.072 88.61437989965286\n", "77.802 14.901 -81.629 89.2736430252513\n", "77.803 15.79 -80.259 87.7868293139694\n", "78.588 16.812 -81.896 89.24838809188657\n", "79.208 17.419 -81.398 88.6674911904019\n", "78.996 16.568 -82.776 90.14643665170576\n", "77.245 17.518 -82.126 89.42067512605796\n", "76.715 17.008 -82.803 90.17496182976735\n", "76.739 17.554 -81.264 88.57962639343202\n", "77.394 18.907 -82.621 89.74696484561468\n", "76.501 19.336 -82.76 89.87233636664844\n", "77.883 18.926 -83.493 90.59771935871233\n", "77.906 19.467 -81.969 89.02556403078836\n", "80.575 11.48 -79.542 87.7813459226959\n", "79.708 11.042 -79.779 88.10037226936103\n", "81.76 10.638 -79.322 87.7467591253375\n", "82.168 10.977 -78.474 86.85600125495071\n", "82.736 10.806 -80.485 88.87422795163961\n", "82.504 10.31 -81.585 90.04481454253764\n", "81.401 9.157 -79.118 87.85647639758835\n", "82.234 8.613 -79.218 88.09091554751829\n", "80.52 8.697 -80.11 88.91817394661228\n", "80.994 8.592 -80.935 89.74878747927461\n", "80.704 8.932 -77.776 86.59203317280407\n", "80.473 7.967 -77.649 86.69137427679873\n", "79.857 9.461 -77.719 86.41726594842028\n", "81.292 9.21 -77.016 85.79438110389282\n", "83.839 11.517 -80.245 88.53808984838108\n", "83.915 11.977 -79.361 87.58651299144178\n", "84.95 11.668 -81.196 89.49420978476763\n", "84.56 11.708 -82.116 90.3694009330592\n", "85.853 10.434 -81.076 89.67032066408595\n", "86.851 10.447 -80.362 89.03902268668496\n", "85.71 12.996 -80.966 89.0708559125823\n", "86.137 12.92 -80.065 88.2267898599966\n", "86.78 13.227 -82.043 90.16166135891686\n", "87.266 14.087 -81.887 89.90282938261733\n", "86.369 13.267 -82.954 91.0215628354073\n", "87.454 12.488 -82.043 90.34188099657877\n", "84.763 14.207 -81.003 88.85005491275737\n", "85.265 15.059 -80.853 88.59572309090319\n", "84.061 14.135 -80.294 88.12955380007321\n", "84.301 14.274 -81.887 89.68836734493499\n", "85.464 9.329 -81.712 90.49675166546035\n", "84.589 9.345 -82.196 90.91906005343434\n", "86.25 8.093 -81.739 90.84262296411305\n", "87.216 8.341 -81.809 90.9246581021892\n", "86.092 7.606 -80.88 90.10935954161477\n", "85.859 7.205 -82.916 92.16383879266314\n", "84.726 6.738 -82.997 92.28912340032275\n", "86.793 7.002 -83.844 93.17331776855431\n", "87.685 7.429 -83.697 93.00028390279246\n", "86.623 6.205 -85.062 94.52911911680971\n", "85.902 6.671 -85.575 94.87182040521833\n", "86.164 4.763 -84.763 94.54036501410391\n", "86.849 4.003 -84.083 94.07297126167538\n", "87.962 6.171 -85.832 95.36590257529156\n", "88.693 5.946 -85.188 94.82324667506381\n", "87.906 5.462 -86.535 96.19520890356235\n", "88.313 7.504 -86.516 95.77326614457712\n", "87.641 7.678 -87.236 96.3810930421522\n", "88.266 8.233 -85.833 94.9469331100273\n", "89.719 7.512 -87.145 96.4991428614783\n", "89.864 8.123 -88.228 97.44772661278455\n", "90.644 6.939 -86.526 96.07036684639026\n", "85.029 4.353 -85.343 95.16083743851775\n", "84.321 5.031 -85.54 95.14795746099861\n", "84.778 2.95 -85.703 95.82990451837047\n", "84.465 2.961 -86.653 96.74569847802022\n", "85.664 2.489 -85.649 95.9071928324461\n", "83.769 2.144 -84.877 95.20733575203121\n", "83.35 1.09 -85.351 95.9262812372084\n", "83.308 2.608 -83.714 93.96369737829605\n", "83.719 3.434 -83.327 93.39283088653004\n", "82.215 1.947 -82.979 93.41730273348723\n", "81.919 1.188 -83.559 94.17404717330567\n", "81.041 2.899 -82.789 92.96502536975935\n", "81.159 3.866 -82.041 91.98324982843343\n", "82.7 1.371 -81.642 92.2693947200262\n", "81.95 0.914 -81.163 91.93314035754462\n", "83.447 0.722 -81.788 92.58198376574138\n", "83.189 2.38 -80.782 91.17909252674102\n", "83.3 3.193 -81.274 91.4546597719329\n", "79.908 2.622 -83.445 93.66862357267773\n", "79.935 1.935 -84.172 94.55843440434067\n", "78.624 3.279 -83.149 93.21672160615819\n", "78.731 4.229 -83.443 93.24563767812411\n", "78.348 3.164 -81.658 91.8195616903065\n", "78.152 2.051 -81.164 91.66479113596452\n", "77.454 2.617 -83.9 94.14677102269627\n", "76.623 2.711 -83.352 93.62236500430866\n", "77.672 1.228 -84.047 94.67347403576146\n", "76.83 0.774 -84.08 94.86318458179653\n", "77.258 3.209 -85.29 95.3298741108998\n", "76.495 2.768 -85.763 95.92973168418642\n", "78.078 3.088 -85.85 95.88001141531012\n", "77.063 4.188 -85.238 95.03026559996557\n", "78.361 4.292 -80.951 90.83244667518319\n", "78.598 5.15 -81.407 91.04308093424783\n", "78.039 4.308 -79.531 89.46799148857652\n", "78.593 3.599 -79.094 89.23154579519509\n", "76.555 3.965 -79.341 89.42703131603999\n", "75.716 4.291 -80.188 90.19044910632168\n", "78.424 5.661 -78.914 88.50634138862593\n", "78.397 5.614 -77.915 87.55478246789264\n", "79.338 5.936 -79.211 88.70916470128664\n", "77.533 6.686 -79.306 88.64879633700617\n", "78.013 7.51 -79.395 88.52240907815376\n", "76.196 3.339 -78.217 88.53963557074312\n", "76.911 3.014 -77.598 88.01125982509282\n", "74.786 3.109 -77.855 88.3342243697198\n", "74.425 2.495 -78.556 89.20447469157587\n", "73.979 4.423 -77.859 88.02186693089394\n", "72.779 4.438 -78.15 88.38948724820165\n", "74.714 2.468 -76.458 87.19427250112246\n", "75.341 2.96 -75.854 86.43501147104685\n", "73.779 2.563 -76.117 86.90520224934754\n", "75.086 0.98 -76.423 87.5953057075549\n", "75.017 0.324 -77.486 88.81334859130129\n", "75.404 0.503 -75.313 86.67945493021976\n", "74.655 5.548 -77.602 87.4273786179135\n", "75.614 5.465 -77.329 87.13086343540961\n", "74.087 6.884 -77.693 87.21124691804377\n", "73.243 6.857 -77.157 86.76382353262215\n", "73.697 7.266 -79.126 88.53155534610244\n", "72.578 7.734 -79.333 88.70987607927316\n", "75.086 7.875 -77.099 86.33009812921563\n", "75.351 7.51 -76.207 85.53959102661176\n", "75.879 7.877 -77.708 86.87691917304618\n", "74.273 9.488 -76.99 85.90412763074892\n", "75.186 10.441 -76.963 85.61306252552818\n", "74.558 7.033 -80.117 89.48842523477548\n", "75.448 6.635 -79.895 89.31847188012118\n", "74.253 7.337 -81.521 90.79693465090108\n", "73.996 8.303 -81.522 90.59426945453008\n", "73.094 6.48 -82.034 91.58022107966326\n", "72.177 6.982 -82.688 92.16942013487987\n", "75.479 7.101 -82.411 91.64423928431071\n", "75.783 6.155 -82.298 91.74573856588654\n", "75.221 7.257 -83.365 92.54819400723062\n", "76.636 8.029 -82.062 91.03930734578333\n", "76.381 9.246 -81.921 90.64539011444542\n", "77.752 7.483 -81.905 90.97453148546576\n", "73.078 5.19 -81.677 91.55680917332147\n", "73.86 4.821 -81.175 91.11074954691131\n", "71.957 4.294 -81.993 92.18676840523264\n", "71.87 4.291 -82.989 93.1524578043972\n", "70.667 4.844 -81.373 91.57243640419316\n", "69.62 4.886 -82.028 92.30489125176412\n", "72.25 2.852 -81.516 92.09478765380807\n", "72.445 2.873 -80.535 91.13431664307359\n", "73.486 2.285 -82.254 92.86200998255423\n", "73.262 2.196 -83.225 93.83238258724968\n", "74.243 2.929 -82.144 92.5247067814862\n", "71.02 1.946 -81.743 92.68192549790925\n", "71.202 1.012 -81.437 92.64588395606143\n", "70.775 1.91 -82.712 93.64019549317483\n", "70.227 2.286 -81.238 92.18573017555373\n", "73.949 0.914 -81.745 92.74216066600994\n", "74.748 0.594 -82.254 93.27225345728493\n", "73.226 0.231 -81.847 93.09624359231687\n", "74.197 0.956 -80.777 91.79175632375708\n", "70.725 5.303 -80.124 90.24828251551382\n", "71.591 5.249 -79.626 89.69684044045253\n", "69.565 5.88 -79.464 89.5967625084746\n", "68.85 5.188 -79.563 89.95662624843153\n", "69.077 7.168 -80.146 89.99582314752168\n", "67.886 7.285 -80.439 90.40495474806676\n", "69.865 6.109 -77.987 88.08530141856812\n", "70.211 5.259 -77.59 87.88570068560641\n", "70.56 6.823 -77.904 87.74722070812271\n", "68.639 6.538 -77.214 87.3880058589278\n", "68.426 7.904 -76.972 86.84964603842666\n", "69.069 8.579 -77.332 86.95396331967852\n", "67.707 5.591 -76.751 87.31726909380527\n", "67.846 4.618 -76.937 87.73547115049875\n", "67.313 8.327 -76.226 86.19124315729528\n", "67.18 9.299 -76.031 85.80063460721023\n", "66.581 6.016 -76.027 86.68474699161324\n", "65.914 5.344 -75.704 86.66225139586439\n", "66.387 7.381 -75.754 86.10970124788496\n", "65.592 7.678 -75.225 85.66310964470061\n", "69.981 8.111 -80.425 89.93875813018545\n", "70.939 7.899 -80.229 89.69381384465709\n", "69.686 9.437 -80.997 90.23567615416864\n", "68.958 9.802 -80.417 89.68419099261585\n", "69.181 9.345 -82.427 91.70243179981652\n", "68.166 9.952 -82.745 92.01343105221106\n", "70.943 10.33 -80.972 89.88834649719617\n", "71.664 9.784 -81.398 90.34407817339219\n", "70.767 11.649 -81.741 90.39959080659602\n", "71.601 12.2 -81.703 90.17771552329323\n", "70.021 12.192 -81.355 90.00346776097018\n", "70.556 11.477 -82.703 91.39351440337548\n", "71.301 10.718 -79.543 88.38154307885782\n", "72.116 11.297 -79.522 88.16762073459849\n", "71.486 9.907 -78.987 87.98970786972757\n", "70.554 11.223 -79.111 87.93847491854746\n", "69.867 8.6 -83.294 92.62251581554023\n", "70.594 8.005 -82.952 92.34282212494915\n", "69.588 8.627 -84.731 94.04257348137597\n", "69.165 9.519 -84.891 94.0619122386952\n", "68.568 7.579 -85.176 94.82087532816811\n", "67.92 7.764 -86.206 95.8582367300797\n", "70.902 8.493 -85.506 94.68537476294847\n", "71.399 7.697 -85.16 94.47385537279612\n", "70.691 8.359 -86.474 95.67581375143877\n", "71.801 9.705 -85.38 94.2288459071849\n", "71.454 10.9 -86.04 94.67417388601815\n", "70.604 10.954 -86.564 95.25859098789986\n", "72.987 9.644 -84.623 93.4036808107689\n", "73.227 8.802 -84.14 93.0889216394733\n", "72.303 12.016 -85.962 94.32115183775058\n", "72.056 12.865 -86.429 94.65576645403068\n", "73.833 10.762 -84.544 93.04479321273168\n", "74.672 10.72 -84.001 92.46735669413287\n", "73.496 11.941 -85.231 93.52445251911394\n", "74.11 12.729 -85.198 93.31321155120533\n", "68.391 6.491 -84.415 94.35531206031806\n", "68.914 6.412 -83.566 93.49109855488918\n", "67.463 5.407 -84.77 95.07587315928262\n", "67.071 5.629 -85.663 95.93354796941475\n", "66.272 5.342 -83.823 94.35091466435287\n", "65.138 5.545 -84.249 94.88290178425193\n", "68.248 4.092 -84.884 95.4122170846061\n", "69.021 4.236 -85.501 95.87397649518871\n", "68.587 3.845 -83.976 94.56431562169738\n", "67.411 2.928 -85.421 96.33791995367142\n", "66.623 2.777 -84.825 95.91786424853298\n", "67.094 3.14 -86.346 97.20804524832293\n", "68.285 1.669 -85.45 96.59637399509361\n", "69.054 1.816 -86.072 97.05720210782917\n", "68.63 1.486 -84.53 95.72971489041424\n", "67.475 0.465 -85.93 97.49646344868106\n", "66.676 0.338 -85.342 97.08373310189508\n", "67.176 0.613 -86.873 98.38848035720443\n", "68.297 -0.77 -85.883 97.71150088397987\n", "67.772 -1.562 -86.196 98.31251674634312\n", "68.61 -0.957 -84.952 96.85000537945261\n", "69.104 -0.686 -86.467 98.1447029747403\n", "66.519 5.079 -82.542 93.15380516650943\n", "67.466 5.105 -82.221 92.70546980086989\n", "65.455 4.751 -81.577 92.47882855010653\n", "64.904 4.039 -82.013 93.16829144617819\n", "64.539 5.95 -81.305 92.06878320581846\n", "63.314 5.817 -81.275 92.28909956760874\n", "66.08 4.223 -80.272 91.27636244943157\n", "66.694 4.944 -79.95 90.6864667136172\n", "65.028 3.956 -79.204 90.5036256124582\n", "65.449 3.614 -78.364 89.73223273718312\n", "64.366 3.274 -79.516 91.09916423875688\n", "64.526 4.791 -78.979 90.1524287581871\n", "66.882 2.935 -80.494 91.71868002757127\n", "67.279 2.608 -79.637 90.94111046715891\n", "67.629 3.085 -81.142 92.18766692459462\n", "66.3 2.209 -80.859 92.3556240355724\n", "65.118 7.132 -81.109 91.500941273847\n", "66.106 7.203 -81.244 91.4563215857712\n", "64.389 8.329 -80.708 90.96665961218977\n", "63.707 8.092 -80.017 90.47911819309469\n", "63.492 8.883 -81.843 92.09442151943841\n", "62.296 9.064 -81.588 92.03617115569291\n", "65.411 9.269 -80.037 89.94367505277955\n", "65.893 8.751 -79.33 89.29804968194993\n", "66.062 9.569 -80.734 90.44757337817305\n", "64.815 10.519 -79.38 89.1506196781604\n", "63.824 10.388 -79.342 89.31691000588859\n", "65.382 10.728 -77.975 87.65669178106141\n", "64.992 11.544 -77.549 87.15005238093664\n", "66.375 10.841 -78.003 87.49846852374046\n", "65.178 9.946 -77.386 87.28708184490989\n", "65.154 11.759 -80.185 89.6289334701691\n", "64.768 12.578 -79.761 89.13408570238435\n", "64.791 11.693 -81.114 90.60164188909603\n", "66.144 11.884 -80.25 89.50778091875588\n", "63.968 9.031 -83.096 93.18272383870307\n", "63.137 9.307 -84.272 94.40464993314684\n", "62.639 10.156 -84.094 94.15524348648884\n", "62.058 8.251 -84.541 95.08374828013459\n", "60.901 8.593 -84.799 95.48577002883728\n", "64.124 9.379 -85.443 95.34609426190461\n", "64.293 8.473 -85.832 95.8789413844354\n", "63.793 9.993 -86.159 95.97249692490031\n", "65.379 9.933 -84.785 94.39560321328531\n", "66.198 9.707 -85.313 94.82690041860485\n", "65.322 10.924 -84.667 94.09969962757586\n", "65.365 9.212 -83.445 93.24860274020196\n", "65.809 8.318 -83.511 93.43231786164785\n", "65.816 9.756 -82.738 92.38295538139057\n", "62.392 6.96 -84.428 95.19678432069016\n", "63.33 6.73 -84.17 94.83148751865068\n", "61.44 5.865 -84.667 95.86068634742816\n", "61.115 5.996 -85.603 96.78479730308887\n", "60.221 5.938 -83.736 95.2059501081734\n", "59.103 5.603 -84.139 95.90772787424379\n", "62.163 4.513 -84.525 95.91644423142468\n", "62.93 4.49 -85.166 96.39077914925265\n", "62.508 4.43 -83.59 94.98515909867183\n", "61.239 3.319 -84.818 96.67698568428786\n", "60.494 3.329 -84.151 96.19396236251005\n", "60.864 3.433 -85.738 97.59119940855322\n", "61.928 1.947 -84.747 96.84497518715155\n", "61.189 0.956 -84.952 97.45609183627259\n", "63.154 1.874 -84.507 96.41462981311498\n", "60.399 6.408 -82.5 93.88485914139723\n", "61.314 6.698 -82.218 93.35986984245426\n", "59.293 6.512 -81.544 93.19555034442362\n", "58.602 5.878 -81.891 93.83172083043132\n", "58.658 7.9 -81.539 93.01729025294168\n", "57.435 8.014 -81.661 93.39810987916191\n", "59.718 6.05 -80.143 91.88848986679452\n", "60.436 6.658 -79.806 91.26491286907581\n", "58.488 6.071 -79.228 91.30500116642023\n", "58.725 5.775 -78.303 90.45392178341412\n", "57.775 5.461 -79.573 91.95205965066796\n", "58.102 6.992 -79.167 91.11795615574353\n", "60.242 4.609 -80.188 92.17943227206382\n", "60.521 4.301 -79.279 91.34523285864456\n", "61.034 4.534 -80.794 92.60224110139019\n", "59.538 3.982 -80.523 92.81321057909805\n", "59.44 8.969 -81.399 92.4742113834987\n", "60.432 8.846 -81.387 92.27138253001306\n", "58.889 10.319 -81.262 92.19281879300577\n", "58.084 10.204 -80.68 91.85197540064122\n", "58.412 10.896 -82.598 93.46555329638828\n", "57.345 11.505 -82.624 93.63190426879076\n", "59.902 11.247 -80.575 91.12735520687518\n", "60.754 11.212 -81.098 91.44929220611824\n", "59.533 12.176 -80.6 91.06245863142505\n", "60.229 10.905 -79.11 89.72078878944389\n", "60.641 9.994 -79.119 89.82241522582211\n", "61.18 11.958 -78.535 88.76089707748564\n", "61.406 11.755 -77.582 87.83760958723774\n", "60.767 12.868 -78.566 88.71456568117775\n", "62.035 11.99 -79.053 89.0734523918322\n", "58.989 10.874 -78.207 89.15189396193442\n", "59.237 10.649 -77.265 88.2428054744408\n", "58.332 10.189 -78.523 89.74809869295282\n", "58.528 11.762 -78.2 89.08438020775584\n", "59.12 10.676 -83.704 94.4019558324932\n", "59.951 10.122 -83.647 94.27206288715655\n", "58.715 11.224 -85.007 95.63786415954718\n", "58.247 12.078 -84.779 95.37479520816807\n", "57.732 10.3 -85.723 96.71771352756431\n", "56.662 10.74 -86.129 97.27672982784732\n", "59.922 11.55 -85.9 96.17355140057998\n", "60.395 10.698 -86.126 96.44657630004292\n", "59.594 11.983 -86.74 96.97557654378755\n", "60.914 12.497 -85.213 95.14323325912358\n", "60.423 13.318 -84.922 94.82821276392379\n", "61.296 12.035 -84.413 94.3742559546829\n", "62.065 12.917 -86.128 95.73217206874604\n", "62.515 14.075 -85.996 95.33733374182434\n", "62.572 12.077 -86.901 96.52664930991854\n", "58.028 9.0 -85.83 97.00523938942679\n", "58.838 8.645 -85.363 96.45048136219953\n", "57.191 8.077 -86.619 98.1386280014144\n", "56.849 8.606 -87.396 98.84869338539583\n", "55.927 7.611 -85.89 97.85150676918572\n", "54.874 7.524 -86.515 98.72558872956898\n", "58.068 6.923 -87.114 98.65443358511567\n", "58.834 7.311 -87.627 98.88945894785752\n", "58.416 6.432 -86.316 97.92870166095331\n", "57.344 5.917 -88.019 99.90078844033215\n", "56.556 5.536 -87.536 99.71491487736425\n", "57.034 6.376 -88.852 100.6584671103231\n", "58.319 4.791 -88.383 100.28854655442963\n", "59.117 5.185 -88.838 100.45671826712237\n", "58.608 4.326 -87.546 99.5455183169991\n", "57.666 3.771 -89.319 101.56239014024827\n", "56.857 3.379 -88.882 101.42977868949534\n", "57.401 4.216 -90.174 102.32183723917393\n", "58.614 2.672 -89.632 101.9259688254176\n", "58.195 2.001 -90.243 102.76317353020973\n", "58.897 2.195 -88.8 101.20431181031763\n", "59.436 3.024 -90.079 102.08917602762791\n", "56.011 7.286 -84.596 96.6797530199576\n", "56.886 7.396 -84.124 95.99438025738797\n", "54.852 6.77 -83.845 96.3858700951545\n", "54.278 6.376 -84.563 97.30015517973237\n", "54.065 7.861 -83.126 95.68131736655803\n", "52.84 7.774 -83.061 95.98117812363006\n", "55.267 5.704 -82.828 95.57248445028517\n", "55.968 6.089 -82.227 94.73705861488418\n", "54.466 5.449 -82.286 95.34038792662845\n", "55.829 4.447 -83.487 96.3518126762543\n", "55.114 4.018 -84.039 97.15767112276826\n", "56.597 4.7 -84.075 96.64856278807254\n", "56.312 3.453 -82.443 95.51098321659137\n", "55.679 3.218 -81.415 94.7781603588084\n", "57.447 2.844 -82.681 95.61793060404518\n", "57.806 2.181 -82.024 95.10142925319262\n", "57.954 3.042 -83.52 96.23040553276287\n", "54.747 8.86 -82.56 94.75328608549678\n", "55.747 8.843 -82.575 94.50731714528774\n", "54.06 9.976 -81.92 94.11293552429441\n", "53.2 9.611 -81.564 94.09441614676186\n", "53.713 11.047 -82.957 94.98127570210877\n", "52.564 11.458 -82.988 95.26252084109468\n", "54.839 10.496 -80.706 92.65377447249519\n", "55.661 10.924 -81.081 92.70398861429858\n", "54.255 11.197 -80.296 92.29551025374961\n", "55.222 9.144 -79.55 91.73699021114655\n", "55.315 9.625 -78.324 90.45968404211901\n", "54.624 11.421 -83.867 95.5239225063544\n", "55.507 10.951 -83.855 95.36559569362527\n", "54.427 12.471 -84.884 96.3588274575817\n", "54.846 12.149 -85.733 97.10851070323342\n", "53.442 12.578 -85.018 96.73599115634264\n", "55.037 13.827 -84.501 95.61526793352617\n", "54.594 14.861 -85.006 96.06043969293498\n", "55.963 13.844 -83.542 94.45795223272629\n", "56.146 12.996 -83.044 94.07253053362601\n", "56.724 15.036 -83.181 93.74129407043621\n", "56.056 15.776 -83.104 93.73345273166885\n", "57.734 15.38 -84.275 94.49556267888985\n", "58.176 14.506 -85.014 95.22786588493938\n", "57.435 14.82 -81.836 92.30843276754295\n", "57.957 13.968 -81.885 92.35882117588986\n", "58.059 15.585 -81.679 91.89489397131922\n", "56.497 14.728 -80.647 91.42299033066027\n", "55.718 15.846 -80.302 91.13710160521894\n", "55.776 16.679 -80.852 91.53420443746698\n", "56.404 13.549 -79.885 90.90789577918962\n", "56.956 12.751 -80.128 91.13145466851716\n", "54.859 15.803 -79.193 90.32397755856414\n", "54.321 16.608 -78.944 90.13016602669718\n", "55.531 13.493 -78.778 90.10028977200906\n", "55.46 12.654 -78.239 89.75433040249368\n", "54.757 14.622 -78.431 89.80535906614926\n", "53.945 14.607 -77.339 89.01100555549297\n", "53.03 14.603 -77.621 89.5507962834502\n", "58.137 16.646 -84.351 94.30551095773777\n", "57.666 17.329 -83.793 93.79542894512504\n", "59.237 17.088 -85.213 94.83331453133967\n", "59.498 16.337 -85.82 95.45708366590715\n", "60.454 17.42 -84.359 93.70326183223293\n", "60.41 18.391 -83.601 92.866029111834\n", "58.75 18.263 -86.068 95.63529477133429\n", "57.85 18.046 -86.446 96.22995974747157\n", "58.683 19.081 -85.497 95.01243789104666\n", "59.729 18.526 -87.215 96.50670271540729\n", "60.631 18.727 -86.834 95.92774802422915\n", "59.784 17.71 -87.79 97.14165512796248\n", "59.276 19.709 -88.073 97.32225753135815\n", "58.393 19.502 -88.494 97.94339714345219\n", "59.191 20.526 -87.503 96.71525745713548\n", "60.324 19.946 -89.162 98.14294921694578\n", "61.218 20.09 -88.737 97.53801938731378\n", "60.365 19.148 -89.764 98.79473676264337\n", "60.015 21.133 -89.994 98.92100270923258\n", "60.712 21.268 -90.698 99.45944241247282\n", "59.977 21.962 -89.436 98.32516459177681\n", "59.132 21.03 -90.452 99.55891090706044\n", "61.513 16.626 -84.444 93.66635652143196\n", "61.475 15.838 -85.058 94.37351035115734\n", "62.733 16.859 -83.675 92.65209462284163\n", "62.475 17.438 -82.902 91.87693482044337\n", "63.762 17.601 -84.526 93.20426729501176\n", "63.715 17.528 -85.751 94.41849948500558\n", "63.287 15.534 -83.144 92.20936666087671\n", "63.647 15.015 -83.919 92.97285725414702\n", "64.03 15.741 -82.507 91.4262924710392\n", "62.256 14.657 -82.414 91.82408674198726\n", "61.465 14.522 -83.011 92.57986958837216\n", "62.946 13.353 -82.066 91.56156828058376\n", "62.323 12.735 -81.586 91.32206222485341\n", "63.737 13.513 -81.475 90.81635763451426\n", "63.267 12.887 -82.89 92.37787817978933\n", "61.745 15.29 -81.118 90.57658966863346\n", "61.078 14.696 -80.668 90.36911393280339\n", "61.303 16.168 -81.298 90.71769540723574\n", "62.496 15.45 -80.477 89.78171828384663\n", "64.664 18.318 -83.864 92.31927823049745\n", "64.496 18.523 -82.9 91.38122895868713\n", "65.887 18.82 -84.478 92.6701204272445\n", "65.837 18.614 -85.455 93.65940450910415\n", "67.08 18.098 -83.857 91.96155023704199\n", "67.298 18.193 -82.644 90.72702665688985\n", "65.988 20.338 -84.315 92.34701204695254\n", "65.146 20.758 -84.653 92.77621592843718\n", "66.103 20.554 -83.345 91.3556408384288\n", "67.157 20.921 -85.08 92.87899814812819\n", "68.424 21.016 -84.479 92.10777147450696\n", "68.548 20.729 -83.529 91.17714359969827\n", "67.001 21.29 -86.428 94.20184410084549\n", "66.107 21.2 -86.867 94.7709401715526\n", "69.518 21.514 -85.209 92.65784570126806\n", "70.414 21.595 -84.773 92.120453032972\n", "68.092 21.784 -87.161 94.74342319126959\n", "67.972 22.054 -88.116 95.68477106102098\n", "69.352 21.898 -86.55 93.97721813822751\n", "70.13 22.252 -87.069 94.3810552494514\n", "67.825 17.374 -84.685 92.7578800372238\n", "67.52 17.303 -85.635 93.74181262915712\n", "69.054 16.673 -84.321 92.33092510638025\n", "69.21 16.824 -83.345 91.33198658739445\n", "70.186 17.277 -85.148 92.9412443966617\n", "70.233 17.119 -86.37 94.16133650814436\n", "68.925 15.149 -84.547 92.77691957593763\n", "68.799 14.972 -85.523 93.77625906912687\n", "67.689 14.583 -83.812 92.29869312725938\n", "67.789 14.776 -82.836 91.30029859754018\n", "66.876 15.047 -84.162 92.68591579091184\n", "70.216 14.45 -84.077 92.27096822944907\n", "70.158 13.461 -84.213 92.56695221838082\n", "70.381 14.618 -83.105 91.27265516571762\n", "71.01 14.784 -84.585 92.63775004823896\n", "67.477 13.074 -83.975 92.72716049249\n", "66.664 12.77 -83.478 92.40900506444163\n", "68.261 12.562 -83.624 92.3670883810895\n", "67.357 12.831 -84.938 93.72447371417991\n", "71.106 17.957 -84.47 92.096315637489\n", "70.963 18.124 -83.494 91.12682294472907\n", "72.316 18.467 -85.102 92.55330953564005\n", "72.045 19.045 -85.872 93.27855025138416\n", "73.154 17.294 -85.645 93.15843563521233\n", "73.399 16.328 -84.926 92.55114713497612\n", "73.08 19.312 -84.076 91.38536443544993\n", "72.457 19.985 -83.678 90.97561214413454\n", "73.429 18.714 -83.355 90.7065115909547\n", "74.246 20.047 -84.691 91.8415464754378\n", "75.45 19.358 -84.932 92.0773233592289\n", "75.555 18.412 -84.625 91.86652672763894\n", "74.095 21.383 -85.105 92.14918409839558\n", "73.237 21.867 -84.934 92.0035203076491\n", "76.504 20.001 -85.605 92.63656502159392\n", "77.359 19.514 -85.784 92.83075035784209\n", "75.153 22.037 -85.76 92.68896772000431\n", "75.059 22.994 -86.036 92.90684420428884\n", "76.346 21.339 -86.026 92.94841994353642\n", "77.341 21.946 -86.711 93.5503260763959\n", "78.088 22.089 -86.13 92.94107024346125\n", "73.582 17.357 -86.904 94.366295540304\n", "73.446 18.226 -87.38 94.74869893038108\n", "74.233 16.284 -87.668 95.2123481697621\n", "74.967 16.704 -88.201 95.64403093241103\n", "74.625 15.645 -87.006 94.61837984768076\n", "73.291 15.52 -88.615 96.31309205398817\n", "73.767 14.789 -89.483 97.23906845501966\n", "71.965 15.657 -88.452 96.23786003959148\n", "71.649 16.2 -87.674 95.42577811052945\n", "70.937 15.067 -89.335 97.28229202686376\n", "71.436 14.525 -90.011 97.97896330845718\n", "70.141 16.135 -90.081 97.95500970343477\n", "69.811 15.933 -91.246 99.16411629717676\n", "69.99 14.185 -88.503 96.68487167597627\n", "70.541 13.523 -87.995 96.2297091651014\n", "69.497 14.771 -87.86 96.02047894589987\n", "68.959 13.414 -89.347 97.74458336399003\n", "68.515 14.05 -89.979 98.3206646488926\n", "69.431 12.702 -89.867 98.31430028739462\n", "67.885 12.757 -88.47 97.11932008102198\n", "67.347 12.115 -89.016 97.82875808779339\n", "68.318 12.269 -87.712 96.40462348871033\n", "66.966 13.763 -87.905 96.5287222074342\n", "67.24 14.718 -88.018 96.46057910359029\n", "65.83 13.562 -87.27 96.10180806311605\n", "65.353 12.366 -87.065 96.16834945552512\n", "65.853 11.565 -87.394 96.55075878003238\n", "64.487 12.25 -86.579 95.85305191281078\n", "65.133 14.572 -86.859 95.65481383077382\n", "65.457 15.503 -87.024 95.63407677705682\n", "64.27 14.421 -86.377 95.34676205828912\n", "69.783 17.209 -89.376 97.1659333974619\n", "70.198 17.335 -88.475 96.21765606685707\n", "68.82 18.22 -89.833 97.61238756428406\n", "68.448 17.841 -90.68 98.53307537065918\n", "69.466 19.576 -90.191 97.75918848885766\n", "68.765 20.477 -90.653 98.21730526745274\n", "67.725 18.399 -88.761 96.67005355331091\n", "68.156 18.75 -87.929 95.7580545855021\n", "67.061 19.066 -89.1 97.02444199272675\n", "66.965 17.115 -88.397 96.55617692307416\n", "66.64 16.288 -89.275 97.56496989186232\n", "66.662 16.908 -87.199 95.44577793700462\n", "70.771 19.741 -89.959 97.37958813837734\n", "71.245 19.004 -89.477 96.92674822256238\n", "71.572 20.908 -90.349 97.59384901724084\n", "70.946 21.684 -90.272 97.51699573407704\n", "72.045 20.817 -91.807 99.00880683050372\n", "72.214 19.728 -92.364 99.63908928226914\n", "72.764 21.094 -89.387 96.52503282568723\n", "73.277 21.903 -89.674 96.71329909066282\n", "72.405 21.236 -88.465 95.62618863574978\n", "73.733 19.903 -89.345 96.51295194946634\n", "73.233 18.768 -89.166 96.47841843645655\n", "74.964 20.121 -89.356 96.42998275432801\n", "72.27 21.97 -92.441 99.53767472670837\n", "72.037 22.83 -91.986 99.05062061390629\n", "72.847 22.007 -93.781 100.82447104745951\n", "72.604 21.134 -94.204 101.32357295812263\n", "74.371 22.108 -93.705 100.64264096793167\n", "74.943 22.858 -92.914 99.77726442431663\n", "72.23 23.127 -94.624 101.64398727913029\n", "72.393 23.999 -94.162 101.12835114348498\n", "72.678 23.135 -95.518 102.49974268260384\n", "70.737 22.986 -94.848 102.00217883947381\n", "70.248 22.171 -95.888 103.12947201455071\n", "70.887 21.679 -96.479 103.68872730436998\n", "69.837 23.669 -94.01 101.22192733296478\n", "70.185 24.242 -93.268 100.42321616040783\n", "68.86 22.049 -96.096 103.48653155845933\n", "68.512 21.474 -96.837 104.29751718041997\n", "68.451 23.551 -94.21 101.57729829543607\n", "67.814 24.04 -93.614 101.03908319556349\n", "67.962 22.74 -95.256 102.71491619526347\n", "66.62 22.635 -95.449 103.08035364219508\n", "66.433 22.61 -96.387 104.03470757876912\n", "75.051 21.371 -94.584 101.53112597130006\n", "74.545 20.767 -95.2 102.21577428655522\n", "76.514 21.414 -94.68 101.56018868139229\n", "76.858 21.154 -93.778 100.66782588791715\n", "76.967 22.84 -95.022 101.79577022646865\n", "76.633 23.353 -96.088 102.84337968483922\n", "77.033 20.403 -95.723 102.65796739659324\n", "76.652 20.688 -96.603 103.52508889153391\n", "78.566 20.403 -95.79 102.68896895966967\n", "78.895 19.746 -96.468 103.41398243951346\n", "78.963 20.158 -94.906 101.82222578592554\n", "78.914 21.306 -96.043 102.86865649944107\n", "76.582 18.97 -95.398 102.4731595345825\n", "76.924 18.323 -96.08 103.20248527046235\n", "75.584 18.903 -95.384 102.50556101012276\n", "76.922 18.681 -94.503 101.5988330789286\n", "77.762 23.453 -94.138 100.85846365080126\n", "77.959 22.976 -93.281 100.02368933907607\n", "78.367 24.779 -94.337 100.98613969253405\n", "79.329 24.7 -94.076 100.71549193644441\n", "78.302 24.983 -95.314 101.95614187482771\n", "77.734 25.932 -93.549 100.17556451550448\n", "78.206 27.059 -93.679 100.27187655070588\n", "76.703 25.685 -92.74 99.40479077489172\n", "76.307 24.767 -92.735 99.44522171527399\n", "76.125 26.705 -91.856 98.51947231385275\n", "76.095 27.534 -92.414 99.06613435478342\n", "77.007 26.985 -90.62 97.24693429100991\n", "77.766 26.124 -90.164 96.78700334755695\n", "74.707 26.297 -91.435 98.17649516050163\n", "74.753 25.391 -91.014 97.77881012264363\n", "74.376 26.96 -90.764 97.51282927389606\n", "73.701 26.24 -92.593 99.39436934253368\n", "73.662 27.142 -93.023 99.80904797662384\n", "74.023 25.567 -93.259 100.0562231647787\n", "72.279 25.847 -92.144 99.05990783864075\n", "71.317 26.457 -92.666 99.64643634872246\n", "72.121 24.893 -91.344 98.30654725398506\n", "76.906 28.196 -90.057 96.67562694909198\n", "76.346 28.892 -90.506 97.14486949396762\n", "77.588 28.535 -88.806 95.4036279918117\n", "78.54 28.258 -88.935 95.51179848584152\n", "76.973 27.743 -87.644 94.26457150488724\n", "75.798 27.898 -87.302 93.96922071082638\n", "77.568 30.049 -88.539 95.14902182891845\n", "77.968 30.525 -89.323 95.93110858840316\n", "76.621 30.347 -88.415 95.06113219397295\n", "78.371 30.399 -87.279 93.87685700959528\n", "77.938 29.993 -86.174 92.7746218855135\n", "79.458 31.001 -87.414 94.01074169476593\n", "77.798 26.898 -87.023 93.63033787186714\n", "78.753 26.882 -87.318 93.90596013033465\n", "77.407 25.992 -85.94 92.57946204207497\n", "76.77 25.333 -86.339 93.01989715646863\n", "76.665 26.753 -84.827 91.47488082528449\n", "75.602 26.325 -84.379 91.08418946776658\n", "78.669 25.267 -85.4 92.0333770378986\n", "79.298 25.946 -85.022 91.62551680072532\n", "79.42 24.542 -86.546 93.19762031833217\n", "78.759 23.978 -87.042 93.72678746228317\n", "79.794 25.237 -87.161 93.78253578891967\n", "78.307 24.325 -84.238 90.91803443211913\n", "79.119 23.857 -83.889 90.57926355408284\n", "77.653 23.628 -84.532 91.26250093000958\n", "77.895 24.832 -83.481 90.14923811658088\n", "80.578 23.631 -86.117 92.8104501605288\n", "81.009 23.202 -86.911 93.62963328455368\n", "80.256 22.903 -85.511 92.24627282985475\n", "81.28 24.149 -85.629 92.30255538716142\n", "77.196 27.898 -84.391 91.00479408250975\n", "78.014 28.237 -84.855 91.443562589173\n", "76.661 28.696 -83.275 89.90659535873884\n", "76.538 28.07 -82.505 89.14335866456905\n", "75.297 29.282 -83.638 90.33582007155302\n", "74.371 29.249 -82.817 89.57124338759621\n", "77.668 29.811 -82.907 89.51350590274072\n", "77.817 30.309 -83.761 90.37134080005673\n", "77.168 30.844 -81.887 88.53040398642717\n", "77.87 31.531 -81.699 88.34179234654457\n", "76.928 30.405 -81.021 87.66345520797135\n", "76.356 31.319 -82.227 88.91495749872459\n", "78.967 29.196 -82.363 88.93579579112114\n", "79.627 29.908 -82.121 88.69515448433471\n", "79.394 28.6 -83.043 89.60859189832189\n", "78.79 28.65 -81.544 88.11725413901638\n", "75.152 29.795 -84.858 91.56739774614107\n", "75.935 29.771 -85.479 92.14756844323131\n", "73.903 30.392 -85.335 92.13048418954499\n", "73.603 31.027 -84.623 91.4564072003706\n", "72.798 29.34 -85.489 92.35106932786431\n", "71.712 29.503 -84.921 91.88036340263353\n", "74.168 31.174 -86.63 93.42343385361083\n", "74.971 31.755 -86.499 93.26245921055266\n", "74.343 30.525 -87.371 94.13574896924122\n", "72.97 32.057 -87.013 93.91885997498053\n", "72.236 31.467 -87.349 94.2926676417631\n", "72.66 32.543 -86.196 93.14899307024204\n", "73.302 33.093 -88.102 95.02309648711729\n", "72.554 34.094 -88.176 95.20695943574714\n", "74.312 32.915 -88.819 95.66171214754627\n", "73.104 28.21 -86.135 92.9684593074447\n", "74.025 28.125 -86.515 93.28226449867091\n", "72.175 27.081 -86.324 93.24322562524314\n", "71.418 27.44 -86.87 93.8499619019635\n", "71.632 26.587 -84.992 91.97461048572046\n", "70.424 26.387 -84.84 91.9483220836574\n", "72.887 25.926 -87.053 93.93658218713304\n", "73.72 25.754 -86.527 93.35591864472225\n", "72.075 24.624 -87.126 94.12130812945601\n", "72.584 23.911 -87.608 94.59108663082372\n", "71.212 24.767 -87.61 94.67524091334545\n", "71.861 24.283 -86.211 93.24444501416691\n", "73.174 26.328 -88.491 95.33793749604614\n", "73.637 25.591 -88.984 95.81662094334155\n", "73.76 27.137 -88.527 95.31702384673999\n", "72.328 26.54 -88.98 95.88649356921964\n", "72.502 26.407 -83.999 90.9125215743134\n", "73.465 26.625 -84.156 90.98774348779071\n", "72.097 25.901 -82.686 89.65389850419223\n", "71.557 25.073 -82.84 89.8857608801305\n", "71.206 26.922 -81.981 89.01307990402309\n", "70.125 26.574 -81.501 88.65899429273941\n", "73.343 25.539 -81.861 88.73932081101364\n", "73.961 26.324 -81.821 88.63063998979133\n", "74.067 24.356 -82.546 89.41706353934914\n", "73.605 23.503 -82.302 89.2510571197899\n", "74.033 24.481 -83.538 90.4022653090065\n", "72.947 25.193 -80.411 87.33918109302377\n", "73.752 24.956 -79.867 86.74347176589141\n", "72.32 24.415 -80.387 87.40294930378494\n", "72.494 25.967 -79.969 86.91151782704061\n", "75.523 24.248 -82.127 88.91629738692451\n", "75.97 23.478 -82.581 89.38730810355574\n", "75.603 24.111 -81.14 87.93445011484407\n", "76.027 25.079 -82.363 89.09042302065919\n", "71.607 28.194 -81.941 88.91942618460828\n", "72.468 28.443 -82.384 89.28107171175758\n", "70.831 29.238 -81.271 88.33339255909965\n", "70.703 28.935 -80.326 87.40576507874064\n", "69.441 29.41 -81.898 89.11539065728208\n", "68.437 29.511 -81.184 88.53545577337928\n", "71.629 30.545 -81.332 88.33286858808559\n", "72.56 30.367 -81.012 87.92488652253127\n", "71.657 30.859 -82.281 89.28207612953453\n", "71.04 31.654 -80.483 87.57999800182688\n", "70.416 31.462 -79.447 86.61197022352049\n", "71.262 32.889 -80.874 87.9979818518584\n", "70.923 33.655 -80.328 87.5320643250232\n", "71.77 33.063 -81.718 88.79566490544457\n", "69.364 29.415 -83.228 90.44498870584262\n", "70.209 29.344 -83.757 90.87280152498877\n", "68.098 29.52 -83.944 91.31597122628658\n", "67.684 30.343 -83.555 90.9988974163973\n", "67.201 28.306 -83.717 91.20966714663528\n", "66.016 28.459 -83.402 91.07455386659876\n", "68.325 29.653 -85.448 92.77901056273448\n", "68.997 28.965 -85.724 92.96380973798352\n", "67.457 29.476 -85.911 93.35074963276942\n", "68.836 31.034 -85.885 93.17523860983668\n", "68.502 31.722 -85.241 92.59888380536776\n", "69.836 31.027 -85.878 93.0514815035204\n", "68.349 31.394 -87.297 94.64621068484463\n", "68.323 32.607 -87.577 94.97116675075652\n", "67.741 30.522 -87.978 95.37707659600393\n", "67.738 27.095 -83.864 91.29165901658267\n", "68.721 27.016 -84.027 91.3257085436516\n", "66.93 25.882 -83.793 91.36260632228046\n", "66.077 26.09 -84.272 91.95762489320829\n", "66.516 25.54 -82.36 90.01844989223042\n", "65.394 25.063 -82.152 90.0079467491621\n", "67.635 24.743 -84.537 92.03969318723308\n", "68.587 24.687 -84.235 91.6176542048529\n", "67.171 23.88 -84.339 91.94815198251676\n", "67.603 24.994 -86.037 93.5190187341591\n", "66.551 25.247 -86.614 94.22771333848658\n", "68.733 24.991 -86.693 94.02429174420831\n", "68.744 25.196 -87.672 94.98656916111877\n", "69.587 24.784 -86.216 93.45854614747653\n", "67.326 25.886 -81.353 88.89193782340442\n", "68.256 26.185 -81.566 88.96457871535165\n", "66.904 25.845 -79.945 87.56397895824514\n", "66.587 24.911 -79.781 87.48464300664432\n", "65.735 26.813 -79.717 87.49964869643763\n", "64.706 26.401 -79.18 87.15638297910257\n", "68.085 26.114 -78.989 86.43829765214028\n", "68.509 26.962 -79.307 86.67515342357346\n", "67.614 26.249 -77.535 85.06409345311333\n", "68.386 26.423 -76.923 84.34298350781765\n", "67.159 25.413 -77.226 84.85418151747149\n", "66.967 27.005 -77.437 85.04828855420901\n", "69.093 24.958 -79.004 86.35812628814963\n", "69.855 25.139 -78.383 85.6401240657672\n", "69.469 24.822 -79.921 87.22547901272885\n", "68.661 24.102 -78.719 86.17251546171782\n", "65.802 28.063 -80.2 87.94909990443335\n", "66.642 28.354 -80.657 88.26594909703287\n", "64.686 29.032 -80.086 88.02632259159756\n", "64.473 29.066 -79.11 87.10416185234779\n", "63.422 28.581 -80.824 88.98116235473663\n", "62.311 28.754 -80.312 88.69593751688969\n", "65.133 30.405 -80.603 88.47613955185884\n", "65.632 30.283 -81.461 89.23630953261122\n", "64.324 30.971 -80.765 88.79040184051426\n", "66.043 31.116 -79.597 87.35110891683057\n", "65.516 31.353 -78.781 86.6414167185648\n", "66.797 30.51 -79.343 86.96551825292597\n", "66.605 32.391 -80.227 87.93032008357527\n", "67.126 32.156 -81.048 88.6526100292597\n", "65.852 33.001 -80.473 88.32094136160461\n", "67.522 33.093 -79.228 86.83968879492832\n", "66.978 33.487 -78.487 86.21111285095442\n", "68.177 32.439 -78.85 86.34080896655995\n", "68.273 34.183 -79.894 87.45547244741178\n", "68.877 34.649 -79.247 86.76652943387789\n", "67.65 34.864 -80.279 87.96904231603297\n", "68.837 33.826 -80.639 88.09547405514087\n", "63.582 27.944 -81.988 90.0969831292924\n", "64.51 27.874 -82.353 90.29041394300947\n", "62.493 27.337 -82.774 91.08107810626748\n", "61.754 28.01 -82.746 91.1936690839885\n", "61.941 26.049 -82.143 90.59834747941046\n", "60.965 25.517 -82.673 91.334010609411\n", "62.961 27.103 -84.229 92.42360000562627\n", "63.825 26.6 -84.204 92.251080058718\n", "62.269 26.554 -84.697 93.0244406433062\n", "63.179 28.4 -85.038 93.16720438008215\n", "62.289 28.818 -85.222 93.51468969097849\n", "63.737 29.028 -84.496 92.53458706883605\n", "63.892 28.135 -86.382 94.36392587212552\n", "64.702 27.572 -86.215 94.06683316663742\n", "63.267 27.647 -86.991 95.07651467107952\n", "64.328 29.451 -87.061 94.96226843857512\n", "63.53 29.888 -87.476 95.5125500915979\n", "64.724 30.061 -86.375 94.2279621927589\n", "65.347 29.249 -88.134 95.85550868364321\n", "65.606 30.12 -88.551 96.23811119301958\n", "64.993 28.655 -88.857 96.62244338661696\n", "66.175 28.826 -87.767 95.36558406993582\n", "62.5 25.565 -81.028 89.40948073890151\n", "63.253 26.086 -80.625 88.85209821382948\n", "62.093 24.328 -80.35 88.87765311933028\n", "61.52 23.873 -81.032 89.68487175661232\n", "61.227 24.559 -79.103 87.83073080647797\n", "61.417 25.497 -78.319 86.98702600962973\n", "63.309 23.462 -80.018 88.35814540833233\n", "63.994 23.981 -79.506 87.69883325335634\n", "63.044 22.652 -79.494 87.94671989903887\n", "63.905 23.025 -81.216 89.44781285755397\n", "64.848 22.926 -81.086 89.15927712246213\n", "60.227 23.694 -78.878 87.8768127778881\n", "60.069 22.971 -79.55 88.60870334792175\n", "59.342 23.75 -77.687 86.92422001950894\n", "59.239 24.727 -77.501 86.72016970693727\n", "59.957 23.108 -76.443 85.60996194953015\n", "59.565 23.452 -75.319 84.59388550598678\n", "57.984 23.102 -77.996 87.59627953857401\n", "58.14 22.176 -78.34 87.95141563954499\n", "57.449 23.058 -77.152 86.92307132171527\n", "57.184 23.883 -79.041 88.76484648215192\n", "57.008 24.804 -78.694 88.43237532148505\n", "57.718 23.94 -79.884 89.43945125614312\n", "55.848 23.2 -79.343 89.44892816574159\n", "56.001 22.269 -79.675 89.78680877500881\n", "55.279 23.171 -78.521 88.81948341439507\n", "55.135 23.957 -80.38 90.59827466900238\n", "54.643 24.777 -80.088 90.41787949847087\n", "55.086 23.652 -81.664 91.86032092802637\n", "55.413 22.489 -82.16 92.31752289246066\n", "55.726 21.757 -81.554 91.70256608187145\n", "55.35 22.33 -83.145 93.29178983168883\n", "54.725 24.566 -82.511 92.72876777462321\n", "54.49 25.483 -82.188 92.44858336394344\n", "54.682 24.354 -83.487 93.68764897252998\n", "60.876 22.165 -76.631 85.6453053646258\n", "61.098 21.931 -77.578 86.53380344119863\n", "61.595 21.436 -75.581 84.52276837042194\n", "61.481 21.976 -74.747 83.69371159770607\n", "63.071 21.329 -75.927 84.5568868987027\n", "63.439 21.401 -77.093 85.61593292139028\n", "61.004 20.026 -75.403 84.61254333726176\n", "61.072 19.543 -76.276 85.49281545252794\n", "61.542 19.543 -74.712 83.87249612358035\n", "59.54 20.007 -74.963 84.53405147631337\n", "59.0 20.55 -75.606 85.23422003514784\n", "59.212 19.062 -74.965 84.71738948999786\n", "59.371 20.587 -73.561 83.16734451694367\n", "59.879 20.031 -72.903 82.46252245717444\n", "59.715 21.526 -73.541 82.9777909624015\n", "57.954 20.606 -73.153 83.1403272185045\n", "57.553 19.732 -72.879 83.07442644400261\n", "57.163 21.661 -73.114 83.22410377408698\n", "57.567 22.864 -73.421 83.31676165694391\n", "58.515 23.017 -73.701 83.32364573156889\n", "56.929 23.632 -73.376 83.40033983144194\n", "55.917 21.509 -72.762 83.2547313069954\n", "55.571 20.601 -72.526 83.2136006251382\n", "55.307 22.301 -72.728 83.33916638052003\n", "63.878 21.115 -74.901 83.41344962894172\n", "63.51 21.241 -73.98 82.57652788777209\n", "65.269 20.707 -75.031 83.31733633524298\n", "65.524 20.644 -75.996 84.22368850270094\n", "65.394 19.329 -74.387 82.80646609414025\n", "65.131 19.193 -73.195 81.70514956843294\n", "66.153 21.772 -74.361 82.4118026559303\n", "66.037 22.634 -74.854 82.84962534616557\n", "65.849 21.885 -73.415 81.5267060907038\n", "67.649 21.415 -74.351 82.19051652106829\n", "67.748 20.524 -73.907 81.82095495653908\n", "68.217 21.32 -75.762 83.5047556490048\n", "69.189 21.088 -75.742 83.37158753436329\n", "68.119 22.189 -76.247 83.926595796565\n", "67.744 20.617 -76.292 84.15942422569204\n", "68.429 22.48 -73.591 81.23937248034353\n", "69.405 22.265 -73.574 81.10335453604863\n", "68.113 22.549 -72.645 80.34789106130913\n", "68.319 23.378 -74.018 81.61474592253535\n", "65.735 18.307 -75.161 83.62261259970296\n", "65.809 18.462 -76.146 84.55423539953513\n", "66.009 16.965 -74.647 83.24931950472629\n", "65.572 16.875 -73.752 82.46556715381274\n", "67.521 16.836 -74.51 82.88914877111479\n", "68.227 16.991 -75.497 83.72941821128342\n", "65.402 15.882 -75.562 84.40239219951054\n", "65.737 16.031 -76.493 85.22905794387263\n", "63.856 15.977 -75.564 84.67481163840873\n", "63.529 15.758 -74.645 83.88128528462114\n", "63.602 16.916 -75.794 84.81321494319148\n", "65.847 14.484 -75.101 84.09920078692781\n", "65.459 13.773 -75.687 84.85591115532259\n", "65.55 14.305 -74.163 83.27085715302803\n", "66.843 14.397 -75.13 83.97785075244542\n", "63.137 15.047 -76.547 85.90995456872271\n", "62.145 15.164 -76.491 86.04008024752184\n", "63.345 14.089 -76.351 85.83544893573982\n", "63.417 15.236 -77.488 86.73680250043806\n", "68.006 16.551 -73.306 81.67950265519495\n", "67.364 16.49 -72.542 81.040838303907\n", "69.428 16.321 -73.033 81.24616054312966\n", "69.921 16.597 -73.858 81.95060295690325\n", "69.616 14.843 -72.739 81.16991661323793\n", "68.972 14.305 -71.834 80.46690341997758\n", "69.95 17.17 -71.862 79.9054394706643\n", "69.497 16.863 -71.025 79.18882025892292\n", "69.599 18.659 -72.041 79.92882990510995\n", "70.104 19.023 -72.823 80.58936944163293\n", "68.617 18.747 -72.208 80.21807921534895\n", "71.471 16.968 -71.708 79.60236473874377\n", "71.83 17.513 -70.95 78.73999650749293\n", "71.955 17.241 -72.539 80.32963195483968\n", "71.689 16.009 -71.527 79.54634486888759\n", "69.961 19.472 -70.801 78.56367639692023\n", "69.73 20.437 -70.925 78.61066774299783\n", "70.94 19.413 -70.607 78.25769909088817\n", "69.468 19.139 -69.997 77.8780536158936\n", "70.502 14.197 -73.482 81.89700625786024\n", "70.989 14.71 -74.189 82.44471343269984\n", "70.807 12.78 -73.327 81.97076272061886\n", "70.049 12.359 -72.829 81.65874247133615\n", "72.077 12.639 -72.506 81.06132106621504\n", "73.139 13.083 -72.913 81.27370178600209\n", "70.917 12.101 -74.699 83.42740924899921\n", "71.684 12.476 -75.22 83.78087328859732\n", "69.611 12.368 -75.481 84.29152686361778\n", "68.83 12.088 -74.923 83.90528949953037\n", "69.543 13.345 -75.684 84.31597298851504\n", "71.192 10.597 -74.514 83.52739451221976\n", "71.267 10.135 -75.398 84.47727709271884\n", "70.455 10.158 -74.0 83.20766947823981\n", "72.046 10.447 -74.015 82.98748447205759\n", "69.56 11.605 -76.789 85.71908204711481\n", "68.709 11.791 -77.279 86.26841627154168\n", "69.615 10.619 -76.631 85.75940691259473\n", "70.32 11.864 -77.385 86.15782340565481\n", "71.973 12.013 -71.343 80.06494232808764\n", "71.066 11.711 -71.051 79.942498453576\n", "73.097 11.74 -70.467 79.16160079861953\n", "73.819 12.369 -70.756 79.25074589554346\n", "73.568 10.3 -70.637 79.60409063609734\n", "72.798 9.355 -70.446 79.70915426724837\n", "72.72 12.009 -69.009 77.72122419905646\n", "71.986 11.377 -68.763 77.69358168471832\n", "73.525 11.821 -68.446 77.14066536529225\n", "72.244 13.427 -68.684 77.16219959280579\n", "71.408 13.634 -69.192 77.70769772036743\n", "72.004 13.475 -67.17 75.70255310093577\n", "71.689 14.38 -66.886 75.28521113738076\n", "72.844 13.27 -66.667 75.16730870531417\n", "71.311 12.808 -66.896 75.65011391927972\n", "73.259 14.487 -69.112 77.28222862340344\n", "72.932 15.406 -68.892 76.93456433229474\n", "73.425 14.447 -70.097 78.23964870831156\n", "74.134 14.353 -68.647 76.77758659270296\n", "74.856 10.148 -70.917 79.81404135864817\n", "75.392 10.976 -71.08 79.75170880300935\n", "75.557 8.863 -71.006 80.16259195535035\n", "74.87 8.141 -70.923 80.30548810012924\n", "76.552 8.767 -69.855 79.02122947031387\n", "77.082 9.781 -69.401 78.31023986044225\n", "76.262 8.724 -72.367 81.47689506847938\n", "76.946 9.453 -72.398 81.3024341702018\n", "76.936 7.357 -72.534 81.95188287037706\n", "77.388 7.286 -73.423 82.81187896672796\n", "76.266 6.617 -72.47 82.1141037459461\n", "77.626 7.209 -71.826 81.28276157956248\n", "75.263 8.853 -73.515 82.6122264195803\n", "75.72 8.763 -74.4 83.46588973946183\n", "74.806 9.742 -73.494 82.41295893850675\n", "74.559 8.145 -73.459 82.77470759839626\n", "76.809 7.558 -69.351 78.83578236435534\n", "76.257 6.78 -69.65 79.35920780854607\n", "77.875 7.338 -68.374 77.9160134503813\n", "77.85 8.079 -67.703 77.07149197336197\n", "79.219 7.359 -69.097 78.57776327944184\n", "79.56 6.409 -69.785 79.49634368321601\n", "77.634 6.004 -67.664 77.61804105361072\n", "76.722 6.014 -67.254 77.25875474663049\n", "77.69 5.264 -68.334 78.47362576687789\n", "78.672 5.761 -66.565 76.61199975852347\n", "79.59 5.776 -66.962 76.9739039220436\n", "78.598 6.476 -65.87 75.73891415250155\n", "78.42 4.401 -65.921 76.42187725383354\n", "77.495 4.371 -65.541 76.09829234614926\n", "78.524 3.678 -66.604 77.29671546061968\n", "79.383 4.156 -64.829 75.41615496032664\n", "80.087 4.849 -64.675 75.0453578710902\n", "79.392 3.101 -64.04 74.96710495944205\n", "78.498 2.16 -64.164 75.41820489112692\n", "77.79 2.232 -64.867 76.10908647461223\n", "78.52 1.366 -63.556 75.0903109395613\n", "80.309 2.969 -63.121 74.09238561417766\n", "81.012 3.672 -63.012 73.75624367468832\n", "80.309 2.165 -62.526 73.77530195804013\n", "79.998 8.412 -68.896 78.10024799576503\n", "79.657 9.167 -68.336 77.36831145242863\n", "81.341 8.505 -69.467 78.63640733146447\n", "81.437 7.762 -70.129 79.46923498436361\n", "82.408 8.277 -68.39 77.67790163231754\n", "82.318 8.793 -67.271 76.46120675872177\n", "81.487 9.832 -70.218 79.04018565261597\n", "80.578 10.163 -70.473 79.2008004694397\n", "81.928 10.499 -69.617 78.3085330918668\n", "82.334 9.663 -71.487 80.33113719473911\n", "83.282 9.485 -71.222 80.14678400285315\n", "81.982 8.887 -72.01 81.01569873796066\n", "82.294 10.916 -72.372 80.90785623782155\n", "82.628 10.776 -73.567 82.11353977268304\n", "81.949 11.995 -71.836 80.14688640864347\n", "83.42 7.469 -68.706 78.23202460629534\n", "83.435 7.076 -69.626 79.2185869730078\n", "84.518 7.117 -67.788 77.43580581358988\n", "84.051 6.826 -66.953 76.68694757910241\n", "85.417 8.306 -67.436 76.84363066643846\n", "86.09 8.277 -66.408 75.87337059864943\n", "85.367 5.981 -68.384 78.31027132503118\n", "86.269 5.992 -67.952 77.92207945120562\n", "85.575 6.177 -69.766 79.60806981079243\n", "86.514 6.221 -69.944 79.80608917870867\n", "84.657 4.633 -68.245 78.5032278444651\n", "85.21 3.895 -68.633 79.08855750992048\n", "83.777 4.641 -68.721 78.94644421378331\n", "84.485 4.416 -67.284 77.63202108666243\n", "85.41 9.36 -68.252 77.41279259269749\n", "84.704 9.379 -68.96 78.04860146088461\n", "86.342 10.499 -68.212 77.16812625689444\n", "87.099 10.152 -67.658 76.74311472699034\n", "85.82 11.735 -67.466 76.12269155777402\n", "86.451 12.789 -67.508 75.98708877829179\n", "86.807 10.855 -69.641 78.51032004774915\n", "86.734 11.84 -69.8 78.44279036979752\n", "87.752 10.563 -69.787 78.78599942248624\n", "86.017 10.215 -70.632 79.55581839815363\n", "86.545 10.071 -71.417 80.39072228808496\n", "84.697 11.622 -66.747 75.37353719310246\n", "84.33 10.711 -66.56 75.38101722582417\n", "83.99 12.793 -66.226 74.57146967842326\n", "83.317 12.483 -65.555 73.95191420105365\n", "84.655 13.391 -65.779 74.04747429858766\n", "83.295 13.536 -67.366 75.50165235277967\n", "83.744 13.49 -68.501 76.64185192177966\n", "82.166 14.177 -67.073 75.05129042861287\n", "81.893 14.208 -66.112 74.09589189691962\n", "81.288 14.842 -68.044 75.86348811516643\n", "81.158 14.185 -68.787 76.71288894964131\n", "81.917 16.102 -68.68 76.28483566214193\n", "81.304 17.167 -68.687 76.11376781502805\n", "79.964 15.169 -67.336 75.10077223304698\n", "80.172 15.68 -66.502 74.18954441833431\n", "79.414 15.738 -67.947 75.6072145896144\n", "79.121 13.975 -66.942 74.94357032461156\n", "78.222 13.429 -67.876 75.9846971304091\n", "78.158 13.819 -68.794 76.81013168846933\n", "79.203 13.429 -65.646 73.78173861464637\n", "79.83 13.825 -64.975 73.03847640114078\n", "77.414 12.337 -67.521 75.88818049604299\n", "76.766 11.959 -68.182 76.64083508156732\n", "78.402 12.326 -65.295 73.68847455335197\n", "78.463 11.934 -64.377 72.88049083945579\n", "77.516 11.776 -66.238 74.75639320486242\n", "76.957 10.983 -65.994 74.72347570208441\n", "83.152 16.003 -69.173 76.82487666765239\n", "83.585 15.102 -69.138 76.96062892154663\n", "83.929 17.093 -69.76 77.26800735750858\n", "83.967 17.796 -69.05 76.46657499849199\n", "83.25 17.672 -70.995 78.37626680315924\n", "83.401 18.863 -71.255 78.48362508192393\n", "85.33 16.595 -70.13 77.78848738727345\n", "85.871 17.327 -70.543 78.12453859063746\n", "85.807 16.241 -69.325 77.08398849307164\n", "85.244 15.544 -71.072 78.87832691557296\n", "85.225 14.704 -70.613 78.56910350131277\n", "82.457 16.86 -71.7 79.16316646016631\n", "82.413 15.894 -71.444 79.05777102853331\n", "81.656 17.318 -72.822 80.1885382894588\n", "82.285 17.749 -73.469 80.78413882687616\n", "80.675 18.411 -72.388 79.60033510607855\n", "80.818 19.503 -72.907 79.98519044798229\n", "81.024 16.127 -73.543 81.06743239427286\n", "80.622 16.459 -74.396 81.85761490539534\n", "81.749 15.469 -73.749 81.38481960414975\n", "79.951 15.381 -72.817 80.46498061890028\n", "80.107 14.543 -71.77 79.57523540021731\n", "80.971 14.369 -71.297 79.14442672734448\n", "78.55 15.298 -73.177 80.85008152129471\n", "78.896 13.962 -71.449 79.37461802112814\n", "78.765 13.304 -70.708 78.77347459646552\n", "77.891 14.405 -72.281 80.13564291874123\n", "77.784 15.87 -74.203 81.79047623042673\n", "78.229 16.444 -74.89 82.37078098452145\n", "76.52 14.128 -72.376 80.32946498639214\n", "76.084 13.473 -71.759 79.86561164230822\n", "76.405 15.648 -74.277 81.95042926672197\n", "75.866 16.1 -74.988 82.60898774951791\n", "75.775 14.796 -73.362 81.21985434608953\n", "74.785 14.662 -73.411 81.35070063004989\n", "79.889 18.222 -71.312 78.55700946446471\n", "80.024 17.375 -70.798 78.16373124410067\n", "78.842 19.148 -70.815 77.95834512096827\n", "78.3 19.312 -71.639 78.76802644474469\n", "79.311 20.555 -70.367 77.34879765064225\n", "78.506 21.334 -69.848 76.7689339576889\n", "78.032 18.454 -69.693 76.95137161870475\n", "78.675 18.094 -69.017 76.31452837435346\n", "77.442 19.137 -69.262 76.45611730921209\n", "77.145 17.293 -70.17 77.61386760753518\n", "77.734 16.71 -70.73 78.23292223226741\n", "76.563 16.528 -68.979 76.57844854134876\n", "75.985 15.772 -69.286 77.0326082123668\n", "76.005 17.128 -68.406 75.94939499429867\n", "77.29 16.147 -68.408 76.04520743610342\n", "75.947 17.78 -70.99 78.41197156047028\n", "75.383 17.011 -71.291 78.85103551634562\n", "76.248 18.277 -71.804 79.1354882085149\n", "75.369 18.393 -70.451 77.83018929695596\n", "80.59 20.893 -70.539 77.48168265467652\n", "81.222 20.177 -70.836 77.85678687179428\n", "81.138 22.235 -70.325 77.15199141305428\n", "80.361 22.85 -70.188 76.9618455599916\n", "81.685 22.197 -69.489 76.33076804277552\n", "82.006 22.772 -71.469 78.26588149379012\n", "82.503 23.892 -71.349 78.08447367434835\n", "82.211 22.006 -72.547 79.4051285560322\n", "81.623 21.208 -72.679 79.5935863056817\n", "83.25 22.274 -73.545 80.41083803816498\n", "83.83 22.997 -73.17 80.00803270922239\n", "83.783 21.433 -73.638 80.59542409467178\n", "82.762 22.703 -74.929 81.74109597381234\n", "83.53 23.345 -75.645 82.43935198071367\n", "81.525 22.387 -75.331 82.13564535571629\n", "80.914 21.907 -74.702 81.53856306067699\n", "81.046 22.731 -76.678 83.4477628819371\n", "81.882 22.872 -77.209 83.98042351643626\n", "80.264 24.05 -76.71 83.39374533500698\n", "79.516 24.386 -75.788 82.45820617136901\n", "80.262 21.573 -77.302 84.15408098244554\n", "80.193 21.682 -78.294 85.13380717435348\n", "80.693 20.695 -77.092 84.02382757884813\n", "78.954 21.529 -76.794 83.66070428821406\n", "78.33 21.519 -77.52 84.39639905825365\n", "80.401 24.799 -77.81 84.45576857148362\n", "81.099 24.545 -78.479 85.1402429994183\n", "79.568 25.98 -78.075 84.67845283187454\n", "79.746 26.606 -77.316 83.90181874667557\n", "78.076 25.625 -78.091 84.73015762407148\n", "77.247 26.416 -77.647 84.2877062744028\n", "79.972 26.62 -79.41 85.99403972950682\n", "79.313 27.322 -79.679 86.25430904598332\n", "80.884 27.026 -79.346 85.92435026812831\n", "80.01 25.653 -80.448 87.05854424466331\n", "80.019 24.775 -80.067 86.71156473043257\n", "77.737 24.408 -78.522 85.22040915179885\n", "78.471 23.802 -78.827 85.53850010959977\n", "76.37 23.899 -78.579 85.35390753211009\n", "75.872 24.573 -79.125 85.88829174573213\n", "75.683 23.846 -77.218 84.03339698001028\n", "74.591 24.394 -77.042 83.89481051888728\n", "76.384 22.504 -79.237 86.09642630214101\n", "76.835 22.571 -80.127 86.96015530114926\n", "76.894 21.875 -78.65 85.53707141351053\n", "74.965 21.947 -79.443 86.41681187130199\n", "74.586 21.714 -78.547 85.56744919652566\n", "74.406 22.66 -79.867 86.82294511245284\n", "74.897 20.698 -80.329 87.4061291958407\n", "73.755 20.236 -80.546 87.74090487338275\n", "75.95 20.213 -80.808 87.86984241478984\n", "76.327 23.219 -76.238 83.0618061987578\n", "77.24 22.852 -76.417 83.22715464318121\n", "75.746 23.048 -74.909 81.77795227321359\n", "74.845 22.649 -75.078 82.02792893277265\n", "75.627 24.381 -74.188 80.98668441787206\n", "74.62 24.616 -73.526 80.37833173809966\n", "76.609 22.131 -74.053 80.94993854228673\n", "77.533 22.51 -74.013 80.84520273337188\n", "76.222 22.099 -73.132 80.05364070421783\n", "76.68 20.702 -74.614 81.63058314749442\n", "75.936 20.158 -74.226 81.33469641549048\n", "76.587 20.733 -75.609 82.62117734576286\n", "78.0 20.039 -74.268 81.30690099862373\n", "77.998 18.816 -74.036 81.21387231871167\n", "79.009 20.776 -74.306 81.24984494754435\n", "76.609 25.276 -74.333 81.0407656985051\n", "77.408 25.033 -74.883 81.56870009384727\n", "76.552 26.599 -73.713 80.38139771738234\n", "76.435 26.433 -72.734 79.41342365746486\n", "75.349 27.4 -74.227 80.94243604562443\n", "74.605 27.972 -73.428 80.18719925274856\n", "77.863 27.356 -73.961 80.56566860021705\n", "78.071 27.327 -74.939 81.53790471921631\n", "77.745 28.306 -73.673 80.2727801250212\n", "79.04 26.743 -73.183 79.77392287583707\n", "78.805 26.716 -72.211 78.80669941699118\n", "79.197 25.813 -73.515 80.13011302874844\n", "80.332 27.538 -73.346 79.91457619858845\n", "80.417 28.526 -74.056 80.61831052558718\n", "81.393 27.152 -72.671 79.25445789985571\n", "82.248 27.666 -72.746 79.33953753961514\n", "81.345 26.345 -72.083 78.68442162207205\n", "75.097 27.378 -75.54 82.26852973038962\n", "75.724 26.872 -76.133 82.8328557397365\n", "73.95 28.056 -76.161 82.9598864391701\n", "73.956 28.994 -75.814 82.61309882216014\n", "72.634 27.392 -75.749 82.66571046086763\n", "71.679 28.078 -75.369 82.37376762659336\n", "74.11 28.046 -77.694 84.47697215809761\n", "74.23 27.09 -77.96 84.74487008073113\n", "75.344 28.861 -78.132 84.83336658414541\n", "75.118 29.835 -78.111 84.83474417359906\n", "76.098 28.68 -77.501 84.16287337062583\n", "72.863 28.6 -78.405 85.28277334256902\n", "72.981 28.587 -79.398 86.26218455963192\n", "72.683 29.544 -78.129 85.02926393307189\n", "72.054 28.056 -78.185 85.13858052610462\n", "75.784 28.485 -79.55 86.22492810086884\n", "76.584 29.016 -79.83 86.4686673252225\n", "75.053 28.66 -80.21 86.92428535225353\n", "76.023 27.516 -79.606 86.27518329160476\n", "72.568 26.06 -75.795 82.74700365572158\n", "73.371 25.552 -76.107 83.00447301802475\n", "71.376 25.313 -75.41 82.50871242481001\n", "70.617 25.686 -75.944 83.1095875576338\n", "71.035 25.518 -73.922 81.06045368735607\n", "69.873 25.747 -73.582 80.85470715425292\n", "71.591 23.837 -75.762 82.90669382504647\n", "71.811 23.728 -76.731 83.8528805766385\n", "70.77 23.3 -75.571 82.83878819731731\n", "72.343 23.448 -75.231 82.32751659682198\n", "72.039 25.501 -73.038 80.07497202622052\n", "72.959 25.315 -73.383 80.33712617463982\n", "71.886 25.736 -71.598 78.65091356748502\n", "71.133 25.134 -71.333 78.49488689717312\n", "71.496 27.177 -71.296 78.35455885907342\n", "70.586 27.391 -70.498 77.66549459058379\n", "73.17 25.368 -70.829 77.77446947424328\n", "73.947 25.783 -71.302 78.1634085809978\n", "73.1 25.746 -69.906 76.84776452831923\n", "73.439 23.861 -70.706 77.70464341981115\n", "73.573 23.555 -71.648 78.64887147950694\n", "74.305 23.803 -70.21 77.14404763168704\n", "72.122 22.932 -69.875 77.06747162065199\n", "71.176 22.464 -71.346 78.66439426449556\n", "70.373 21.922 -71.098 78.55909054972568\n", "71.733 21.919 -71.972 79.2667510687804\n", "70.86 23.273 -71.841 79.13318896013227\n", "72.114 28.157 -71.956 78.93374749750578\n", "72.863 27.918 -72.574 79.47747615519758\n", "71.745 29.565 -71.816 78.83866757499139\n", "71.853 29.793 -70.848 77.8680434132\n", "70.275 29.799 -72.199 79.39301950423601\n", "69.503 30.356 -71.415 78.7272417718289\n", "72.692 30.414 -72.672 79.61018380207396\n", "73.624 30.31 -72.324 79.17867498891353\n", "72.651 30.09 -73.617 80.54777013052565\n", "72.343 31.886 -72.659 79.67887404450443\n", "71.543 32.428 -73.683 80.80300121282625\n", "71.228 31.847 -74.433 81.55636678396115\n", "72.79 32.702 -71.603 78.62446918103802\n", "73.357 32.313 -70.877 77.83114444745111\n", "71.187 33.788 -73.649 80.88475345205671\n", "70.616 34.174 -74.374 81.69441680433246\n", "72.44 34.065 -71.568 78.70710289421152\n", "72.76 34.647 -70.82 77.97677729939856\n", "71.635 34.607 -72.593 79.8462675019941\n", "71.285 35.919 -72.568 79.96992075149255\n", "72.075 36.46 -72.562 79.93151200871905\n", "69.85 29.295 -73.361 80.59313888290988\n", "70.506 28.812 -73.941 81.08437761985967\n", "68.465 29.42 -73.822 81.23995514523627\n", "68.242 30.393 -73.761 81.22832300989599\n", "67.468 28.67 -72.916 80.49063590878133\n", "66.328 29.107 -72.753 80.51998958643748\n", "68.391 28.924 -75.275 82.68473792061023\n", "68.932 28.087 -75.356 82.68997509976647\n", "67.436 28.727 -75.498 83.04616553459888\n", "68.92 29.934 -76.285 83.62209895715367\n", "68.657 31.122 -76.209 83.6107559408477\n", "69.639 29.497 -77.29 84.51908831145779\n", "69.967 30.136 -77.986 85.1790996195663\n", "69.86 28.524 -77.361 84.55698110741655\n", "67.876 27.556 -72.306 79.83054045288682\n", "68.813 27.243 -72.462 79.850242460496\n", "67.018 26.773 -71.421 79.10849245814256\n", "66.107 26.827 -71.829 79.66557069399552\n", "66.895 27.341 -69.997 77.71513269627737\n", "65.808 27.3 -69.421 77.3432257796376\n", "67.559 25.347 -71.389 79.03361149536315\n", "67.641 24.974 -72.313 79.9480139903425\n", "66.954 24.746 -70.867 78.64524770130743\n", "68.464 25.316 -70.964 78.47535715751792\n", "67.994 27.83 -69.415 76.9538375001533\n", "68.819 27.923 -69.972 77.37741720295398\n", "68.063 28.239 -68.008 75.55110554452529\n", "67.296 27.763 -67.579 75.25887165643661\n", "67.848 29.735 -67.79 75.37946055789999\n", "67.309 30.109 -66.753 74.45506192328362\n", "69.42 27.818 -67.419 74.76517024657939\n", "70.143 28.142 -68.029 75.26639176285786\n", "69.522 28.248 -66.522 73.8598512116021\n", "69.579 26.302 -67.247 74.60254312689347\n", "69.381 25.87 -68.127 75.51551610761857\n", "70.999 25.976 -66.803 73.9840234442545\n", "71.12 24.99 -66.686 73.89402699136109\n", "71.212 26.418 -65.932 73.07966078875845\n", "71.667 26.29 -67.478 74.56389260225085\n", "68.62 25.77 -66.179 73.70878076593046\n", "68.722 24.782 -66.066 73.62529522521454\n", "67.669 25.954 -66.428 74.10263676820144\n", "68.795 26.201 -65.294 72.7927286547221\n", "68.27 30.581 -68.734 76.26140550763537\n", "68.608 30.204 -69.596 77.0520735152533\n", "68.261 32.044 -68.563 76.14700309926846\n", "68.178 32.187 -67.577 75.19440337551724\n", "67.049 32.681 -69.235 77.03917609891735\n", "66.42 33.557 -68.653 76.62947774192384\n", "69.577 32.674 -69.067 76.48177537819058\n", "69.603 32.526 -70.056 77.4485969659877\n", "69.632 34.177 -68.77 76.27650570129704\n", "70.487 34.576 -69.1 76.51959221010001\n", "69.571 34.351 -67.787 75.32760706407711\n", "68.877 34.658 -69.215 76.86032571489663\n", "70.8 32.02 -68.406 75.6338562087112\n", "71.649 32.432 -68.736 75.88057593350226\n", "70.835 31.041 -68.607 75.79032477829871\n", "70.772 32.129 -67.412 74.65739233324453\n", "66.675 32.232 -70.438 78.26441135024271\n", "67.186 31.481 -70.855 78.55694303497305\n", "65.533 32.81 -71.167 79.21417310683739\n", "65.552 33.774 -70.901 79.0074820380956\n", "64.158 32.274 -70.717 79.01308505557797\n", "63.146 32.663 -71.295 79.80767338420536\n", "65.741 32.687 -72.688 80.66326490416812\n", "65.971 31.739 -72.907 80.79472979099565\n", "64.891 32.939 -73.151 81.28716386982633\n", "66.869 33.598 -73.196 81.02075521741327\n", "66.762 34.501 -72.78 80.69055249532005\n", "67.746 33.205 -72.92 80.5853443623591\n", "66.873 33.765 -74.713 82.5242741864477\n", "66.265 33.038 -75.482 83.33888103400477\n", "67.541 34.783 -75.212 82.98139088373972\n", "67.542 34.945 -76.199 83.96622184545402\n", "68.048 35.395 -74.604 82.35452899507106\n", "64.114 31.372 -69.724 78.01341859577748\n", "64.998 31.066 -69.371 77.47954208692768\n", "62.919 30.773 -69.085 77.62636630681614\n", "63.279 29.941 -68.663 77.11598699361889\n", "61.836 30.222 -70.057 78.8054964199833\n", "60.694 29.943 -69.684 78.71258373347936\n", "62.379 31.715 -67.976 76.7027719251397\n", "63.009 32.487 -67.892 76.5129087213393\n", "61.481 32.047 -68.263 77.20877845167607\n", "62.222 31.08 -66.577 75.35730041608443\n", "62.551 29.881 -66.382 75.05930189523481\n", "61.734 31.798 -65.676 74.63015945983233\n", "62.187 30.032 -71.336 79.96606125100823\n", "63.161 30.054 -71.562 79.97353644800259\n", "61.234 29.794 -72.426 81.2413765577615\n", "60.337 30.091 -72.098 81.14245579842897\n", "61.517 30.372 -73.191 81.93115290901257\n", "61.13 28.345 -72.911 81.72805904339097\n", "60.221 28.014 -73.684 82.69626830758448\n", "62.045 27.462 -72.496 81.1220212272845\n", "62.706 27.756 -71.805 80.29874603005952\n", "62.134 26.083 -72.998 81.62168316078761\n", "61.28 25.914 -73.49 82.29866055410622\n", "62.231 25.106 -71.826 80.4939286157658\n", "63.164 25.142 -71.034 79.51626199086574\n", "63.309 25.915 -73.991 82.3461421440009\n", "64.167 26.079 -73.504 81.69202387626348\n", "63.213 26.939 -75.148 83.4716757289561\n", "62.384 26.75 -75.674 84.1620213219716\n", "63.158 27.858 -74.758 83.08842389286247\n", "63.303 24.479 -74.552 82.95436266405764\n", "64.054 24.343 -75.198 83.44436471086587\n", "62.447 24.285 -75.031 83.61000845592591\n", "63.404 23.807 -73.818 82.2521494551966\n", "64.403 26.902 -76.107 84.18004471963648\n", "64.297 27.579 -76.836 84.90537929365841\n", "64.492 26.002 -76.534 84.6052133677352\n", "65.257 27.099 -75.626 83.54716160947659\n", "61.268 24.18 -71.728 80.6640397265101\n", "60.485 24.221 -72.349 81.45062866546826\n", "61.335 23.104 -70.728 79.74425496548324\n", "61.629 23.558 -69.887 78.82960086794807\n", "62.357 22.054 -71.148 79.99555202634706\n", "62.284 21.544 -72.27 81.14448992383893\n", "59.974 22.451 -70.47 79.87530578345223\n", "59.581 22.174 -71.347 80.84215284738524\n", "60.111 21.644 -69.896 79.35326659942866\n", "58.988 23.386 -69.768 79.38963391400668\n", "59.413 23.753 -68.941 78.45791313819149\n", "58.751 24.138 -70.383 79.9992451026883\n", "57.716 22.62 -69.388 79.42871204419721\n", "57.276 22.267 -70.214 80.37015059087547\n", "57.949 21.859 -68.783 78.84526977568153\n", "56.763 23.577 -68.667 78.95081756384793\n", "57.234 23.994 -67.89 78.0455086792315\n", "56.466 24.292 -69.3 79.60071060612461\n", "55.557 22.881 -68.157 78.88056119222276\n", "54.946 23.519 -67.689 78.58800307298817\n", "55.806 22.162 -67.508 78.24350378785448\n", "55.045 22.457 -68.904 79.77977854694758\n", "63.232 21.696 -70.216 78.92804835418141\n", "63.178 22.147 -69.325 78.0350223104985\n", "64.271 20.684 -70.409 78.99395873736168\n", "64.452 20.685 -71.392 79.91613933367903\n", "63.771 19.302 -69.99 78.83879745404542\n", "63.086 19.163 -68.975 78.01760782669511\n", "65.559 21.052 -69.659 77.97520978490536\n", "65.357 20.986 -68.682 77.06555912987331\n", "66.693 20.098 -70.036 78.23721329393065\n", "67.535 20.333 -69.55 77.5944391370928\n", "66.883 20.137 -71.017 79.16158458494877\n", "66.458 19.154 -69.806 78.16096591649823\n", "66.015 22.473 -69.99 78.09135461112196\n", "66.854 22.704 -69.497 77.44143762870108\n", "65.316 23.142 -69.737 77.92439788666961\n", "66.196 22.573 -70.968 79.01041236444726\n", "64.122 18.281 -70.766 79.64606356876654\n", "64.606 18.499 -71.613 80.34581862797839\n", "63.863 16.867 -70.491 79.62716246357144\n", "63.399 16.818 -69.607 78.87683990247073\n", "65.202 16.143 -70.447 79.43052971622436\n", "65.878 16.037 -71.464 80.31007691441964\n", "62.95 16.25 -71.566 80.94913727149907\n", "63.471 16.252 -72.42 81.66509477126688\n", "62.564 14.809 -71.206 80.91748272159731\n", "61.971 14.411 -71.906 81.78854228435668\n", "62.075 14.776 -70.334 80.19452911514601\n", "63.375 14.23 -71.125 80.76731606906348\n", "61.668 17.071 -71.763 81.30138155652708\n", "61.084 16.661 -72.463 82.16826878424541\n", "61.881 18.005 -72.049 81.40253876876324\n", "61.141 17.122 -70.914 80.59947962611173\n", "65.588 15.644 -69.277 78.30444731942113\n", "65.033 15.833 -68.467 77.59549552648014\n", "66.792 14.83 -69.129 78.08403208082943\n", "67.419 15.129 -69.848 78.62534515663508\n", "66.481 13.354 -69.342 78.61635333694892\n", "65.622 12.804 -68.65 78.21304093947505\n", "67.418 15.069 -67.749 76.59779158043656\n", "66.693 15.275 -67.092 76.0496387959864\n", "67.903 14.243 -67.462 76.39012083378321\n", "68.407 16.245 -67.794 76.28422616111406\n", "68.449 16.58 -68.735 77.14261728124085\n", "67.967 17.376 -66.897 75.30402611414613\n", "68.616 18.136 -66.933 75.12737843156782\n", "67.9 17.074 -65.946 74.43364487246342\n", "67.071 17.724 -67.173 75.67283859483534\n", "69.774 15.794 -67.343 75.71897956259052\n", "70.427 16.551 -67.368 75.53231581912472\n", "70.124 15.066 -67.933 76.37313801330936\n", "69.745 15.443 -66.407 74.87039322722967\n", "67.204 12.72 -70.261 79.5063202896474\n", "67.826 13.268 -70.82 79.84126677977999\n", "67.157 11.284 -70.513 80.05496842170385\n", "66.41 10.914 -69.96 79.72962002292496\n", "68.483 10.66 -70.079 79.56889505956457\n", "69.518 10.979 -70.643 79.89675199280632\n", "66.867 11.009 -72.001 81.594163872179\n", "67.637 11.356 -72.536 81.91439538933312\n", "66.794 10.019 -72.124 81.94278261079495\n", "65.583 11.649 -72.552 82.20896888417954\n", "65.712 12.638 -72.482 81.92087817522466\n", "65.362 11.211 -74.0 83.73191376052502\n", "64.529 11.619 -74.375 84.16065440572571\n", "65.273 10.217 -74.064 84.02061371473074\n", "66.128 11.489 -74.579 84.10087154720811\n", "64.332 11.28 -71.757 81.75507082744164\n", "63.519 11.715 -72.145 82.19752274855976\n", "64.413 11.575 -70.805 80.76515742571175\n", "64.183 10.291 -71.761 82.00252216852844\n", "68.467 9.774 -69.089 78.82454049977075\n", "67.609 9.619 -68.6 78.5255873266797\n", "69.654 9.013 -68.682 78.451404691057\n", "70.446 9.579 -68.911 78.43001565089733\n", "69.675 7.685 -69.444 79.51790739827099\n", "68.795 6.854 -69.217 79.64487956548116\n", "69.631 8.731 -67.169 77.07664877250437\n", "68.769 8.269 -66.961 77.1211140350034\n", "70.395 8.119 -66.964 76.93959904366541\n", "69.744 9.938 -66.228 75.85619919953805\n", "70.644 10.356 -66.354 75.75705815961967\n", "69.033 10.598 -66.47 76.03079115726733\n", "69.576 9.538 -64.738 74.5524071844766\n", "69.778 10.396 -63.842 73.45032381821062\n", "69.228 8.374 -64.433 74.6176756137579\n", "70.658 7.451 -70.314 80.28829524905856\n", "71.315 8.178 -70.513 80.2159049129286\n", "70.802 6.153 -70.989 81.26617285808406\n", "69.879 5.902 -71.282 81.72650302074597\n", "71.27 5.05 -70.032 80.61472866046253\n", "70.911 3.887 -70.198 81.15880201801896\n", "71.704 6.291 -72.231 82.31691866803565\n", "72.536 6.779 -71.968 81.85213379014624\n", "71.942 5.375 -72.555 82.85455774427862\n", "71.029 7.059 -73.384 83.2911369654659\n", "70.78 7.95 -73.004 82.72796018880194\n", "71.973 7.219 -74.574 84.29610907390683\n", "71.53 7.718 -75.319 84.933616913446\n", "72.258 6.328 -74.928 84.83873611151924\n", "72.796 7.724 -74.313 83.84151552780996\n", "69.777 6.354 -73.907 84.1227358387731\n", "69.359 6.872 -74.653 84.75496590170985\n", "69.094 6.252 -73.183 83.54565476432631\n", "69.997 5.442 -74.252 84.6703392221857\n", "71.973 5.428 -68.964 79.41404054699647\n", "72.182 6.401 -68.867 79.02213372846876\n", "72.46 4.524 -67.926 78.64943273158428\n", "71.886 3.711 -68.021 79.0495921494855\n", "72.301 5.112 -66.518 77.15263443331018\n", "72.089 6.308 -66.335 76.6457067356026\n", "73.935 4.206 -68.159 78.83679689713428\n", "74.435 5.069 -68.233 78.60670995532125\n", "74.274 3.69 -67.372 78.2273167953497\n", "74.191 3.384 -69.427 80.27393747038948\n", "73.616 2.566 -69.409 80.56210167318129\n", "73.96 3.936 -70.228 80.88031434780653\n", "75.661 2.962 -69.517 80.39603137593298\n", "76.054 2.515 -70.606 81.54800810565516\n", "76.364 3.066 -68.477 79.34208357485957\n", "72.435 4.275 -65.479 76.4172305308168\n", "72.58 3.302 -65.658 76.88550012193457\n", "72.376 4.74 -64.084 74.96066083620128\n", "71.576 5.338 -64.026 74.80598613079034\n", "73.631 5.546 -63.729 74.25145682745894\n", "74.671 4.963 -63.424 74.06139380946054\n", "72.195 3.552 -63.126 74.46823046104963\n", "71.476 2.956 -63.484 75.08475664873664\n", "73.055 3.044 -63.075 74.50537879240666\n", "71.803 4.01 -61.711 73.03448588851707\n", "72.503 4.635 -61.366 72.42581452079085\n", "70.924 4.485 -61.755 73.02383645769373\n", "71.678 2.82 -60.746 72.56131826944713\n", "70.974 2.194 -61.081 73.18095305473959\n", "72.554 2.34 -60.696 72.58923639906952\n", "71.291 3.317 -59.345 71.13311489032375\n", "71.951 4.004 -59.043 70.53142605250514\n", "70.378 3.723 -59.378 71.14095620667464\n", "71.272 2.222 -58.337 70.6036426397392\n", "71.018 2.57 -57.435 69.67784148493693\n", "72.171 1.792 -58.258 70.58485404107599\n", "70.613 1.513 -58.59 71.18857709632915\n", "73.504 6.866 -63.661 73.799786950912\n", "72.647 7.277 -63.971 74.05799836614544\n", "74.559 7.753 -63.154 72.97099939702073\n", "75.447 7.379 -63.42 73.2693964285226\n", "74.476 7.773 -61.621 71.50858977074013\n", "73.509 8.278 -61.048 70.90085240672357\n", "74.444 9.148 -63.805 73.22008963392493\n", "73.538 9.516 -63.598 73.0012787079788\n", "74.6 9.047 -65.34 74.71094081859765\n", "75.567 8.91 -65.556 74.88865764586784\n", "74.071 8.263 -65.665 75.2726217558549\n", "75.507 10.102 -63.226 72.33822358891598\n", "75.44 11.009 -63.642 72.51922962911286\n", "76.43 9.755 -63.393 72.53467895427676\n", "75.393 10.208 -62.238 71.36578255718912\n", "74.115 10.293 -66.083 75.15135757922141\n", "74.232 10.19 -67.071 76.12235252539165\n", "74.626 11.103 -65.796 74.64068144115514\n", "73.146 10.462 -65.904 75.02219685533075\n", "75.455 7.152 -60.952 70.98347272428984\n", "76.199 6.735 -61.475 71.56165276179695\n", "75.489 7.053 -59.484 69.61690565516396\n", "74.536 6.888 -59.23 69.4983963915715\n", "75.963 8.349 -58.821 68.56448452369492\n", "75.429 8.722 -57.781 67.49847871619033\n", "76.389 5.89 -59.036 69.50712291556887\n", "77.293 6.01 -59.446 69.81195888957707\n", "76.469 5.914 -58.04 68.55560575182747\n", "75.842 4.515 -59.45 70.38754345763176\n", "74.9 4.433 -59.124 70.17485491256824\n", "75.857 4.451 -60.448 71.34502752820269\n", "76.655 3.355 -58.878 70.17586094234969\n", "77.552 3.497 -58.074 69.2954344960763\n", "76.366 2.131 -59.264 70.95933087339536\n", "76.88 1.356 -58.896 70.82657648792578\n", "75.633 1.975 -59.926 71.70435274793296\n", "76.926 9.031 -59.437 68.90356950840791\n", "77.229 8.708 -60.334 69.84078813988285\n", "77.566 10.219 -58.886 68.0185604816803\n", "77.162 10.39 -57.987 67.12453639318487\n", "77.27 11.439 -59.767 68.5639489163219\n", "77.736 11.545 -60.902 69.61856116008144\n", "79.068 9.948 -58.713 67.8843059182312\n", "79.186 9.142 -58.132 67.55114699988447\n", "79.47 9.773 -59.612 68.79135019753575\n", "79.803 11.125 -58.07 66.94190861485801\n", "79.099 12.075 -57.657 66.30866171172511\n", "81.054 11.081 -58.079 66.96642808900592\n", "76.447 12.341 -59.234 67.867683686715\n", "76.037 12.13 -58.347 67.08364197775789\n", "76.102 13.617 -59.857 68.20080775914607\n", "76.265 13.492 -60.836 69.17224261219235\n", "77.012 14.758 -59.392 67.45658767681628\n", "76.902 15.86 -59.927 67.76996831930794\n", "74.621 13.926 -59.585 67.97406467911125\n", "74.344 13.472 -58.738 67.27399887772393\n", "74.508 14.915 -59.486 67.68088795221291\n", "73.712 13.453 -60.698 69.2385520501404\n", "73.307 14.378 -61.673 70.03155535185549\n", "73.57 15.339 -61.59 69.73680487375373\n", "73.358 12.093 -60.817 69.69676270100355\n", "73.646 11.436 -60.12 69.15493076419064\n", "72.535 13.956 -62.762 71.25723949185794\n", "72.239 14.619 -63.45 71.82730890824186\n", "72.594 11.663 -61.925 70.9475175816603\n", "72.351 10.698 -62.025 71.30597198692406\n", "72.175 12.608 -62.892 71.71090176535226\n", "71.353 12.311 -63.92 72.86788275365218\n", "71.863 12.241 -64.727 73.6047397522741\n", "77.9 14.543 -58.416 66.51101886153903\n", "78.002 13.613 -58.063 66.36590506427227\n", "78.733 15.603 -57.837 65.70461967015714\n", "78.071 16.303 -57.569 65.3252136467995\n", "79.711 16.19 -58.854 66.57594015858882\n", "79.981 17.389 -58.82 66.32879423749539\n", "79.508 15.104 -56.613 64.594543840792\n", "80.053 14.309 -56.879 65.02077106586786\n", "80.115 15.833 -56.297 64.13333081947326\n", "78.575 14.703 -55.463 63.573384572476556\n", "77.911 15.437 -55.321 63.29911558623864\n", "78.095 13.864 -55.72 64.02541389167274\n", "79.323 14.456 -54.144 62.32762167771204\n", "78.615 14.378 -53.115 61.35796366405913\n", "80.573 14.394 -54.16 62.352303630258916\n", "80.155 15.389 -59.824 67.67879890334933\n", "79.861 14.433 -59.812 67.8603129450491\n", "81.05 15.82 -60.91 68.66845392900585\n", "81.627 16.521 -60.491 68.13918492321433\n", "80.338 16.504 -62.081 69.69278583899484\n", "80.981 16.854 -63.065 70.60755572174978\n", "81.881 14.623 -61.389 69.38482368645178\n", "81.265 13.922 -61.749 69.86868429418148\n", "82.501 14.926 -62.113 70.05209236703783\n", "82.707 14.022 -60.244 68.41440494515757\n", "83.283 14.735 -59.844 67.89887584489158\n", "82.089 13.661 -59.545 67.79029527889666\n", "83.596 12.89 -60.756 69.20000593208067\n", "83.038 12.207 -61.228 69.7910535670583\n", "84.281 13.255 -61.386 69.76880034084003\n", "84.286 12.253 -59.55 68.21477425015786\n", "84.835 12.94 -59.074 67.62699972644062\n", "83.598 11.884 -58.925 67.66104106500283\n", "85.18 11.147 -59.965 68.93293712732688\n", "85.629 10.733 -59.173 68.26240181827768\n", "85.892 11.475 -60.586 69.49988801429826\n", "84.667 10.43 -60.437 69.53116142421324\n", "79.016 16.657 -62.014 69.61031838743449\n", "78.547 16.372 -61.178 68.84638427688124\n", "78.215 17.22 -63.1 70.60576605348886\n", "78.695 17.015 -63.953 71.46862070867186\n", "78.118 18.753 -62.998 70.27778546596356\n", "78.097 19.273 -61.875 69.0953076120224\n", "76.841 16.537 -63.096 70.7664791338385\n", "76.926 15.636 -62.671 70.50368340732277\n", "76.2 17.096 -62.569 70.18789746102956\n", "76.293 16.363 -64.507 72.2125255478577\n", "75.942 17.264 -64.762 72.33716254457318\n", "77.09 16.145 -65.07 72.76515464149031\n", "75.024 15.085 -64.596 72.60588244763643\n", "75.24 14.656 -66.332 74.37231786760447\n", "74.605 13.933 -66.604 74.82169001699975\n", "76.169 14.332 -66.508 74.54997558685046\n", "75.074 15.448 -66.92 74.81708495390608\n", "78.009 19.488 -64.124 71.29853818978337\n", "77.801 20.935 -64.098 71.10988677392194\n", "78.592 21.357 -63.655 70.60307009613675\n", "76.582 21.343 -63.258 70.28431325694234\n", "75.568 20.635 -63.224 70.38611713967464\n", "77.651 21.355 -65.563 72.5280163936668\n", "76.692 21.337 -65.846 72.85104365758943\n", "78.027 22.269 -65.716 72.58312980989453\n", "78.461 20.3 -66.31 73.3584600165516\n", "78.143 20.201 -67.253 74.31445039829063\n", "79.435 20.525 -66.309 73.3159265235051\n", "78.187 19.036 -65.501 72.71657553130511\n", "77.356 18.577 -65.815 73.11655475335253\n", "78.957 18.4 -65.549 72.8329093267597\n", "76.657 22.5 -62.593 69.50958484266756\n", "77.488 23.048 -62.687 69.52026960534603\n", "75.579 23.01 -61.729 68.67098421458658\n", "75.492 22.31 -61.02 68.03258387713934\n", "74.245 23.156 -62.469 69.49690543470264\n", "73.193 22.858 -61.904 69.05842147052017\n", "75.959 24.37 -61.133 67.95632845438311\n", "76.242 24.977 -61.876 68.64532745933987\n", "75.157 24.754 -60.675 67.53247820863676\n", "77.104 24.269 -60.117 66.88800002242554\n", "76.888 23.545 -59.462 66.29626615428654\n", "77.946 24.038 -60.605 67.35620347080142\n", "77.321 25.583 -59.349 66.0404924118529\n", "77.942 25.496 -58.269 64.94217377020884\n", "76.851 26.635 -59.836 66.50984363987034\n", "74.293 23.515 -63.756 70.74493797438795\n", "75.185 23.766 -64.133 71.03385157092356\n", "73.138 23.568 -64.656 71.74026044697635\n", "72.542 24.28 -64.284 71.38621156077691\n", "72.365 22.249 -64.673 71.94085869657103\n", "71.158 22.228 -64.44 71.85380747740511\n", "73.615 23.914 -66.076 73.0828642295853\n", "72.88 23.779 -66.74 73.8206817497644\n", "73.936 24.86 -66.122 73.04645489686682\n", "74.693 23.083 -66.465 73.43804582095034\n", "74.385 22.181 -66.553 73.62183408473331\n", "73.047 21.123 -64.876 72.17826202534944\n", "74.039 21.18 -64.985 72.18895636452989\n", "72.411 19.806 -64.947 72.46140518234517\n", "71.607 19.929 -65.529 73.1112621283479\n", "71.932 19.339 -63.572 71.21777411573602\n", "70.827 18.8 -63.466 71.32195120718445\n", "73.367 18.785 -65.587 73.12682918054084\n", "74.201 18.763 -65.036 72.51251837441588\n", "73.796 19.184 -67.016 74.44774130220472\n", "74.223 20.087 -66.97 74.2583995047025\n", "74.466 18.514 -67.336 74.79664059969538\n", "72.71 17.396 -65.581 73.38350385474926\n", "73.313 16.713 -65.993 73.83630021879482\n", "71.854 17.402 -66.098 73.98253162064677\n", "72.503 17.101 -64.648 72.53414487674063\n", "72.67 19.252 -68.057 75.57213765667873\n", "73.026 19.516 -68.953 76.39106773700705\n", "71.977 19.923 -67.792 75.30303447405024\n", "72.218 18.365 -68.155 75.82927099082517\n", "72.709 19.589 -62.507 70.04954091212875\n", "73.618 19.979 -62.657 70.05753003781962\n", "72.277 19.312 -61.124 68.77138855657925\n", "72.133 18.323 -61.08 68.88475425665682\n", "70.971 20.042 -60.804 68.52528202057982\n", "70.028 19.427 -60.299 68.24267974662192\n", "73.36 19.741 -60.125 67.61318039406221\n", "73.641 20.675 -60.346 67.68835956794935\n", "72.967 19.72 -59.206 66.75113005784995\n", "74.606 18.846 -60.138 67.63410519109424\n", "74.363 17.926 -59.831 67.49071830259328\n", "74.979 18.801 -61.065 68.52546091782236\n", "75.65 19.448 -59.189 66.53397825171737\n", "75.922 20.349 -59.528 66.73431391720455\n", "75.251 19.542 -58.277 65.64872581398667\n", "76.885 18.558 -59.1 66.50093503102043\n", "76.681 17.76 -58.533 66.0773611534238\n", "77.146 18.258 -60.017 67.43935985757872\n", "78.037 19.268 -58.5 65.75675329576423\n", "78.838 18.672 -58.449 65.77176821402934\n", "77.824 19.577 -57.573 64.80359862692812\n", "78.285 20.071 -59.042 66.17774705291802\n", "70.898 21.323 -61.162 68.74053931996751\n", "71.704 21.738 -61.584 69.01037786449224\n", "69.718 22.159 -60.978 68.64630473667174\n", "69.482 22.1 -60.008 67.73468376688564\n", "68.519 21.64 -61.78 69.67611740044073\n", "67.428 21.47 -61.229 69.34550472813648\n", "70.072 23.598 -61.371 68.86166970093014\n", "70.799 23.928 -60.769 68.14065051788103\n", "70.393 23.605 -62.318 69.74973982030326\n", "68.901 24.546 -61.262 68.87462142182706\n", "68.161 24.897 -62.407 70.10644596611641\n", "68.408 24.517 -63.298 70.96231632352485\n", "68.543 25.067 -60.006 67.66998520023482\n", "69.064 24.811 -59.191 66.79345940284871\n", "67.074 25.782 -62.297 70.15273698153194\n", "66.551 26.037 -63.111 71.04098080685542\n", "67.454 25.947 -59.896 67.71850038209647\n", "67.199 26.316 -59.002 66.87707197537883\n", "66.723 26.309 -61.04 68.96785637527094\n", "65.953 26.942 -60.961 69.02744843176517\n", "68.706 21.313 -63.063 70.93708358115661\n", "69.618 21.417 -63.461 71.1760509370954\n", "67.615 20.806 -63.908 72.00214444028732\n", "66.88 21.479 -63.823 71.98189407760816\n", "67.115 19.453 -63.391 71.74494274860076\n", "65.903 19.247 -63.301 71.91467362089602\n", "68.038 20.723 -65.388 73.38882551179029\n", "68.822 20.103 -65.42 73.3632936419842\n", "68.425 22.1 -65.967 73.76071350658152\n", "67.588 22.594 -66.204 74.09013972857656\n", "68.927 22.61 -65.269 72.95198092581174\n", "66.86 20.224 -66.239 74.47950540920637\n", "67.115 20.163 -67.204 75.38513140533748\n", "66.078 20.843 -66.166 74.48564421417055\n", "66.563 19.317 -65.942 74.3504109538071\n", "69.302 22.007 -67.222 74.87055037863685\n", "69.532 22.917 -67.567 75.10382133420376\n", "68.832 21.511 -67.952 75.70375032982183\n", "70.158 21.528 -67.027 74.60192333981745\n", "68.013 18.549 -62.98 71.30631748309543\n", "68.985 18.755 -63.09 71.22559655769827\n", "67.63 17.269 -62.375 70.97563257203137\n", "67.033 16.821 -63.04 71.80069593673866\n", "66.819 17.464 -61.094 69.85155554459757\n", "65.818 16.772 -60.919 69.99427843759801\n", "68.879 16.41 -62.137 70.67588834248919\n", "69.279 16.158 -63.018 71.51360899856753\n", "69.544 16.935 -61.607 69.96754621251198\n", "68.507 15.135 -61.365 70.21934373091221\n", "68.245 15.382 -60.432 69.31450151303116\n", "67.737 14.69 -61.821 70.8776900653513\n", "69.667 14.154 -61.3 70.16729885067545\n", "69.855 13.798 -62.215 71.09803699821816\n", "70.479 14.62 -60.95 69.61628513501708\n", "69.291 13.003 -60.367 69.57170299769871\n", "69.285 13.324 -59.42 68.59012555754654\n", "68.384 12.656 -60.607 70.02799930027989\n", "70.254 11.891 -60.472 69.78564469860547\n", "70.003 11.141 -59.86 69.41881241421521\n", "71.176 12.191 -60.229 69.35508496858755\n", "70.284 11.53 -61.404 70.76313767068275\n", "67.199 18.392 -60.214 68.78369309654722\n", "68.053 18.888 -60.372 68.70967963831588\n", "66.403 18.708 -59.02 67.73597053264979\n", "66.282 17.828 -58.561 67.45089898585489\n", "65.023 19.278 -59.376 68.29387676797973\n", "64.027 18.904 -58.758 67.97962285861846\n", "67.157 19.696 -58.117 66.57196593912485\n", "67.723 20.288 -58.691 66.94648272314237\n", "66.489 20.251 -57.621 66.15324431953434\n", "68.062 18.99 -57.098 65.507826898776\n", "67.507 18.366 -56.549 65.17498760260717\n", "68.76 18.47 -57.59 65.93880029997513\n", "68.755 19.981 -56.164 64.33444648864246\n", "68.852 21.165 -56.422 64.42239692839749\n", "69.267 19.54 -55.036 63.20590940726982\n", "69.724 20.174 -54.412 62.431521821913\n", "69.2 18.57 -54.802 63.13565377027468\n", "64.945 20.155 -60.384 69.17277366854678\n", "65.775 20.343 -60.91 69.48257123192836\n", "63.71 20.86 -60.765 69.74150693812115\n", "63.239 21.082 -59.911 69.00722026715755\n", "62.726 19.991 -61.556 70.84174513660713\n", "61.513 20.117 -61.387 70.97370424319136\n", "64.114 22.126 -61.541 70.27045149990143\n", "64.814 22.608 -61.014 69.55893798067939\n", "64.493 21.847 -62.423 71.06663688398375\n", "62.946 23.096 -61.799 70.71452528299967\n", "62.25 22.634 -62.348 71.45388390423574\n", "62.55 23.375 -60.924 69.94661008226203\n", "63.438 24.345 -62.553 71.24181324896215\n", "64.114 24.815 -61.986 70.50820509699562\n", "63.865 24.054 -63.409 71.99208109924314\n", "62.301 25.33 -62.881 71.78383983181729\n", "61.629 24.878 -63.468 72.54247191818045\n", "61.86 25.622 -62.032 71.06268841663675\n", "62.796 26.549 -63.593 72.30815480289897\n", "62.044 27.175 -63.797 72.67564463422391\n", "63.236 26.305 -64.457 73.05042123766296\n", "63.464 27.042 -63.036 71.5967464973095\n", "63.22 19.146 -62.457 71.69577009838169\n", "64.209 18.997 -62.469 71.49942241724754\n", "62.4 18.419 -63.435 72.93120223196654\n", "61.454 18.615 -63.176 72.89305485435494\n", "62.525 16.894 -63.353 73.04992624910719\n", "61.703 16.195 -63.947 73.9338760379841\n", "62.716 18.955 -64.841 74.13531311729923\n", "63.698 18.869 -65.009 74.0834547993005\n", "62.214 18.414 -65.516 74.97582306984032\n", "62.332 20.405 -65.018 74.22391373405205\n", "61.157 20.983 -64.596 74.04881125987102\n", "60.407 20.514 -64.129 73.84730208342076\n", "63.078 21.398 -65.593 74.50197346379491\n", "63.989 21.292 -65.992 74.69574282380489\n", "61.191 22.284 -64.919 74.22936263366404\n", "60.456 22.936 -64.733 74.1900739317599\n", "62.344 22.59 -65.525 74.50344331639981\n", "63.49 16.38 -62.587 72.17234582580782\n", "63.997 16.999 -61.988 71.37923878131512\n", "63.846 14.965 -62.575 72.33170460455084\n", "64.391 14.796 -61.754 71.45715384760297\n", "62.997 14.439 -62.526 72.58206509186688\n", "64.64 14.551 -63.816 73.4241439718571\n", "64.888 15.346 -64.721 74.09467998446311\n", "65.027 13.279 -63.854 73.63291998148654\n", "64.892 12.724 -63.033 72.9947582638644\n", "65.635 12.643 -65.016 74.75669605460102\n", "65.55 13.265 -65.795 75.39074873616788\n", "64.875 11.351 -65.344 75.50575107235208\n", "64.443 10.624 -64.443 74.90874734635469\n", "67.124 12.416 -64.744 74.268645611725\n", "67.586 13.278 -64.534 73.80368739433011\n", "67.576 12.011 -65.539 75.0430823660649\n", "67.257 11.8 -63.968 73.63809652618677\n", "64.666 11.082 -66.631 76.83512135735845\n", "65.011 11.732 -67.308 77.26778397236458\n", "63.964 9.895 -67.115 77.71681909985764\n", "63.4 9.558 -66.361 77.20546593344282\n", "65.016 8.867 -67.507 78.12935921278249\n", "65.732 9.034 -68.489 78.88511500910676\n", "63.022 10.221 -68.293 78.95746857011058\n", "63.577 10.529 -69.065 79.50158286474552\n", "62.051 11.373 -67.946 78.58647187016349\n", "61.463 11.079 -67.192 78.07634702648427\n", "62.587 12.167 -67.661 78.0232603907322\n", "62.25 8.951 -68.704 79.82024423665965\n", "61.632 9.139 -69.467 80.63458336842821\n", "61.702 8.603 -67.943 79.31600390211297\n", "62.878 8.226 -68.988 80.13057202466484\n", "61.155 11.795 -69.115 79.81474807327277\n", "60.544 12.54 -68.848 79.55676022186927\n", "60.59 11.031 -69.427 80.40982324940155\n", "61.702 12.109 -69.891 80.35851095559201\n", "65.093 7.782 -66.744 77.67442322927155\n", "64.473 7.695 -65.964 77.08631422632683\n", "66.051 6.713 -67.004 78.0322905789648\n", "66.878 7.136 -67.374 78.11917376035156\n", "65.551 5.762 -68.083 79.40905505671252\n", "64.447 5.225 -67.966 79.66595589710826\n", "66.391 6.024 -65.685 76.9271104682868\n", "66.725 6.707 -65.035 76.0582850056455\n", "65.567 5.591 -65.32 76.86546478751039\n", "67.467 4.96 -65.89 77.25264477026013\n", "67.107 4.231 -66.472 78.0824514791896\n", "68.265 5.374 -66.328 77.41181692739165\n", "67.876 4.376 -64.543 76.10686217418242\n", "68.396 5.05 -64.019 75.32152400210713\n", "67.065 4.105 -64.025 75.84639127868907\n", "68.719 3.19 -64.751 76.55439269565137\n", "69.169 3.11 -65.641 77.34496118688017\n", "68.943 2.224 -63.889 76.04748388342642\n", "68.487 2.282 -62.665 74.96447676733294\n", "67.955 3.074 -62.367 74.50003383220708\n", "68.671 1.534 -62.027 74.6145689326153\n", "69.626 1.174 -64.247 76.65039231471683\n", "69.981 1.102 -65.179 77.49005859463523\n", "69.796 0.44 -63.59 76.28787125749413\n", "66.383 5.527 -69.088 80.27413389753887\n", "67.207 6.09 -69.148 80.03326520891171\n", "66.186 4.512 -70.109 81.56415932258481\n", "65.298 4.689 -70.533 82.06764197294814\n", "66.159 3.129 -69.465 81.38516234547916\n", "66.999 2.77 -68.639 80.58622384129932\n", "67.276 4.629 -71.172 82.35217630396903\n", "67.251 5.556 -71.547 82.44677689879695\n", "68.161 4.47 -70.734 81.85064341836292\n", "67.168 3.676 -72.323 83.7344662489706\n", "68.12 2.788 -72.682 84.19800423406721\n", "68.987 2.65 -72.203 83.66935941549929\n", "66.094 3.507 -73.3 84.87714329547148\n", "67.718 2.099 -73.808 85.52706854557802\n", "68.261 1.387 -74.254 86.09118480425275\n", "66.479 2.511 -74.243 85.99892167928618\n", "64.828 4.091 -73.485 85.10055973376438\n", "64.511 4.785 -72.838 84.35231601444029\n", "65.662 2.132 -75.318 87.25631537602305\n", "65.969 1.434 -75.965 88.02601436507278\n", "63.995 3.722 -74.56 86.37040643646411\n", "63.103 4.16 -74.67 86.52075776367195\n", "64.409 2.744 -75.476 87.4390492857739\n", "63.815 2.484 -76.237 88.33812144821735\n", "65.12 2.376 -69.803 82.12281372432388\n", "64.447 2.764 -70.432 82.7115447806411\n", "64.894 1.014 -69.315 82.15772227855395\n", "65.716 0.768 -68.802 81.61761901084839\n", "64.755 0.02 -70.464 83.57982670477368\n", "64.224 -1.068 -70.258 83.86803994967332\n", "63.673 0.985 -68.386 81.54893591580456\n", "63.595 0.094 -67.938 81.46030689851347\n", "63.744 1.702 -67.692 80.65557526296615\n", "62.463 1.206 -69.097 82.38095173642994\n", "62.648 1.256 -70.035 83.18760978655413\n", "65.118 0.436 -71.678 84.49518005779974\n", "65.443 1.377 -71.776 84.22026523943035\n", "65.068 -0.399 -72.865 85.88219062762663\n", "64.328 -1.061 -72.747 86.13203466190728\n", "64.868 0.188 -73.649 86.44854773794641\n", "66.386 -1.125 -73.082 86.10864217951645\n", "67.447 -0.667 -72.669 85.40450635651493\n", "66.288 -2.261 -73.748 87.13589945596476\n", "65.377 -2.648 -73.889 87.55284877718142\n", "67.429 -2.979 -74.287 87.7146603824013\n", "68.263 -2.763 -73.779 87.05057951558966\n", "67.612 -2.53 -75.742 88.87347951441983\n", "66.653 -2.571 -76.521 89.74929681061573\n", "67.126 -4.472 -74.139 88.17123588790167\n", "66.812 -4.641 -73.205 87.42875386850713\n", "66.4 -4.714 -74.783 88.96106380883717\n", "68.321 -5.374 -74.409 88.591217967697\n", "69.284 -4.905 -75.061 88.88683103249885\n", "68.214 -6.551 -74.007 88.69762762892816\n", "68.811 -2.073 -76.111 88.89563270487477\n", "69.533 -2.011 -75.422 88.14348373532782\n", "69.115 -1.657 -77.486 89.99742899105507\n", "68.424 -0.972 -77.715 90.07193706143995\n", "68.984 -2.819 -78.485 91.33971676658517\n", "68.84 -2.587 -79.685 92.39720187862834\n", "70.524 -1.045 -77.539 89.68058453756866\n", "71.183 -1.738 -77.245 89.56804484301307\n", "70.719 -0.778 -78.483 90.45890130329906\n", "70.708 0.178 -76.66 88.43699355473363\n", "70.092 1.395 -77.007 88.45032306894079\n", "69.537 1.456 -77.837 89.28093732146857\n", "71.502 0.108 -75.5 87.2863964716152\n", "71.947 -0.753 -75.253 87.2961853576661\n", "70.257 2.525 -76.187 87.31362829478569\n", "69.807 3.385 -76.428 87.34259673836128\n", "71.672 1.242 -74.687 86.13934567896368\n", "72.236 1.186 -73.863 85.32604367952378\n", "71.051 2.452 -75.031 86.15303122351528\n", "71.173 3.26 -74.455 85.35184361804963\n", "68.999 -4.062 -77.991 91.31464110973661\n", "69.049 -4.164 -76.997 90.42570055576014\n", "68.948 -5.288 -78.797 92.50910687062111\n", "69.305 -4.986 -79.681 93.173916677362\n", "67.533 -5.83 -79.038 93.11254319370725\n", "67.349 -6.696 -79.895 94.24645916425719\n", "69.831 -6.378 -78.172 92.23615276018401\n", "69.813 -7.175 -78.776 93.09630287503364\n", "69.298 -6.824 -76.949 91.34787689924708\n", "68.35 -6.925 -77.032 91.58067646616287\n", "71.272 -5.924 -77.937 91.69711971485255\n", "71.817 -6.657 -77.53 91.50424201642238\n", "71.304 -5.138 -77.319 90.83073767178156\n", "71.708 -5.657 -78.796 92.349390111684\n", "66.51 -5.325 -78.336 92.42692394535263\n", "66.696 -4.597 -77.676 91.52733168840878\n", "65.126 -5.793 -78.493 92.95775489436048\n", "65.201 -6.736 -78.817 93.59368449313232\n", "64.372 -5.004 -79.576 93.78838807123192\n", "64.585 -3.804 -79.737 93.47849841006219\n", "64.397 -5.808 -77.141 91.85050929091248\n", "64.531 -4.927 -76.687 91.08641094038121\n", "63.421 -5.958 -77.297 92.22134840154962\n", "64.945 -6.93 -76.242 91.36837074173972\n", "64.851 -7.8 -76.726 92.16258783259072\n", "65.912 -6.751 -76.064 90.98078363039086\n", "64.23 -7.053 -74.901 90.32696188292839\n", "63.107 -6.612 -74.696 90.17488488487245\n", "64.862 -7.675 -73.932 89.59311003643082\n", "64.425 -7.784 -73.039 88.91266695471461\n", "65.78 -8.04 -74.087 89.72833589229212\n", "63.5 -5.712 -80.315 94.8709381739213\n", "63.342 -6.657 -80.029 94.98336386441575\n", "62.75 -5.254 -81.498 95.92639099330277\n", "63.422 -5.116 -82.226 96.42775208932333\n", "62.133 -6.0 -81.751 96.5370432994506\n", "61.924 -3.961 -81.333 95.48081320872797\n", "61.97 -3.318 -80.287 94.29063479476633\n", "61.17 -3.545 -82.374 96.44640232792511\n", "60.684 -2.172 -82.543 96.25210242898594\n", "61.472 -1.586 -82.731 96.08439091756786\n", "60.056 -1.604 -81.267 95.02114252102001\n", "59.082 -2.134 -80.724 94.90183301180225\n", "59.7 -2.204 -83.719 97.5538751152408\n", "58.885 -1.661 -83.517 97.37190850548221\n", "60.131 -1.861 -84.554 98.1313496136683\n", "59.344 -3.684 -83.861 98.23630578355437\n", "58.575 -3.927 -83.27 97.93992028279378\n", "59.121 -3.91 -84.809 99.23046111451865\n", "60.622 -4.392 -83.415 97.79775955511455\n", "60.429 -5.3 -83.043 97.80513328552853\n", "61.279 -4.472 -84.165 98.386585777737\n", "60.648 -0.516 -80.777 94.10234338208586\n", "61.398 -0.109 -81.299 94.31039231707182\n", "60.262 0.113 -79.521 92.82509283054878\n", "60.241 -0.603 -78.823 92.40611987309065\n", "58.868 0.719 -79.664 93.08357121425885\n", "58.598 1.457 -80.604 93.8007962332943\n", "61.301 1.18 -79.139 91.92921468717113\n", "61.411 1.81 -79.908 92.4399323452803\n", "60.966 1.682 -78.342 91.1073435075351\n", "62.674 0.571 -78.799 91.52340712080162\n", "62.966 -0.009 -79.56 92.35627912600204\n", "63.333 1.313 -78.672 91.05621275344149\n", "62.654 -0.275 -77.531 90.61142627174567\n", "61.982 0.054 -76.558 89.73793940691975\n", "63.38 -1.371 -77.496 90.79646036052286\n", "63.386 -1.941 -76.674 90.22593419854405\n", "63.926 -1.635 -78.291 91.52096858643924\n", "57.959 0.435 -78.732 92.52126400455194\n", "58.212 -0.164 -77.972 91.94548911719377\n", "56.598 0.976 -78.79 92.74873798063238\n", "56.437 1.177 -79.756 93.62018915276768\n", "56.47 2.274 -77.994 91.669139632703\n", "56.82 2.314 -76.814 90.47919982515317\n", "55.59 -0.062 -78.294 92.86992094860423\n", "55.658 -0.908 -78.823 93.59846172881261\n", "55.731 -0.263 -77.325 92.01051871389488\n", "54.274 0.446 -78.448 93.21297122718488\n", "54.303 1.402 -78.483 92.95309996444443\n", "55.816 3.292 -78.561 92.07838733383637\n", "55.578 3.215 -79.529 93.05762672129565\n", "55.424 4.518 -77.852 91.19788995914324\n", "56.282 4.909 -77.518 90.55586117971602\n", "54.529 4.272 -76.612 90.36743526293085\n", "54.274 5.19 -75.829 89.47654227785067\n", "54.713 5.437 -78.855 92.08578555890153\n", "55.285 5.601 -79.659 92.63589558049298\n", "54.502 6.323 -78.442 91.54249082256828\n", "53.854 5.031 -79.166 92.71714940613737\n", "54.028 3.039 -76.429 90.68204450165423\n", "54.239 2.353 -77.125 91.4533777725022\n", "53.196 2.611 -75.294 90.01327672071493\n", "52.726 3.448 -75.014 89.66326434499247\n", "53.997 2.124 -74.078 88.81266634889418\n", "53.381 1.882 -73.038 88.12801018972344\n", "52.205 1.527 -75.757 91.05117566511703\n", "52.725 0.759 -76.129 91.4601793459864\n", "51.677 1.22 -74.965 90.59291147214554\n", "51.225 2.02 -76.835 92.18662411109325\n", "50.725 2.813 -76.486 91.80441321091268\n", "51.74 2.283 -77.651 92.69132556501714\n", "50.222 0.917 -77.207 93.16345774497637\n", "50.72 0.123 -77.555 93.55622413821541\n", "49.704 0.655 -76.393 92.68002647280588\n", "49.25 1.415 -78.285 94.30340266925684\n", "48.733 2.195 -77.934 93.93736392405313\n", "49.765 1.694 -79.096 94.78785504483156\n", "48.282 0.361 -78.69 95.29526914805372\n", "47.656 0.7 -79.392 96.0350037902847\n", "47.734 0.059 -77.91 94.87465588870401\n", "48.756 -0.438 -79.061 95.70916839049434\n", "55.32 1.963 -74.165 88.55899409433239\n", "55.779 2.142 -75.035 89.17289503543103\n", "56.119 1.527 -73.004 87.41201782935799\n", "55.602 0.739 -72.67 87.49971255952786\n", "56.192 2.614 -71.927 86.07874726086574\n", "55.967 3.799 -72.183 86.0266297956627\n", "57.537 1.059 -73.367 87.51002816820481\n", "57.976 0.701 -72.543 86.75871480721692\n", "58.327 2.149 -73.752 87.32566658777932\n", "59.238 1.868 -73.84 87.26866590592525\n", "57.579 -0.021 -74.446 88.82741775488016\n", "58.521 -0.291 -74.646 88.86245306652297\n", "57.165 0.305 -75.296 89.60535176539402\n", "57.08 -0.838 -74.155 88.95744475871595\n", "56.517 2.218 -70.688 84.98114543826766\n", "56.722 1.251 -70.538 85.09315799757346\n", "56.588 3.133 -69.535 83.63175891370454\n", "55.679 3.542 -69.455 83.69718447474801\n", "57.573 4.284 -69.755 83.21701913070426\n", "57.253 5.415 -69.399 82.65483776525122\n", "56.937 2.328 -68.273 82.63785370518767\n", "56.284 1.577 -68.181 82.9819890036386\n", "57.86 1.957 -68.374 82.59332134016647\n", "56.887 3.184 -66.997 81.22700440740135\n", "57.553 3.926 -67.069 80.87473467653541\n", "55.97 3.568 -66.892 81.28124591195683\n", "57.218 2.328 -65.771 80.2982471415161\n", "56.55 1.589 -65.685 80.65870231413346\n", "58.135 1.94 -65.867 80.25527170846786\n", "57.185 3.123 -64.53 78.93204878248125\n", "56.949 4.091 -64.618 78.77440755092988\n", "57.438 2.676 -63.312 77.90974142557526\n", "57.774 1.436 -63.087 78.03249557716323\n", "57.847 0.792 -63.848 78.91596700288224\n", "57.959 1.13 -62.153 77.25455777493002\n", "57.357 3.474 -62.286 76.75042506722683\n", "57.102 4.432 -62.417 76.6371970651328\n", "57.55 3.129 -61.368 75.98494291634364\n", "58.734 4.003 -70.351 83.54002448527292\n", "58.931 3.051 -70.587 83.99124303163991\n", "59.731 5.023 -70.675 83.29488235179878\n", "59.958 5.473 -69.811 82.31101906184858\n", "59.151 6.067 -71.636 84.0442877832872\n", "59.107 7.248 -71.298 83.43158262912192\n", "60.988 4.365 -71.255 83.72276905955749\n", "61.412 3.795 -70.552 83.14071304721894\n", "60.728 3.795 -72.035 84.6726672486464\n", "62.003 5.387 -71.723 83.64329009550018\n", "61.999 5.828 -73.059 84.77658363604893\n", "61.327 5.461 -73.702 85.6247497456197\n", "62.919 5.942 -70.814 82.44275647987516\n", "62.905 5.655 -69.856 81.62731788439454\n", "62.936 6.782 -73.494 84.73993274129971\n", "62.938 7.083 -74.448 85.565343393222\n", "63.856 6.9 -71.245 82.40016921099131\n", "64.511 7.286 -70.596 81.55778714506665\n", "63.87 7.313 -72.588 83.56080544130722\n", "64.544 7.984 -72.899 83.55913607739132\n", "58.614 5.635 -72.782 85.36094222769567\n", "58.565 4.65 -72.948 85.79684269249073\n", "58.094 6.548 -73.804 86.20563898608954\n", "58.817 7.227 -73.931 85.97082564451733\n", "56.851 7.309 -73.357 85.92635755110302\n", "56.719 8.488 -73.674 85.97431376870652\n", "57.838 5.78 -75.101 87.67745487866307\n", "57.274 4.978 -74.905 87.85255890410933\n", "57.36 6.374 -75.748 88.25149134717215\n", "59.103 5.316 -75.74 88.08232689932753\n", "59.452 4.034 -75.986 88.57581358926375\n", "58.872 3.238 -75.813 88.77618379948532\n", "60.196 6.132 -76.26 88.10329034150769\n", "60.723 3.987 -76.509 88.78900446564315\n", "61.222 3.144 -76.71 89.10594151345913\n", "61.215 5.252 -76.719 88.53783691168425\n", "60.42 7.519 -76.417 87.8580462507561\n", "59.721 8.17 -76.12 87.58427516398135\n", "62.414 5.717 -77.249 88.6677858695028\n", "63.125 5.071 -77.525 88.95762900392523\n", "61.618 7.995 -76.987 88.02393317160963\n", "61.756 8.979 -77.103 87.88065527179458\n", "62.62 7.097 -77.394 88.41885211876482\n", "63.474 7.44 -77.784 88.5417446914166\n", "55.978 6.701 -72.545 85.56830106412069\n", "56.077 5.72 -72.381 85.6450041099888\n", "54.879 7.422 -71.885 85.09637529883398\n", "54.341 7.825 -72.625 85.84114238522224\n", "55.399 8.548 -70.99 83.84148350309648\n", "54.857 9.651 -71.023 83.77809903548778\n", "54.023 6.446 -71.071 84.85646667756087\n", "54.631 5.841 -70.556 84.35985057478467\n", "53.457 6.971 -70.435 84.31657335304844\n", "53.105 5.587 -71.951 86.17216695662236\n", "52.475 6.176 -72.457 86.67857662075444\n", "53.656 5.056 -72.595 86.73122375477011\n", "52.309 4.637 -71.051 85.86867679194783\n", "52.937 3.972 -70.646 85.4888796978882\n", "51.872 5.168 -70.325 85.20978872171905\n", "51.229 3.885 -71.831 87.13811546045737\n", "50.64 4.534 -72.312 87.58747799200522\n", "51.653 3.266 -72.492 87.77051682655173\n", "50.395 3.087 -70.903 86.81839847635983\n", "49.683 2.589 -71.399 87.6531852815401\n", "49.947 3.674 -70.229 86.2021669391205\n", "50.95 2.419 -70.407 86.38596651655868\n", "56.469 8.3 -70.231 82.88734789459727\n", "56.863 7.381 -70.235 83.00877882489297\n", "57.082 9.328 -69.395 81.69036475619386\n", "56.345 9.744 -68.862 81.31062892389899\n", "57.702 10.444 -70.254 82.064639187655\n", "57.454 11.618 -70.002 81.64574252831558\n", "58.09 8.668 -68.433 80.67424648548011\n", "57.768 7.749 -68.207 80.78503397907312\n", "58.979 8.608 -68.887 80.87343923068933\n", "58.267 9.443 -67.138 79.23230089426912\n", "57.472 10.282 -66.758 78.90515263910208\n", "59.288 9.136 -66.375 78.31964850533996\n", "59.406 9.59 -65.492 77.35369889669143\n", "59.948 8.448 -66.676 78.60023466249957\n", "58.401 10.107 -71.344 82.97358062058066\n", "58.58 9.139 -71.52 83.31235907114862\n", "58.918 11.109 -72.297 83.52113885119144\n", "59.496 11.716 -71.752 82.7348139600253\n", "57.776 11.943 -72.902 84.22033114397021\n", "57.813 13.173 -72.842 83.91974917145545\n", "59.789 10.45 -73.387 84.4748616631007\n", "59.205 9.79 -73.859 85.20683679728991\n", "60.321 11.483 -74.387 85.08310947538294\n", "60.884 11.046 -75.089 85.71073786871747\n", "60.883 12.171 -73.927 84.3791156270318\n", "59.57 11.957 -74.847 85.6053521399217\n", "61.005 9.749 -72.768 83.75639095018362\n", "61.57 9.322 -73.474 84.39503388825672\n", "60.72 9.035 -72.128 83.38095157768349\n", "61.577 10.399 -72.268 83.00845046740723\n", "56.7 11.306 -73.388 85.09706827499993\n", "56.706 10.306 -73.375 85.29153881833766\n", "55.505 11.981 -73.942 85.82047800496102\n", "55.868 12.531 -74.694 86.31962114142995\n", "54.821 12.914 -72.939 84.90499677286371\n", "54.311 13.967 -73.319 85.22755532103453\n", "54.481 10.946 -74.437 86.78761121842217\n", "54.391 10.234 -73.74 86.31268747988327\n", "53.602 11.407 -74.559 87.07366937829138\n", "54.862 10.275 -75.766 88.05556378787203\n", "54.947 10.976 -76.474 88.55182033137433\n", "55.738 9.805 -75.655 87.80264767647954\n", "53.793 9.255 -76.194 88.9835520812695\n", "54.125 8.735 -76.981 89.73221556386535\n", "53.606 8.63 -75.436 88.47379669144983\n", "52.513 9.902 -76.58 89.59231212553898\n", "52.56 10.872 -76.818 89.6022920967985\n", "51.314 9.337 -76.644 90.14789895499507\n", "51.162 8.055 -76.46 90.30933824361685\n", "51.957 7.48 -76.267 90.01189566385099\n", "50.251 7.647 -76.512 90.74709505543414\n", "50.235 10.039 -76.88 90.57027210404084\n", "50.302 11.027 -77.017 90.47782280205465\n", "49.344 9.587 -76.923 91.00151930050399\n", "54.812 12.558 -71.656 83.77484245881935\n", "55.204 11.674 -71.402 83.59347927320647\n", "54.252 13.407 -70.601 82.80458578484648\n", "53.306 13.605 -70.857 83.30781765836865\n", "54.984 14.762 -70.507 82.25232243529662\n", "54.338 15.805 -70.328 82.11695044264613\n", "54.282 12.624 -69.283 81.71727169943941\n", "53.7 11.816 -69.381 82.15524887674555\n", "55.224 12.338 -69.105 81.31423237047744\n", "53.799 13.4 -68.079 80.60813490585177\n", "54.731 14.092 -67.283 79.43959192367494\n", "55.705 14.049 -67.507 79.3496810705626\n", "52.432 13.427 -67.747 80.75541950234671\n", "51.769 12.932 -68.309 81.59504274770617\n", "54.302 14.842 -66.177 78.41829196048586\n", "54.965 15.35 -65.627 77.60251437292479\n", "52.002 14.154 -66.62 79.73587883130153\n", "51.034 14.158 -66.369 79.85323724183009\n", "52.933 14.876 -65.845 78.56893773623263\n", "52.53 15.609 -64.772 77.59809795349368\n", "52.435 16.526 -65.029 77.7210503338703\n", "56.306 14.764 -70.711 82.04855239429882\n", "56.752 13.884 -70.873 82.22507144417693\n", "57.149 15.966 -70.714 81.6159055331741\n", "56.699 16.598 -70.083 81.0522299323097\n", "57.199 16.699 -72.073 82.78176288289589\n", "57.423 17.918 -72.112 82.59108157664481\n", "58.547 15.584 -70.207 80.81049538890353\n", "58.846 14.752 -70.674 81.31220511706714\n", "59.182 16.329 -70.412 80.72170383484234\n", "58.58 15.329 -68.718 79.43039248297845\n", "58.845 16.268 -67.747 78.28534841846205\n", "59.039 17.236 -67.904 78.2359164067246\n", "58.377 14.141 -68.07 79.08030802292058\n", "58.19 13.261 -68.506 79.7075937285777\n", "58.798 15.657 -66.55 77.26272556673106\n", "58.978 16.104 -65.674 76.30991603323909\n", "58.476 14.367 -66.697 77.71658131312776\n", "56.912 16.002 -73.173 84.00786283437998\n", "56.789 15.014 -73.078 84.10530325728574\n", "56.764 16.583 -74.513 85.23773945266264\n", "57.59 17.129 -74.656 85.0757319921492\n", "55.562 17.547 -74.616 85.54417818881656\n", "54.655 17.526 -73.769 85.01163417438815\n", "56.686 15.452 -75.554 86.41396265071982\n", "56.056 14.749 -75.223 86.38319032659074\n", "56.345 15.827 -76.416 87.27054206890203\n", "58.055 14.809 -75.804 86.39017641491421\n", "58.334 14.461 -74.909 85.52215976575896\n", "57.861 14.041 -76.415 87.14710123693158\n", "59.289 15.937 -76.506 86.58257416478213\n", "58.857 15.856 -78.268 88.38935653120232\n", "59.46 16.439 -78.812 88.68727826469814\n", "57.917 16.16 -78.421 88.72446567322905\n", "58.938 14.921 -78.614 88.84069852269285\n", "55.55 18.466 -75.604 86.37358001727148\n", "54.412 19.346 -75.841 86.83204916388878\n", "54.172 19.814 -74.991 86.04926459883315\n", "53.169 18.544 -76.254 87.68748275552218\n", "53.259 17.417 -76.745 88.25892087488947\n", "54.87 20.339 -76.916 87.62087841376619\n", "54.107 20.61 -77.503 88.37768442881946\n", "55.279 21.153 -76.503 87.03663643546894\n", "55.91 19.548 -77.705 88.1577934728405\n", "55.476 18.99 -78.412 89.0116831264301\n", "56.582 20.158 -78.126 88.31831027029446\n", "56.559 18.673 -76.639 87.05573535385247\n", "56.832 17.789 -77.018 87.4490216869234\n", "57.356 19.126 -76.24 86.409943345659\n", "51.989 19.132 -76.031 87.78357573601112\n", "51.962 19.984 -75.508 87.21256841189806\n", "50.732 18.562 -76.533 88.72816609172084\n", "50.685 17.628 -76.179 88.52282562706637\n", "50.791 18.604 -78.049 90.12557371245967\n", "51.006 19.665 -78.634 90.49514052146667\n", "49.485 19.313 -76.036 88.60547265829577\n", "49.533 20.242 -76.404 88.84033286745384\n", "48.199 18.63 -76.522 89.5833737252622\n", "47.389 19.119 -76.198 89.5235748895228\n", "48.144 17.689 -76.187 89.40196769087356\n", "48.163 18.603 -77.521 90.52636253600384\n", "49.453 19.36 -74.504 87.18541481234116\n", "48.643 19.848 -74.177 87.12123312373397\n", "50.26 19.827 -74.143 86.51914111339755\n", "49.433 18.438 -74.118 86.93616336139984\n", "50.642 17.444 -78.665 90.88703668840789\n", "50.413 16.633 -78.127 90.5610539139204\n", "50.801 17.318 -80.094 92.1928265539136\n", "51.511 17.955 -80.393 92.17528238090729\n", "49.508 17.702 -80.809 93.237060839561\n", "48.422 17.27 -80.422 93.29023765110688\n", "51.23 15.891 -80.377 92.50790514869526\n", "51.841 15.578 -79.65 91.6778862976236\n", "50.422 15.302 -80.411 92.87814469507883\n", "51.957 15.829 -81.71 93.54814938308506\n", "51.371 16.196 -82.432 94.35822791892608\n", "52.801 16.363 -81.661 93.17912559151861\n", "52.292 14.398 -82.021 93.94635508629379\n", "52.349 13.529 -81.162 93.25583368883686\n", "52.445 14.117 -83.278 95.12999037632665\n", "52.614 13.173 -83.562 95.49671249838917\n", "52.394 14.844 -83.963 95.68508413540742\n", "49.62 18.511 -81.865 94.10115197488285\n", "50.496 18.96 -82.04 93.93822353547037\n", "48.501 18.762 -82.776 95.29780240907971\n", "47.676 18.928 -82.236 95.05382707182284\n", "48.34 17.51 -83.632 96.28950408533632\n", "49.289 17.113 -84.303 96.6567407995945\n", "48.748 20.023 -83.619 95.8869361852802\n", "49.576 19.889 -84.163 96.14380380970995\n", "47.967 20.16 -84.229 96.70630228170239\n", "48.924 21.279 -82.748 94.905622415113\n", "48.155 21.349 -82.113 94.56071726673821\n", "49.777 21.203 -82.232 94.14704648049242\n", "48.974 22.544 -83.612 95.61496335302336\n", "49.785 22.521 -84.196 95.90714130345039\n", "48.154 22.596 -84.182 96.41886216399776\n", "49.037 23.766 -82.783 94.74320520755036\n", "48.859 23.656 -81.805 93.88643133594971\n", "49.305 24.991 -83.205 95.00000714736815\n", "49.613 25.243 -84.447 96.06695335025464\n", "49.652 24.498 -85.113 96.71417481424322\n", "49.81 26.181 -84.733 96.24789025739732\n", "49.254 26.002 -82.383 94.20759634976363\n", "49.011 25.855 -81.424 93.38770075871875\n", "49.458 26.924 -82.711 94.43033727568698\n", "47.183 16.851 -83.551 96.6804278124585\n", "46.465 17.229 -82.967 96.34007663480448\n", "46.904 15.601 -84.272 97.60577055686821\n", "47.488 14.889 -83.883 97.14308055131873\n", "47.258 15.762 -85.755 98.8479120770894\n", "46.695 16.621 -86.431 99.56075802242567\n", "45.418 15.229 -84.078 97.99288215987934\n", "45.039 15.797 -83.348 97.37809550920576\n", "44.929 15.411 -84.931 98.93128046275353\n", "45.205 13.757 -83.704 97.9346826461392\n", "45.544 13.172 -84.441 98.58419616753996\n", "45.7 13.551 -82.86 97.01179885972633\n", "43.704 13.507 -83.496 98.32826986172388\n", "43.333 14.195 -82.872 97.79278235636819\n", "43.23 13.563 -84.375 99.3009530417508\n", "43.43 12.178 -82.918 98.11477463155077\n", "44.207 11.56 -82.801 97.8247307637491\n", "42.241 11.736 -82.542 98.29991890128902\n", "41.152 12.434 -82.714 98.76443907095306\n", "41.199 13.336 -83.143 98.99122468683777\n", "40.271 12.067 -82.417 98.90909657862618\n", "42.123 10.572 -81.969 98.03350176852808\n", "42.933 10.008 -81.811 97.68417419930417\n", "41.222 10.243 -81.687 98.19406016149856\n", "48.167 14.926 -86.252 99.12594899419626\n", "48.746 14.41 -85.621 98.42153131302112\n", "48.345 14.739 -87.692 100.44447839976073\n", "48.399 15.65 -88.101 100.69052786136339\n", "47.137 13.958 -88.236 101.4521334620421\n", "46.757 12.94 -87.642 101.17455438992553\n", "49.653 14.006 -87.993 100.42462891641671\n", "50.44 14.513 -87.641 99.78333986693369\n", "49.648 13.085 -87.603 100.19708775708003\n", "49.806 13.884 -89.391 101.71370817151443\n", "50.738 13.856 -89.609 101.64943331863684\n", "46.484 14.408 -89.32 102.61529496619886\n", "45.311 13.745 -89.867 103.6086481815104\n", "44.749 13.36 -89.135 103.17554148634258\n", "45.721 12.555 -90.747 104.46753638331862\n", "45.799 12.703 -91.958 105.54870637293476\n", "44.575 14.852 -90.637 104.42305686485145\n", "44.064 14.472 -91.408 105.36542499795651\n", "43.951 15.352 -90.036 104.0148736671828\n", "45.701 15.762 -91.128 104.38777418835981\n", "46.062 15.443 -92.005 105.13045942542055\n", "45.383 16.706 -91.221 104.46896925403256\n", "46.757 15.649 -90.031 103.02837724627133\n", "47.677 15.611 -90.42 103.104073134867\n", "46.696 16.416 -89.392 102.35567478650121\n", "45.955 11.364 -90.179 104.05140451238513\n", "46.223 11.327 -89.216 103.07420432387534\n", "45.827 10.102 -90.94 105.01559756531407\n", "44.911 10.203 -91.327 105.65971880522869\n", "45.89 8.844 -90.061 104.40939255641707\n", "46.945 8.275 -89.807 103.94125505303465\n", "46.883 9.961 -92.053 105.73697185942105\n", "46.955 10.798 -92.595 106.07678249739666\n", "47.78 9.729 -91.677 105.14758185997432\n", "46.484 8.912 -92.917 106.85649781833578\n", "46.394 8.102 -92.415 106.57034500272579\n", "44.728 8.354 -89.639 104.50158127990217\n", "44.113 8.931 -89.101 104.10755218522813\n", "44.339 6.975 -89.955 105.19903643094835\n", "44.751 6.771 -90.843 105.91746905019964\n", "42.816 6.937 -90.027 105.80131970348951\n", "42.101 6.937 -89.028 105.14701909707189\n", "44.923 5.907 -89.013 104.36273864746939\n", "44.527 5.01 -89.211 104.876087307832\n", "45.917 5.861 -89.108 104.12829794537122\n", "44.659 6.174 -87.655 103.15287094889797\n", "44.599 7.12 -87.521 102.84990258138312\n", "42.3 6.986 -91.258 107.0979087050723\n", "42.874 7.318 -92.006 107.51500063246988\n", "40.93 6.573 -91.554 107.9428276542726\n", "40.311 7.126 -90.997 107.55301539705894\n", "40.828 5.083 -91.214 107.98515965631573\n", "41.153 4.253 -92.054 108.81145078069679\n", "40.619 6.795 -93.051 109.37304798715266\n", "41.406 6.48 -93.581 109.63789694261742\n", "39.817 6.245 -93.285 109.98862565738331\n", "40.328 8.245 -93.464 109.57661176546753\n", "39.506 8.566 -92.993 109.39064352128109\n", "41.104 8.824 -93.214 108.96159578952577\n", "40.107 8.31 -94.986 111.03541589961286\n", "40.958 8.062 -95.449 111.20120662115137\n", "39.388 7.662 -95.238 111.64643708152983\n", "39.688 9.716 -95.438 111.35388315186857\n", "38.806 9.95 -95.028 111.26403838168018\n", "40.378 10.38 -95.148 110.72764724764993\n", "39.551 9.803 -96.917 112.74501398288086\n", "39.278 10.723 -97.198 112.95256991321622\n", "38.86 9.162 -97.251 113.40974763220312\n", "40.416 9.587 -97.37 112.88922248824288\n", "40.349 4.74 -90.024 107.16186685570571\n", "40.487 5.349 -89.243 106.27226973204252\n", "39.624 3.487 -89.841 107.55416746458502\n", "39.836 2.898 -90.621 108.31257870626106\n", "38.13 3.801 -89.857 108.06849122200235\n", "37.568 4.327 -88.905 107.32174405496772\n", "40.119 2.681 -88.634 106.47899474074686\n", "40.485 3.307 -87.946 105.5748889319804\n", "39.355 2.167 -88.244 106.54744016164818\n", "41.206 1.708 -89.033 106.67358558706087\n", "41.077 0.668 -89.932 107.79118218110422\n", "40.24 0.409 -90.414 108.59506262257047\n", "42.506 1.708 -88.607 105.8220534576796\n", "42.909 2.344 -87.949 104.9263504416312\n", "42.272 0.065 -90.046 107.6238018005311\n", "42.462 -0.718 -90.638 108.29805756799149\n", "43.173 0.662 -89.253 106.43827494374379\n", "37.567 3.565 -91.044 109.40076663808165\n", "38.18 3.631 -91.831 109.85262219446561\n", "36.18 3.224 -91.354 110.3017324478632\n", "35.943 3.84 -92.105 110.9242903470651\n", "35.137 3.551 -90.274 109.69313683635818\n", "34.849 2.76 -89.381 109.20920016646949\n", "36.152 1.735 -91.742 111.00775209867102\n", "36.672 1.214 -91.066 110.3311085460488\n", "35.203 1.419 -91.749 111.47035933377087\n", "36.769 1.507 -93.138 112.06001822684128\n", "36.129 1.839 -93.831 112.84616976220327\n", "37.625 2.021 -93.2 111.66316148578277\n", "37.07 0.04 -93.428 112.56470992722363\n", "37.392 -0.742 -92.554 111.86748357319922\n", "37.039 -0.379 -94.674 113.79053792385376\n", "37.278 -1.326 -94.889 114.13583438166998\n", "36.777 0.249 -95.406 114.38430300089256\n", "34.468 4.686 -90.484 109.90252985714204\n", "34.966 5.491 -90.806 109.809343108863\n", "33.032 4.784 -90.257 110.28726231981642\n", "32.871 4.698 -89.274 109.51350879229466\n", "32.336 3.647 -91.023 111.50638885283658\n", "32.284 3.665 -92.251 112.60077802129078\n", "32.542 6.152 -90.786 110.67651565259904\n", "33.128 6.423 -91.55 111.04525291069402\n", "31.601 6.047 -91.108 111.38837814152785\n", "32.568 7.279 -89.735 109.51743679889518\n", "33.103 6.958 -88.954 108.66163046816479\n", "33.216 8.545 -90.294 109.49187758916183\n", "33.23 9.273 -89.608 108.74804405597372\n", "32.714 8.883 -91.09 110.3508346411571\n", "34.159 8.37 -90.576 109.37320602414468\n", "31.142 7.622 -89.298 109.69724259524484\n", "31.142 8.353 -88.615 108.96301454622113\n", "30.689 6.826 -88.896 109.70496699785292\n", "30.593 7.928 -90.076 110.56533509197175\n", "31.79 2.683 -90.291 111.3232063632736\n", "32.21 2.464 -89.41 110.42587155644277\n", "30.613 1.927 -90.7 112.37111949695971\n", "30.355 2.174 -91.634 113.23596785474128\n", "29.503 2.323 -89.725 111.93270564942134\n", "29.599 2.092 -88.521 110.90973604242325\n", "30.918 0.418 -90.736 112.63550962729293\n", "31.62 0.214 -90.054 111.79149198843353\n", "30.083 -0.085 -90.515 112.93958028078552\n", "31.422 -0.035 -92.121 113.72981552345892\n", "31.986 0.704 -92.49 113.62670850200668\n", "32.255 -1.31 -92.006 113.60348903092721\n", "32.583 -1.606 -92.903 114.32328883040411\n", "31.716 -2.056 -91.614 113.69130361201775\n", "33.052 -1.166 -91.42 112.72183982263597\n", "30.251 -0.315 -93.071 115.128436912867\n", "30.58 -0.609 -93.969 115.83872735402439\n", "29.692 0.504 -93.201 115.28231294522155\n", "29.66 -1.036 -92.709 115.25660833982579\n", "28.502 3.017 -90.263 112.69154911970995\n", "28.57 3.234 -91.237 113.44993356542787\n", "27.313 3.489 -89.558 112.53361519563832\n", "27.655 4.093 -88.838 111.62415563398451\n", "26.521 2.329 -88.945 112.65094739947817\n", "26.404 1.282 -89.589 113.49999324229054\n", "26.397 4.205 -90.557 113.6626533475266\n", "25.536 4.471 -90.124 113.64761223184584\n", "26.845 5.015 -90.935 113.60445427006812\n", "26.087 3.342 -91.637 114.9189462577864\n", "26.017 2.443 -91.317 114.87967029026501\n", "25.88 2.514 -87.779 111.9304476270867\n", "24.931 1.552 -87.249 112.17718761405992\n", "25.234 0.61 -87.396 112.38186873779951\n", "23.599 1.712 -87.991 113.41900188680907\n", "22.741 2.501 -87.61 113.34940012633503\n", "24.853 1.862 -85.753 110.89300723219655\n", "23.957 1.618 -85.383 111.0952013590146\n", "25.566 1.375 -85.249 110.2374047363235\n", "25.076 3.374 -85.693 110.3771787372734\n", "24.205 3.862 -85.748 110.75067071580199\n", "25.548 3.628 -84.849 109.37811026891988\n", "25.947 3.682 -86.914 110.9018686226702\n", "25.603 4.479 -87.41 111.31320170132561\n", "26.898 3.84 -86.648 110.1791999653292\n", "23.436 0.965 -89.076 114.58343704916517\n", "24.249 0.593 -89.523 114.6477198290485\n", "22.135 0.661 -89.646 115.77980097149934\n", "21.441 0.799 -88.94 115.51192382174231\n", "22.153 -0.808 -90.078 116.49158943031038\n", "23.07 -1.245 -90.772 116.72683317044114\n", "21.806 1.629 -90.791 116.66977995607945\n", "21.804 2.576 -90.47 116.18766883365893\n", "20.905 1.433 -91.178 117.49025636621957\n", "22.479 1.555 -91.527 116.96809213627449\n", "21.129 -1.55 -89.655 116.84500100988488\n", "20.53 -1.148 -88.963 116.47809516814738\n", "20.803 -2.91 -90.117 117.7464309480334\n", "19.866 -2.989 -89.777 117.96504571694108\n", "21.55 -4.068 -89.431 117.1242372781996\n", "22.33 -4.789 -90.043 117.44207039642991\n", "20.82 -3.02 -91.661 119.03808562808794\n", "21.742 -3.289 -91.939 118.88303856732463\n", "20.552 -1.789 -92.297 119.37791663033829\n", "20.491 -1.925 -93.243 120.22718112806271\n", "19.725 -3.959 -92.153 120.24295111980577\n", "19.736 -4.03 -93.15 121.07638366337177\n", "18.821 -3.631 -91.878 120.38719076795505\n", "19.846 -4.878 -91.778 120.12683307654456\n", "21.232 -4.323 -88.154 116.31273857149095\n", "21.023 -3.553 -87.552 115.71356890615724\n", "21.176 -5.692 -87.594 116.2814826745858\n", "21.087 -6.293 -88.389 117.14845911918772\n", "19.915 -5.873 -86.737 116.29101482917757\n", "19.96 -6.294 -85.591 115.47646400024551\n", "22.491 -6.136 -86.907 115.19375710948923\n", "22.946 -5.331 -86.527 114.4167957382132\n", "22.272 -6.774 -86.169 114.90073922303546\n", "23.454 -6.83 -87.889 115.72622839270274\n", "22.947 -7.519 -88.407 116.60920115496889\n", "23.825 -6.146 -88.517 115.85198807530234\n", "24.619 -7.517 -87.166 114.78129987502318\n", "25.15 -6.834 -86.664 113.90061301415369\n", "24.261 -8.197 -86.526 114.65000698211927\n", "25.518 -8.208 -88.199 115.4151900487973\n", "24.993 -8.905 -88.687 116.2876153595042\n", "25.861 -7.531 -88.851 115.57660381755468\n", "26.684 -8.869 -87.562 114.55669088272408\n", "27.261 -9.315 -88.246 114.99837555809212\n", "26.388 -9.565 -86.908 114.38921413315155\n", "27.248 -8.205 -87.07 113.6730412806836\n", "18.779 -5.564 -87.349 117.28273061708616\n", "18.775 -4.782 -87.972 117.56012271174268\n", "17.531 -6.305 -87.162 118.00896132497735\n", "17.586 -6.862 -86.334 117.4897729719485\n", "17.385 -7.16 -88.433 119.35089409384413\n", "17.586 -6.639 -89.528 119.96550433353748\n", "16.345 -5.341 -86.967 118.20899866761413\n", "16.678 -4.4 -87.034 117.8159013928086\n", "15.67 -5.508 -87.686 119.19052383893612\n", "15.668 -5.529 -85.601 117.55595768398979\n", "15.314 -6.463 -85.548 117.98299263029396\n", "16.353 -5.39 -84.885 116.57851392516547\n", "14.505 -4.549 -85.365 117.73511811689832\n", "13.772 -4.773 -84.379 117.44347295188439\n", "14.348 -3.612 -86.18 118.20134317764753\n", "17.085 -8.458 -88.287 119.7876998902642\n", "16.79 -8.737 -87.373 119.3088300629924\n", "17.134 -9.535 -89.308 120.90706572405105\n", "16.651 -10.249 -88.801 120.9860095796204\n", "18.527 -10.079 -89.655 120.63648702610665\n", "19.109 -9.72 -90.667 121.03667590032369\n", "16.392 -9.178 -90.614 122.21989039841264\n", "16.79 -8.337 -90.98 122.04745663060743\n", "16.531 -9.924 -91.266 122.89824638293257\n", "14.887 -8.957 -90.474 122.83401516273902\n", "14.454 -9.795 -90.142 123.0617263733936\n", "14.715 -8.214 -89.827 122.18983404931852\n", "14.319 -8.588 -91.851 124.11403671221075\n", "14.661 -7.687 -92.119 123.87919517820578\n", "14.612 -9.269 -92.522 124.69702592283426\n", "12.79 -8.552 -91.807 124.88694656368214\n", "12.438 -9.463 -91.591 125.18112775893975\n", "12.488 -7.903 -91.108 124.3092096266403\n", "12.227 -8.129 -93.113 126.09677687395502\n", "11.228 -8.106 -93.082 126.6069880575318\n", "12.498 -8.759 -93.841 126.71190230992508\n", "12.548 -7.215 -93.362 125.85842739363939\n", "18.993 -11.062 -88.882 120.10274516429673\n", "19.187 -10.883 -87.917 119.17858227886417\n", "19.224 -12.409 -89.436 120.8761606521319\n", "18.392 -12.584 -89.963 121.77446972990684\n", "19.335 -13.451 -88.308 120.2858118191834\n", "20.331 -14.143 -88.134 119.89188763632008\n", "20.393 -12.493 -90.454 121.13314851435176\n", "20.586 -11.579 -90.81 121.01734154244176\n", "21.206 -12.85 -89.994 120.48673982227255\n", "20.026 -13.427 -91.63 122.57398494786729\n", "19.516 -14.201 -91.254 122.79210447744593\n", "19.16 -12.703 -92.67 123.58964802118338\n", "18.926 -13.312 -93.428 124.51767913433015\n", "19.641 -11.912 -93.048 123.39544631792535\n", "18.307 -12.378 -92.262 123.57886608963524\n", "21.285 -13.932 -92.327 122.69670988661431\n", "21.055 -14.537 -93.089 123.6312892515483\n", "21.865 -14.444 -91.693 122.08710795575428\n", "21.823 -13.171 -92.69 122.47132526840721\n", "18.267 -13.546 -87.519 120.24442500590204\n", "17.757 -12.716 -87.295 120.04521311989079\n", "17.816 -14.818 -86.97 120.50105828995859\n", "18.583 -15.43 -86.78 120.18052988733241\n", "16.896 -15.391 -88.058 122.02815587396213\n", "15.744 -14.976 -88.143 122.54725344127463\n", "17.086 -14.56 -85.63 119.75361264279253\n", "17.253 -13.613 -85.357 119.11697533936966\n", "16.106 -14.698 -85.773 120.43208729404301\n", "17.531 -15.472 -84.479 118.96860616566035\n", "17.349 -16.423 -84.727 119.60866091550393\n", "18.511 -15.349 -84.325 118.29131850647367\n", "16.781 -15.144 -83.187 118.2612937566641\n", "16.253 -14.063 -82.992 118.00299559333229\n", "16.703 -16.056 -82.245 117.93205422191203\n", "16.219 -15.855 -81.393 117.47838048764547\n", "17.128 -16.951 -82.38 118.14749628324756\n", "17.441 -16.197 -88.974 122.75114587245204\n", "18.427 -16.112 -89.118 122.33151589022347\n", "16.734 -17.2 -89.794 124.11770934479897\n", "16.411 -17.864 -89.12 124.00836465335715\n", "17.704 -17.837 -90.79 124.6381236460177\n", "18.295 -17.13 -91.595 124.71340948350341\n", "15.509 -16.637 -90.56 125.13667712145788\n", "15.569 -15.639 -90.595 124.77589420236586\n", "15.502 -17.003 -91.49 125.99531420652119\n", "14.203 -17.041 -89.848 125.41425831618987\n", "14.104 -18.035 -89.892 125.86472626593996\n", "14.253 -16.753 -88.892 124.54933853296853\n", "12.969 -16.4 -90.487 126.32777047427062\n", "13.181 -15.464 -90.768 126.10150443194561\n", "12.686 -16.932 -91.285 127.28109319926506\n", "11.84 -16.356 -89.531 126.18707847477887\n", "12.005 -16.734 -88.62 125.54079881855141\n", "10.638 -15.867 -89.765 126.84751640848155\n", "10.311 -15.411 -90.941 127.76356949459418\n", "10.977 -15.428 -91.687 127.9781772373712\n", "9.394 -15.044 -91.098 128.26161859652325\n", "9.739 -15.831 -88.82 126.61675278177053\n", "9.959 -16.176 -87.908 125.93033588456754\n", "8.83 -15.458 -89.008 127.13632159615126\n", "17.793 -19.164 -90.671 125.0010936632156\n", "17.752 -19.535 -89.743 124.44409666593268\n", "17.946 -20.137 -91.767 126.15206586893454\n", "18.0 -21.043 -91.347 126.15170516088952\n", "19.292 -20.057 -92.519 126.05256558674242\n", "19.525 -19.17 -93.323 126.23566176401975\n", "16.684 -20.026 -92.65 127.42324931110491\n", "16.564 -19.073 -92.928 127.34007770533202\n", "16.803 -20.598 -93.461 128.21491838705822\n", "15.424 -20.494 -91.875 127.63554251853203\n", "15.341 -21.484 -91.992 128.1512141027154\n", "15.562 -20.283 -90.907 126.73864138059868\n", "14.087 -19.861 -92.303 128.4078195204638\n", "13.053 -20.301 -91.753 128.6883771519402\n", "14.086 -18.849 -93.039 128.59939148767384\n", "20.3 -20.906 -92.278 125.71017550301964\n", "21.187 -20.482 -92.095 124.97870622230012\n", "20.28 -22.373 -92.246 126.2790062441101\n", "21.221 -22.623 -92.476 126.11718141871074\n", "19.385 -22.969 -93.343 127.80252209561436\n", "18.22 -23.218 -93.082 128.25820576087906\n", "20.022 -22.943 -90.84 125.53836282985372\n", "20.629 -22.522 -90.166 124.55188523663541\n", "20.177 -23.931 -90.82 125.85741723474226\n", "19.079 -22.774 -90.552 125.70146393737824\n", "19.955 -23.119 -94.547 128.53787928077855\n", "20.643 -22.429 -94.77 128.11667033216247\n", "19.738 -24.134 -95.603 129.8797960346412\n", "20.104 -25.007 -95.281 129.81411961339182\n", "20.481 -23.601 -96.863 130.3174449028218\n", "20.089 -22.572 -97.393 130.51145979185122\n", "18.237 -24.393 -95.874 130.90192003557473\n", "17.741 -23.529 -95.792 130.72674676974103\n", "18.134 -24.75 -96.802 131.8218518797244\n", "17.609 -25.39 -94.913 130.85923030875583\n", "18.076 -26.659 -94.645 130.95839942134293\n", "18.87 -27.093 -95.072 131.09849041846363\n", "16.499 -25.209 -94.124 130.71079213668625\n", "15.926 -24.39 -94.098 130.63692853477534\n", "17.283 -27.214 -93.713 130.85513055665794\n", "17.405 -28.131 -93.334 130.90066516637722\n", "16.307 -26.369 -93.362 130.70202082982496\n", "21.713 -24.016 -97.218 130.2076711411428\n", "22.443 -23.353 -97.051 129.48082453398263\n", "22.163 -25.304 -97.82 131.01144649228172\n", "23.134 -25.169 -98.019 130.68781125644426\n", "21.435 -25.582 -99.154 132.51157214371884\n", "20.212 -25.496 -99.152 133.02185002848216\n", "22.056 -26.493 -96.825 130.76386082935912\n", "21.065 -26.589 -96.728 131.1713819741181\n", "22.65 -27.832 -97.277 131.4281017971423\n", "22.533 -28.532 -96.572 131.2262915577515\n", "23.628 -27.745 -97.464 131.11373523014282\n", "22.205 -28.158 -98.111 132.42178058386014\n", "22.811 -26.202 -95.521 129.2752175824895\n", "22.738 -26.971 -94.886 129.1357006330937\n", "22.442 -25.391 -95.066 128.7389700828774\n", "23.782 -26.04 -95.698 128.91873023343038\n", "22.079 -26.104 -100.224 133.2974726542105\n", "23.366 -25.793 -100.885 133.14649623253328\n", "23.699 -24.887 -100.625 132.42655121236072\n", "23.208 -25.844 -102.444 134.49523638032687\n", "22.087 -25.949 -102.924 135.40421289236167\n", "24.251 -26.954 -100.424 132.87916840498363\n", "25.027 -27.085 -101.041 133.1075210271756\n", "24.585 -26.807 -99.493 131.92791761412744\n", "23.274 -28.142 -100.49 133.8453113149654\n", "23.42 -28.668 -101.328 134.67742947131117\n", "23.395 -28.738 -99.697 133.41509789000645\n", "21.866 -27.519 -100.484 134.18382796000418\n", "21.41 -27.631 -101.367 135.13363567594857\n", "21.294 -27.909 -99.762 134.02309930008335\n", "24.308 -25.825 -103.219 134.6562303460185\n", "25.064 -25.269 -102.874 133.83788920182505\n", "24.563 -26.514 -104.519 135.89110570232327\n", "25.032 -27.342 -104.212 135.78732805751795\n", "25.451 -25.652 -105.433 135.9340869576134\n", "25.072 -24.538 -105.79 135.94218439101235\n", "23.306 -26.962 -105.314 137.23929449323177\n", "22.583 -26.283 -105.183 137.16116118639417\n", "23.541 -27.015 -106.284 137.9558233384876\n", "22.774 -28.34 -104.861 137.65603294443727\n", "23.064 -28.454 -103.911 136.81427905741418\n", "21.251 -28.437 -104.921 138.38651851246203\n", "20.937 -29.338 -104.623 138.65460126876425\n", "20.919 -28.289 -105.853 139.21890335008388\n", "20.825 -27.752 -104.33 137.81218451211055\n", "23.336 -29.452 -105.754 138.60925572630424\n", "22.996 -30.348 -105.467 138.89444929873906\n", "24.335 -29.474 -105.713 138.1783775016916\n", "23.071 -29.314 -106.708 139.43439209893663\n", "26.601 -26.207 -105.83 136.02590055206397\n", "26.816 -27.113 -105.466 136.00884277869582\n", "27.576 -25.612 -106.749 136.16937041052952\n", "27.426 -26.002 -107.658 137.13910054029083\n", "27.415 -24.625 -106.778 135.8664419236774\n", "29.0 -25.88 -106.312 135.36812127306783\n", "29.519 -25.031 -105.558 134.2024724101609\n", "29.501 -26.953 -106.714 135.94984685905314\n" ] }, { "data": { "text/plain": [ "0" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from Bio.PDB import *\n", "from rdkit import Chem\n", "import glob\n", "from tqdm import tqdm\n", "from ray.util.multiprocessing import Pool\n", "import os\n", "import ray\n", "\n", "@ray.remote\n", "def single_extract_pocket(names):\n", " bad_mol = 0\n", " for name in names:\n", " id = int(name.split(\"/\")[-1].split(\".\")[0])\n", "\n", " pocket_out_path = f\"/scratch/bbto/suyufeng/data/pocket/{id}.pdb\"\n", " ligand_out_path = f\"/scratch/bbto/suyufeng/data/raw_ligand/{id}.sdf\"\n", " lines = []\n", " ed = 0\n", " for index, line in enumerate(open(name, \"r\")):\n", " lines.append(line)\n", " if \"COMPND\" in line:\n", " ed = index\n", "\n", " protein_lines = lines[:ed]\n", " ligand_lines = lines[ed+1:]\n", "\n", " ftmp_out = open(f\"/scratch/bbto/suyufeng/data/raw_ligand/tmp_{id}.pdb\", \"w\")\n", " for line in ligand_lines:\n", " ftmp_out.write(line)\n", " ftmp_out.close()\n", "\n", " mol = Chem.MolFromPDBFile(f\"/scratch/bbto/suyufeng/data/raw_ligand/tmp_{id}.pdb\", flavor=1, sanitize=False)\n", " os.system(f\"rm -r /scratch/bbto/suyufeng/data/raw_ligand/tmp_{id}.pdb\")\n", " if mol is None:\n", " print(f\"!!!!!{id}!!!!!\")\n", " bad_mol += 1\n", " continue\n", "\n", " ligand_coords = []\n", " # mol = Chem.RemoveHs(mol, sanitize=False)\n", " for i, atom in enumerate(mol.GetAtoms()):\n", " positions = mol.GetConformer().GetAtomPosition(i)\n", " ligand_coords.append((positions.x, positions.y, positions.z))\n", " \n", " try:\n", " writer = Chem.SDWriter(ligand_out_path)\n", " writer.write(mol, confId=0)\n", " except:\n", " bad_mol += 1\n", " continue\n", "\n", " fin = open(pocket_out_path, \"w\")\n", "\n", " for line in protein_lines:\n", " if \"ATOM\" in line:\n", " try:\n", " x = float(line[30:38])\n", " y = float(line[38:46])\n", " z = float(line[46:54])\n", " for ligand_coord in ligand_coords:\n", " if 'H' not in line[12:16].strip() and distance(x, y, z, ligand_coord[0], ligand_coord[1], ligand_coord[2]) < 10:\n", " fin.write(line)\n", " break\n", " except:\n", " continue\n", " \n", " elif \"HETATM\" in line or \"ENDMDL\" in line:\n", " fin.write(line)\n", " return bad_mol\n", "\n", "def distance(x1, y1, z1, x2, y2, z2):\n", " return (1. * (x2 - x1) ** 2 + 1. * (y2 - y1) ** 2 + 1. * (z2 - z1) ** 2) ** 0.5\n", "\n", "\n", "os.makedirs(\"/scratch/bbto/suyufeng/data\", exist_ok=True)\n", "os.makedirs(\"/scratch/bbto/suyufeng/data/raw_ligand\", exist_ok=True)\n", "os.makedirs(\"/scratch/bbto/suyufeng/data/pocket\", exist_ok=True)\n", "\n", "mol = None\n", "\n", "parameters = []\n", "for name in tqdm(glob.glob(f\"/scratch/bbto/tjdean2/General_dataset/*.pdb\")):\n", " parameters.append(name)\n", "\n", "results = [parameters[i*1000: (i+1)*1000] for i in range(len(parameters) // 1000)]\n", "bad_molecular = 0\n", "\n", "\n", "results = [single_extract_pocket.remote(parameters[i*100: (i+1)*100]) for i in range(len(parameters) // 100)]\n", "bad_molecular = 0\n", "\n", "for result in tqdm(ray.get(results)):\n", " bad_molecular += result\n", " \n", "# print(single_extract_pocket(parameters))\n", "print(bad_molecular)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n" ] } ], "source": [ "from rdkit.Chem import rdFMCS\n", "from rdkit.Chem import Draw\n", "from rdkit.Chem import AllChem,rdDepictor\n", "from rdkit import Chem\n", "import pandas as pd\n", "import glob\n", "from rdkit import RDLogger\n", "import ray\n", "\n", "root_dir = \"/projects/bbto/suyufeng/enzyme_specificity\"\n", "\n", "def AssignBondOrdersFromTemplate(refmol, mol):\n", " \"\"\" assigns bond orders to a molecule based on the\n", " bond orders in a template molecule\n", " Revised from AllChem.AssignBondOrderFromTemplate(refmol, mol)\n", " \"\"\"\n", " AllChem.AssignBondOrdersFromTemplate\n", " refmol2 = Chem.rdchem.Mol(refmol)\n", " mol2 = Chem.rdchem.Mol(mol)\n", " # do the molecules match already?\n", " matching = mol2.GetSubstructMatch(refmol2)\n", " if not matching: # no, they don't match\n", " # check if bonds of mol are SINGLE\n", " for b in mol2.GetBonds():\n", " if b.GetBondType() != Chem.BondType.SINGLE:\n", " b.SetBondType(Chem.BondType.SINGLE)\n", " b.SetIsAromatic(False)\n", " # set the bonds of mol to SINGLE\n", " for b in refmol2.GetBonds():\n", " b.SetBondType(Chem.BondType.SINGLE)\n", " b.SetIsAromatic(False)\n", " # set atom charges to zero;\n", " for a in refmol2.GetAtoms():\n", " a.SetFormalCharge(0)\n", " for a in mol2.GetAtoms():\n", " a.SetFormalCharge(0)\n", "\n", " matching = mol2.GetSubstructMatches(refmol2, uniquify=False)\n", " # do the molecules match now?\n", " if matching:\n", " if len(matching) > 1:\n", " #logger.warning(\"More than one matching pattern found - picking one\")\n", " pass\n", " matchings=matching[:]\n", " for matching in matchings:\n", " #matching = matching[0] ## use each matching\n", " # apply matching: set bond properties\n", " for b in refmol.GetBonds():\n", " atom1 = matching[b.GetBeginAtomIdx()]\n", " atom2 = matching[b.GetEndAtomIdx()]\n", " b2 = mol2.GetBondBetweenAtoms(atom1, atom2)\n", " b2.SetBondType(b.GetBondType())\n", " b2.SetIsAromatic(b.GetIsAromatic())\n", " # apply matching: set atom properties\n", " for a in refmol.GetAtoms():\n", " a2 = mol2.GetAtomWithIdx(matching[a.GetIdx()])\n", " a2.SetHybridization(a.GetHybridization())\n", " a2.SetIsAromatic(a.GetIsAromatic())\n", " a2.SetNumExplicitHs(a.GetNumExplicitHs())\n", " a2.SetFormalCharge(a.GetFormalCharge())\n", " try:\n", " Chem.SanitizeMol(mol2)\n", " if hasattr(mol2, '__sssAtoms'):\n", " mol2.__sssAtoms = None # we don't want all bonds highlighted\n", " break\n", " except ValueError:\n", " pass\n", " # print(\"More than one matching pattern, Fail at this matching. Try next.\")\n", " else:\n", " raise ValueError(\"No matching found\")\n", " return mol2\n", "\n", "def alignment_number_system(sdf, smile_mol):\n", " \n", " template = smile_mol\n", " query = sdf\n", "\n", " mcs = rdFMCS.FindMCS([template, query], timeout=120)\n", " patt = Chem.MolFromSmarts(mcs.smartsString)\n", "\n", " query_match = query.GetSubstructMatch(patt)\n", " template_match = template.GetSubstructMatch(patt)\n", "\n", " result = [-1] * query.GetNumAtoms()\n", "\n", " for query_atom_id, template_atom_id in zip(query_match, template_match):\n", " result[query_atom_id] = template_atom_id\n", "\n", " # Check if there is any atom not matched\n", " for atom in query.GetAtoms():\n", " assert atom.GetAtomicNum() == 1 or result[atom.GetIdx()] != -1\n", "\n", " return result\n", "\n", "def assign_idx(mol, idxs):\n", " for atom, idx in zip(mol.GetAtoms(), idxs):\n", " atom.SetAtomMapNum(idx)\n", " return mol\n", "\n", "def mol_get_atomic_number(mol, atom_map=False):\n", " result = [0] * mol.GetNumAtoms()\n", " for atom in mol.GetAtoms():\n", " if atom.GetAtomMapNum() != -1:\n", " if atom_map:\n", " result[atom.GetAtomMapNum()] = atom.GetAtomicNum()\n", " else:\n", " result[atom.GetIdx()] = atom.GetAtomicNum()\n", " return result\n", "\n", "def check(mol, mol2):\n", " for atom in mol.GetAtoms():\n", " if atom.GetAtomMapNum() != -1:\n", " id = atom.GetAtomMapNum()\n", " \n", " atom2 = mol2.GetAtomWithIdx(id)\n", " if atom.GetAtomicNum() != atom2.GetAtomicNum():\n", " return False\n", " return True\n", "\n", "def view_difference(mol1, mol2):\n", " mcs = rdFMCS.FindMCS([mol1,mol2])\n", " mcs_mol = Chem.MolFromSmarts(mcs.smartsString)\n", " match1 = mol1.GetSubstructMatch(mcs_mol)\n", " target_atm1 = []\n", " for atom in mol1.GetAtoms():\n", " if atom.GetIdx() not in match1:\n", " target_atm1.append(atom.GetIdx())\n", " match2 = mol2.GetSubstructMatch(mcs_mol)\n", " target_atm2 = []\n", " for atom in mol2.GetAtoms():\n", " if atom.GetIdx() not in match2:\n", " target_atm2.append(atom.GetIdx())\n", " return Draw.MolsToGridImage([mol1, mol2],highlightAtomLists=[target_atm1, target_atm2])\n", "\n", "def single_match(item):\n", " id, smile = item\n", " sdf_path = f\"/scratch/bbto/suyufeng/data/raw_ligand/{id}.sdf\"\n", " RDLogger.DisableLog('rdApp.*')\n", "\n", " try:\n", " mol = next(iter(Chem.SDMolSupplier(sdf_path, sanitize=True)))\n", " mol = Chem.RemoveHs(mol)\n", " except Exception as e:\n", " try:\n", " mol = next(iter(Chem.SDMolSupplier(sdf_path, sanitize=False)))\n", " mol = Chem.RemoveHs(mol, sanitize=False)\n", " except Exception as e:\n", " return 1 \n", " # mol = Chem.MolFromSmiles(Chem.MolToSmiles(mol))\n", " try:\n", " smile_mol = Chem.MolFromSmiles(smile)\n", " except Exception as e:\n", " return 1\n", " # print(mol_get_atomic_number(smile_mol))\n", " # print(len(smile_mol.GetAtoms()))\n", " try:\n", " aligned_idx = alignment_number_system(mol, smile_mol)\n", " except:\n", " \n", " try:\n", " mol = AssignBondOrdersFromTemplate(smile_mol, mol)\n", " except:\n", " return 1\n", " \n", " try:\n", " aligned_idx = alignment_number_system(mol, smile_mol)\n", " except:\n", " return 1\n", " mol = assign_idx(mol, aligned_idx)\n", " # print(mol_get_atomic_number(mol, atom_map=True))\n", " if not check(mol, smile_mol):\n", " return 1\n", "\n", " w = Chem.SDWriter(f\"/scratch/bbto/suyufeng/data/ligand/{id}.sdf\")\n", " try:\n", " w.write(mol)\n", " w.close()\n", " except:\n", " w.close()\n", " return 1\n", " \n", " return 0\n", "\n", "@ray.remote(num_cpus=1)\n", "def batched_match(items):\n", " ans = 0\n", " for item in items:\n", " id, smile = item\n", " try:\n", " result = single_match(item)\n", " ans += result\n", " except:\n", " ans += 1\n", "\n", " if not result:\n", " os.system(f\"rm -r /scratch/bbto/suyufeng/data/raw_ligand/{id}.sdf\")\n", "\n", " return ans\n", "\n", "from tqdm import tqdm\n", "\n", "import os\n", "os.makedirs(f\"/scratch/bbto/suyufeng/data/ligand\", exist_ok=True)\n", "\n", "df = pd.read_csv(f\"{root_dir}/data/brenda/final_data/data.csv\")\n", "sub_index_dict = {index: substrate_id for index, substrate_id in zip(df[\"structure_index\"].values, df[\"reaction\"].values)}\n", "\n", "\n", "sub_df = pd.read_csv(f\"{root_dir}/data/brenda/reaction.csv\")\n", "substrates = sub_df[\"substrates\"].values\n", "\n", "bad_molecular = 0\n", "\n", "parameters = []\n", "for index, sdf_path in tqdm(enumerate(glob.glob(f\"/scratch/bbto/suyufeng/data/raw_ligand/*.sdf\"))):\n", " \n", " id = os.path.basename(sdf_path).split(\".\")[0]\n", " \n", " if int(id) not in sub_index_dict:\n", " continue\n", "\n", " substrate_id = int(sub_index_dict[int(id)])\n", " smile = substrates[substrate_id]\n", "\n", " parameters.append((int(id), smile))\n", "\n", "results = [batched_match.remote(parameters[i*100: (i+1)*100]) for i in range(len(parameters) // 100)]\n", "bad_molecular = 0\n", "\n", "for result in tqdm(ray.get(results)):\n", " bad_molecular += result\n", " \n", " # break\n", "print(bad_molecular)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3.7.13 ('revae')", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.13" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "ea8e2fe48c7ffefb1d2d9f58e61432847d99d21375144a203023aa806149d953" } } }, "nbformat": 4, "nbformat_minor": 2 }
Unknown
3D
antecede/EZSpecificity
Datasets/Structure/collator.py
.py
5,668
148
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import torch import numpy as np def pad_1d_unsqueeze(x, padlen): x = x + 1 # pad id = 0 xlen = x.size(0) if xlen < padlen: new_x = x.new_zeros([padlen], dtype=x.dtype) new_x[:xlen] = x x = new_x return x.unsqueeze(0) def pad_2d_unsqueeze(x, padlen): x = x + 1 # pad id = 0 xlen, xdim = x.size() if xlen < padlen: new_x = x.new_zeros([padlen, xdim], dtype=x.dtype) new_x[:xlen, :] = x x = new_x return x.unsqueeze(0) def pad_attn_bias_unsqueeze(x, padlen): xlen = x.size(0) if xlen < padlen: new_x = x.new_zeros([padlen, padlen], dtype=x.dtype).fill_(float('-inf')) new_x[:xlen, :xlen] = x new_x[xlen:, :xlen] = 0 x = new_x return x.unsqueeze(0) def pad_edge_type_unsqueeze(x, padlen): xlen = x.size(0) if xlen < padlen: new_x = x.new_zeros([padlen, padlen, x.size(-1)], dtype=x.dtype) new_x[:xlen, :xlen, :] = x x = new_x return x.unsqueeze(0) def pad_rel_pos_unsqueeze(x, padlen): x = x + 1 xlen = x.size(0) if xlen < padlen: new_x = x.new_zeros([padlen, padlen], dtype=x.dtype) new_x[:xlen, :xlen] = x x = new_x return x.unsqueeze(0) def pad_rel_pos_3d_unsqueeze(x, padlen): xlen = x.size(0) if xlen < padlen: new_x = x.new_zeros([padlen, padlen], dtype=x.dtype) new_x[:xlen, :xlen] = x x = new_x return x.unsqueeze(0) def pad_3d_unsqueeze(x, padlen1, padlen2, padlen3): x = x + 1 xlen1, xlen2, xlen3, xlen4 = x.size() if xlen1 < padlen1 or xlen2 < padlen2 or xlen3 < padlen3: new_x = x.new_zeros([padlen1, padlen2, padlen3, xlen4], dtype=x.dtype) new_x[:xlen1, :xlen2, :xlen3, :] = x x = new_x return x.unsqueeze(0) class Batch(): def __init__(self, idx, attn_bias, attn_edge_type, graph_dist, geo_dist, in_degree, out_degree, protein_x, ligand_x, edge_input, y, num_protein_nodes, num_ligand_nodes): super(Batch, self).__init__() self.idx = idx self.in_degree, self.out_degree = in_degree, out_degree self.protein_x, self.ligand_x, self.y = protein_x, ligand_x, y self.attn_bias, self.attn_edge_type, self.rel_pos = attn_bias, attn_edge_type, graph_dist self.edge_input = edge_input self.geo_dist = geo_dist self.graph_dist = graph_dist self.num_protein_nodes = num_protein_nodes self.num_ligand_nodes = num_ligand_nodes def to(self, device): self.idx = self.idx.to(device) self.in_degree, self.out_degree = self.in_degree.to(device), self.out_degree.to(device) self.x, self.y = self.x.to(device), self.y.to(device) self.protein_x = self.protein_x.to(device) self.ligand_x = self.ligand_x.to(device) self.attn_bias, self.attn_edge_type, self.rel_pos = self.attn_bias.to(device), self.attn_edge_type.to(device), self.rel_pos.to(device) self.edge_input = self.edge_input.to(device) self.geo_dist = self.geo_dist.to(device) self.graph_dist = self.graph_dist.to(device) return self def __len__(self): return self.in_degree.size(0) def collator(items, max_node=1024, multi_hop_max_dist=20, rel_pos_max=20): items = [item for item in items if item is not None and item.protein_x.size(0) + item.ligand_x.size(0) <= max_node] items_ = [(item.id, item.attn_bias, item.attn_edge_type, item.rel_pos, item.in_degree, item.out_degree, item.protein_x, item.ligand_x, item.edge_input[:, :, :multi_hop_max_dist, :], item.y) for item in items] idxs, attn_biases, attn_edge_types, rel_poses, in_degrees, out_degrees, p_xs, l_xs, edge_inputs, ys = zip(*items_) items_ = [(item.geo_dist,) for item in items] all_rel_pos_3d_1s, = zip(*items_) for idx, _ in enumerate(attn_biases): attn_biases[idx][1:, 1:][rel_poses[idx] >= rel_pos_max] = float('-inf') max_dist = max(i.size(-2) for i in edge_inputs) y = torch.cat(ys) # max_node_num = max(i.size(0) for i in xs) # x = torch.cat([pad_2d_unsqueeze(i, max_node_num) for i in xs]) max_p_node_num = max(i.size(0) for i in p_xs) max_l_node_num = max(i.size(0) for i in l_xs) protein_x = torch.cat([pad_2d_unsqueeze(i, max_p_node_num) for i in p_xs]) ligand_x = torch.cat([pad_2d_unsqueeze(i, max_l_node_num) for i in l_xs]) max_node_num = max_p_node_num + max_l_node_num edge_input = torch.cat([pad_3d_unsqueeze(i, max_node_num, max_node_num, max_dist) for i in edge_inputs]) attn_bias = torch.cat([pad_attn_bias_unsqueeze(i, max_node_num + 1) for i in attn_biases]) attn_edge_type = torch.cat([pad_edge_type_unsqueeze(i, max_node_num) for i in attn_edge_types]) rel_pos = torch.cat([pad_rel_pos_unsqueeze(i, max_node_num) for i in rel_poses]) all_rel_pos_3d_1 = torch.cat([pad_rel_pos_3d_unsqueeze(i, max_node_num) for i in all_rel_pos_3d_1s]) in_degree = torch.cat([pad_1d_unsqueeze(i, max_node_num) for i in in_degrees]) out_degree = torch.cat([pad_1d_unsqueeze(i, max_node_num) for i in out_degrees]) return Batch( idx=torch.LongTensor(idxs), attn_bias=attn_bias, attn_edge_type=attn_edge_type, graph_dist=rel_pos, geo_dist=all_rel_pos_3d_1, in_degree=in_degree, out_degree=out_degree, protein_x=protein_x, ligand_x=ligand_x, edge_input=edge_input, y=y, num_protein_nodes=[i.size(0) for i in p_xs], num_ligand_nodes=[i.size(0) for i in l_xs] )
Python
3D
antecede/EZSpecificity
Datasets/Structure/transforms.py
.py
7,875
182
import sys root_dir = "/projects/bbto/suyufeng/enzyme_specificity" sys.path.append(f"{root_dir}/src") import torch import torch.nn.functional as F import numpy as np from rdkit.Chem.rdchem import BondType from Datasets.Structure.utils import StructureComplexData from Datasets.Structure.protein_ligand import ATOM_FEATS from torch_geometric.nn import knn_graph import pyximport pyximport.install(setup_args={'include_dirs': np.get_include()}) class FeaturizeProteinAtom(object): def __init__(self): super().__init__() self.atomic_numbers = torch.LongTensor([1, 6, 7, 8, 16, 34]) # H, C, N, O, S, Se self.max_num_aa = 21 @property def feature_dim(self): return self.atomic_numbers.size(0) + self.max_num_aa + 1 def __call__(self, data: StructureComplexData): element = data.protein_element.view(-1, 1) == self.atomic_numbers.view(1, -1) # (N_atoms, N_elements) amino_acid = F.one_hot(data.protein_atom_to_aa_type, num_classes=self.max_num_aa) is_backbone = data.protein_is_backbone.view(-1, 1).long() x = torch.cat([element, amino_acid, is_backbone], dim=-1) data.protein_atom_feature = x return data class FeaturizeLigandAtom(object): def __init__(self): super().__init__() self.atomic_numbers = torch.LongTensor([1, 6, 7, 8, 9, 15, 16, 17, 26, 35, 53]) # H, C, N, O, F, P, S, Cl, Fe, Br, I # self.n_degree = torch.LongTensor([0, 1, 2, 3, 4, 5]) # 0 - 5 # self.n_num_hs = 6 # 0 - 5 @property def num_properties(self): return sum(ATOM_FEATS.values()) @property def feature_dim(self): return self.atomic_numbers.size(0) + self.num_properties def __call__(self, data: StructureComplexData): element = data.ligand_element.view(-1, 1) == self.atomic_numbers.view(1, -1) # (N_atoms, N_elements) # convert some features to one-hot vectors atom_feature = [] for i, (k, v) in enumerate(ATOM_FEATS.items()): feat = data.ligand_atom_feature[:, i:i+1] if v > 1: feat = (feat == torch.LongTensor(list(range(v))).view(1, -1)) else: if k == 'AtomicNumber': feat = feat / 100. atom_feature.append(feat) # data.ligand_atom_feature: atomic_number, aromatic, degree, num_hs # try: # # degree = F.one_hot(data.ligand_atom_feature[:, 2], num_classes=self.n_degree) # degree = data.ligand_atom_feature[:, 2:3] == self.n_degree.view(1, -1) # num_hs = F.one_hot(data.ligand_atom_feature[:, 3], num_classes=self.n_num_hs) # except: # print(torch.max(data.ligand_atom_feature[:, 2])) # print(torch.max(data.ligand_atom_feature[:, 3])) # raise ValueError atom_feature = torch.cat(atom_feature, dim=-1) data.ligand_atom_feature_full = torch.cat([element, atom_feature], dim=-1) return data from rdkit.Chem.rdchem import BondType from Models.common import GaussianSmearing class EdgeConnection(object): def __init__(self, dist_noise=True, cutoff=12, num_r_gaussian=24, k=48): super(EdgeConnection, self).__init__() self.dist_noise = dist_noise self.k = k self.num_r_gaussian = num_r_gaussian self.cutoff = cutoff self.distance_expansion = GaussianSmearing(stop=cutoff, num_gaussians=num_r_gaussian) @property def feature_dim(self): return 6 + 1 + self.num_r_gaussian def _build_knn_graph(self, data): pos = torch.cat([data.ligand_pos, data.protein_pos], dim=0) dict = {(x, y): 1 for x, y in zip(data.ligand_bond_index[0, :], data.ligand_bond_index[1, :])} knn_index = knn_graph(pos, k=self.k, flow='target_to_source') result = [] for edge in knn_index.permute(1, 0): if (edge[0], edge[1]) not in dict: result.append(edge[:, None]) if len(result) == 0: return torch.zeros((2, 0), dtype=torch.long) return torch.cat(result, dim=1) def _get_dist(self, edge_index, pos): dst, src = edge_index dist = torch.norm(pos[dst] - pos[src], p=2, dim=-1) if self.dist_noise: dist = dist + torch.from_numpy(np.random.laplace(0.001994, 0.031939, (dist.size(0),))).float() # mask = dist < self.cutoff # dist = dist[mask] # edge_index = edge_index[:, mask] return edge_index, self.distance_expansion(dist) def __call__(self, data): N_substrate = data.ligand_pos.size(0) N_protein = data.protein_pos.size(0) if data.str_tag == 'ligand': knn_index = torch.zeros((2, 0), dtype=torch.long) else: knn_index = self._build_knn_graph(data) # dist matrix pos = torch.cat([data.ligand_pos, data.protein_pos], dim=0) knn_index, dist_feat_knn = self._get_dist(knn_index, pos) data.ligand_bond_index, dist_feat_real =self._get_dist(data.ligand_bond_index, pos) dist_feat = torch.cat([dist_feat_knn, dist_feat_real], dim=0) # bond type data.ligand_bond_type[data.ligand_bond_type==12] = 5 ligand_bond_feature_real = F.one_hot(data.ligand_bond_type - 1, num_classes=6) ligand_bond_feature_knn = F.one_hot(torch.ones((knn_index.shape[1]),dtype=torch.long) * 5, num_classes=6) bond_feat = torch.cat([ligand_bond_feature_knn, ligand_bond_feature_real], dim=0) # cross bond cross_bond = ((knn_index[0, :] < N_substrate).logical_and(knn_index[1, :] >= N_substrate)).logical_or((knn_index[0, :] >= N_substrate).logical_and(knn_index[1, :] < N_substrate)) cross_bond = torch.cat([cross_bond, torch.zeros([data.ligand_bond_index.size(1)], dtype=bool)], dim=0)[:, None].int() data.complex_edge_attr = torch.cat([bond_feat, dist_feat, cross_bond], dim=-1) # [E, F] data.protein_x = torch.cat([torch.zeros((N_substrate, data.protein_atom_feature.shape[1])), data.protein_atom_feature], dim=0) data.ligand_x = torch.cat([data.ligand_atom_feature_full, torch.zeros((N_protein, data.ligand_atom_feature_full.shape[1]))], dim=0) data.ligand_mask = torch.cat([torch.ones((N_substrate,)), torch.zeros((N_protein,))], dim=0) data.protein_mask = torch.cat([torch.zeros((N_substrate,)), torch.ones((N_protein,))], dim=0) data.complex_edge_index = torch.cat([data.ligand_bond_index, knn_index], dim=-1) data.ligand_index = torch.cat([data.ligand_index, torch.ones((N_protein, )).long() * 280], dim=-1) # print(data) data.ligand_atom_feature_full = None data.protein_atom_feature = None data.protein_pos = None data.ligand_pos = None data.ligand_bond_index = None data.ligand_bond_type = None data.protein_molecule_name = None data.protein_filename = None # data.y = None return data if __name__ == "__main__": N_protein = 10 N_substrate = 20 protein_pos = torch.rand([N_protein, 3]) ligand_pos = torch.rand([N_substrate, 3]) protein_atom_feature = torch.randint(0, 2, [N_protein, 10]) ligand_atom_feature_full = torch.randint(0, 2, [N_substrate, 10]) ligand_bond_index = torch.randint(0, N_substrate, [2, 10]) ligand_bond_type = torch.randint(1, len(BondType.names.values()), [10]) ligand_index = torch.randint(0, 280, [N_substrate]) data = StructureComplexData(protein_pos=protein_pos, ligand_pos=ligand_pos, ligand_bond_index=ligand_bond_index, ligand_bond_type=ligand_bond_type, protein_atom_feature=protein_atom_feature, ligand_atom_feature_full=ligand_atom_feature_full, ligand_index=ligand_index) data = EdgeConnection()(data) print(data)
Python
3D
antecede/EZSpecificity
Datasets/Specific_familty/other_small_family.ipynb
.ipynb
36,262
886
{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import sys\n", "from collections import defaultdict\n", "import random\n", "\n", "data_root_dir = \"/projects/bbto/suyufeng/enzyme_specificity\"\n", "src_root_dir = \"/projects/bbto/suyufeng/enzyme_specificity\"\n", "query_enzymes = [\"2023_brenda\"]\n", "sys.path.append(f\"{src_root_dir}/src\")\n", "sys.path.append(f\"{src_root_dir}/src/other_softwares/hgraph2graph\")\n", "sys.path.append(f\"{src_root_dir}/src/other_softwares/grover_software\")\n", "# t = pd.read_csv(f\"{root_dir}/data/halogenase/datas.csv\", sep=',')\n", "# print(t['Substrate0'])\n", "# print(t[\"Product0\"])\n", "# print(t['Sequence'])\n", "# print(t['UniprotID'])" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Create enzyme embedding and vocabulary size \n", "1. esm2 embedding\n", "\n", "Datasets/create_features.py \"Create enzyme features for small family dataset\"" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Create substrate Features\n", "1. Our reaction features\n", "\n", " Check Datasets/create_features.py \"Create reaction features for small family dataset\"\n", "2. Get Morgan fingerprint embedding" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from rdkit.Chem import AllChem, DataStructs\n", "import numpy as np\n", "\n", "for enzyme_tag in query_enzymes:\n", " df = pd.read_csv(f\"{data_root_dir}/data/small_family/{enzyme_tag}/reactions.csv\", sep=',')\n", " results = []\n", " for substrate in df['substrates']:\n", " mol = AllChem.MolFromSmiles(substrate)\n", " fp = AllChem.GetMorganFingerprintAsBitVect(mol, 2, 1024)\n", " arr = np.zeros((0,), dtype=np.int8)\n", " DataStructs.ConvertToNumpyArray(fp,arr)\n", " results.append(arr)\n", " np.save(f\"{data_root_dir}/data/small_family/{enzyme_tag}/morgan_fingerprint.npy\", np.array(results))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "3. Get grover embedding" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# 1.create smile only csv\n", "import pandas as pd\n", "import os\n", "\n", "for enzyme_tag in query_enzymes:\n", " df = pd.read_csv(f\"{data_root_dir}/data/small_family/{enzyme_tag}/reactions.csv\", sep=',')\n", " results = [smile for smile in df['substrates']]\n", " data = {\n", " \"substrates\": results\n", " }\n", " data = pd.DataFrame(data)\n", " data.to_csv(f\"{data_root_dir}/data/small_family/{enzyme_tag}/substrates.csv\", index=False)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "python /projects/bbto/suyufeng/enzyme_specificity/src/other_softwares/grover_software/scripts/save_features.py --data_path /scratch/bbto/suyufeng/tmp/enzyme_specificity/data/small_family/2023_brenda/substrates.csv --save_path /scratch/bbto/suyufeng/tmp/enzyme_specificity/data/small_family/2023_brenda/substrates.npz --features_generator fgtasklabel --restart\n" ] } ], "source": [ "# 2. Get npz feature\n", "for enzyme_tag in query_enzymes:\n", " print(f\"python {src_root_dir}/src/other_softwares/grover_software/scripts/save_features.py --data_path {data_root_dir}/data/small_family/{enzyme_tag}/substrates.csv \\\n", " --save_path {data_root_dir}/data/small_family/{enzyme_tag}/substrates.npz \\\n", " --features_generator fgtasklabel \\\n", " --restart\")" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "python /projects/bbto/suyufeng/enzyme_specificity/src/other_softwares/grover_software/scripts/build_vocab.py --data_path /scratch/bbto/suyufeng/tmp/enzyme_specificity/data/small_family/2023_brenda/substrates.csv --vocab_save_folder /scratch/bbto/suyufeng/tmp/enzyme_specificity/data/small_family/2023_brenda/grover_vocab --dataset_name 2023_brenda\n" ] } ], "source": [ "# 3. Get build vocab\n", "for enzyme_tag in query_enzymes:\n", " os.system(f\"mkdir {data_root_dir}/data/small_family/{enzyme_tag}/grover_vocab\")\n", " print(f\"python {src_root_dir}/src/other_softwares/grover_software/scripts/build_vocab.py --data_path {data_root_dir}/data/small_family/{enzyme_tag}/substrates.csv \\\n", " --vocab_save_folder {data_root_dir}/data/small_family/{enzyme_tag}/grover_vocab \\\n", " --dataset_name {enzyme_tag}\")" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "python main.py fingerprint --data_path /projects/bbto/suyufeng/enzyme_specificity/data/small_family/2023_brenda/substrates.csv --features_path /projects/bbto/suyufeng/enzyme_specificity/data/small_family/2023_brenda/substrates.npz --checkpoint_path /projects/bbto/suyufeng/enzyme_specificity/data/pretrain_model/grover_large.pt --fingerprint_source both --output /projects/bbto/suyufeng/enzyme_specificity/data/small_family/2023_brenda/fingerprint.npz --save_lmdb_path /projects/bbto/suyufeng/enzyme_specificity/data/small_family/2023_brenda/grover_fingerprint.lmdb --fingerprint_source both\n" ] } ], "source": [ "# 4. Get fingerprint (GPU)\n", "for enzyme_tag in query_enzymes:\n", " print(f\"python main.py fingerprint --data_path {data_root_dir}/data/small_family/{enzyme_tag}/substrates.csv --features_path {data_root_dir}/data/small_family/{enzyme_tag}/substrates.npz --checkpoint_path {data_root_dir}/data/pretrain_model/grover_large.pt --fingerprint_source both --output {data_root_dir}/data/small_family/{enzyme_tag}/fingerprint.npz --save_lmdb_path {data_root_dir}/data/small_family/{enzyme_tag}/grover_fingerprint.lmdb --fingerprint_source both\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Create dataset" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3\n" ] } ], "source": [ "import os\n", "import pandas as pd\n", "from collections import defaultdict\n", "\n", "enzyme_tag_dict = defaultdict(lambda: \"SEQ\")\n", "enzyme_tag_dict[\"2023_brenda\"] = \"Sequence\"\n", "\n", "substrate_tag_dict = defaultdict(lambda: \"SUBSTRATES\")\n", "substrate_tag_dict[\"2023_brenda\"] = \"Substrate SMILES\"\n", "\n", "label_tag_dict = defaultdict(lambda: \"ReactionorNot\")\n", "label_tag_dict[\"2023_brenda\"] = \"Label\"\n", "\n", "# for enzyme_tag in [\"Duf\", \"Esterase\", \"Phosphatase\", \"Gt_acceptor\", \"Nitrilase\", \"Thiolase\"]:\n", "for enzyme_tag in [\"2023_brenda\"]:\n", " data = {\n", " \"reaction\": [],\n", " \"enzyme\": [],\n", " \"label\": [],\n", " \"structure_index\": [],\n", " \"positive_reactions\": []\n", " }\n", " enzyme_df = pd.read_csv(f\"{data_root_dir}/data/small_family/{enzyme_tag}/enzymes.csv\", sep=',')\n", " reaction_df = pd.read_csv(f\"{data_root_dir}/data/small_family/{enzyme_tag}/reactions.csv\", sep=',')\n", " df = pd.read_csv(f\"{data_root_dir}/data/small_family/{enzyme_tag}/data.csv\", sep=',')\n", "\n", " enzyme_dict = {enzyme: index for index, enzyme in enumerate(enzyme_df['sequences'])}\n", " reaction_dict = {reaction: index for index, reaction in enumerate(reaction_df['substrates'])}\n", "\n", " datas = []\n", " bad_cnt = 0\n", " for index, (sequence, substrate, label) in enumerate(zip(df[enzyme_tag_dict[\"2023_brenda\"]],df[substrate_tag_dict[\"2023_brenda\"]],df[label_tag_dict[\"2023_brenda\"]])):\n", " if sequence not in enzyme_dict:\n", " bad_cnt += 1\n", " continue\n", " if substrate not in reaction_dict:\n", " bad_cnt += 1\n", " continue\n", " datas.append((reaction_dict[substrate], enzyme_dict[sequence], label, index, reaction_dict[substrate]))\n", "\n", " reactions = list(set([a[0] for a in datas]))\n", " enzymes = list(set([a[1] for a in datas]))\n", "\n", " def save_data_csv(data, file_name, reaction_constraint=None, enzyme_constraint=None):\n", " data_df = {\n", " \"reaction\": [],\n", " \"enzyme\": [],\n", " \"label\": [],\n", " \"structure_index\": [],\n", " \"positive_reactions\": []\n", " }\n", " for reaction, enzyme, label, index, positive_reactions in data:\n", " if reaction_constraint is not None and reaction not in reaction_constraint:\n", " continue\n", " if enzyme_constraint is not None and enzyme not in enzyme_constraint:\n", " continue\n", " data_df[\"reaction\"].append(reaction)\n", " data_df[\"enzyme\"].append(enzyme)\n", " data_df[\"label\"].append(label)\n", " data_df[\"structure_index\"].append(index)\n", " data_df[\"positive_reactions\"].append(positive_reactions)\n", "\n", " data_df = pd.DataFrame(data_df)\n", " data_df.to_csv(f\"{data_root_dir}/data/small_family/{enzyme_tag}/{file_name}.csv\", sep=',', index=False)\n", "\n", " # random split\n", " import random\n", " random.shuffle(datas)\n", " random.shuffle(reactions)\n", " random.shuffle(enzymes)\n", "\n", " os.makedirs(f\"{data_root_dir}/data/small_family/{enzyme_tag}/random_split\", exist_ok=True)\n", " for i in range(4):\n", " training_datas = datas[:int(len(datas) * 0.25 * i)] + datas[int(len(datas) * 0.25 * (i + 1)):]\n", " \n", " testing_datas = datas[int(len(datas) * 0.25 * i):int(len(datas) * 0.25 * (i + 1))]\n", " val_datas = testing_datas[:int(len(testing_datas) * 0.3)]\n", " testing_datas = testing_datas[int(len(testing_datas) * 0.3):]\n", "\n", " save_data_csv(training_datas, f\"random_split/training_datas_{i}\")\n", " save_data_csv(val_datas, f\"random_split/val_datas_{i}\")\n", " save_data_csv(testing_datas, f\"random_split/testing_datas_{i}\")\n", " \n", " os.makedirs(f\"{data_root_dir}/data/small_family/{enzyme_tag}/reaction_split\", exist_ok=True)\n", " os.makedirs(f\"{data_root_dir}/data/small_family/{enzyme_tag}/enzyme_split\", exist_ok=True)\n", " os.makedirs(f\"{data_root_dir}/data/small_family/{enzyme_tag}/all_split\", exist_ok=True)\n", " for i in range(4):\n", " # enzyme\n", " training_enzymes = enzymes[:int(len(enzymes) * 0.25 * i)] + enzymes[int(len(enzymes) * 0.25 * (i + 1)):]\n", "\n", " testing_enzymes = enzymes[int(len(enzymes) * 0.25 * i):int(len(enzymes) * 0.25 * (i + 1))]\n", " val_enzymes = testing_enzymes[:int(len(testing_enzymes) * 0.3)]\n", " testing_enzymes = testing_enzymes[int(len(testing_enzymes) * 0.3):]\n", " if len(val_enzymes) == 0:\n", " val_enzymes = testing_enzymes[:2]\n", " testing_enzymes = testing_enzymes[2:]\n", "\n", " # substrate\n", " training_substrates = reactions[:int(len(reactions) * 0.25 * i)] + reactions[int(len(reactions) * 0.25 * (i + 1)):]\n", " \n", " testing_substrates = reactions[int(len(reactions) * 0.25 * i):int(len(reactions) * 0.25 * (i + 1))]\n", " val_substrates = testing_substrates[:int(len(testing_substrates) * 0.3)]\n", " testing_substrates = testing_substrates[int(len(testing_substrates) * 0.3):]\n", " if len(val_substrates) == 0:\n", " val_substrates = testing_substrates[:2]\n", " testing_substrates = testing_substrates[2:]\n", "\n", " save_data_csv(datas, f\"reaction_split/training_datas_{i}\", reaction_constraint=training_substrates)\n", " save_data_csv(datas, f\"reaction_split/val_datas_{i}\", reaction_constraint=val_substrates)\n", " save_data_csv(datas, f\"reaction_split/testing_datas_{i}\", reaction_constraint=testing_substrates)\n", " save_data_csv(datas, f\"enzyme_split/training_datas_{i}\", enzyme_constraint=training_enzymes)\n", " save_data_csv(datas, f\"enzyme_split/val_datas_{i}\", enzyme_constraint=val_enzymes)\n", " save_data_csv(datas, f\"enzyme_split/testing_datas_{i}\", enzyme_constraint=testing_enzymes)\n", " save_data_csv(datas, f\"all_split/training_datas_{i}\", reaction_constraint=training_substrates, enzyme_constraint=training_enzymes)\n", " save_data_csv(datas, f\"all_split/val_datas_{i}\", reaction_constraint=val_substrates, enzyme_constraint=val_enzymes)\n", " save_data_csv(datas, f\"all_split/testing_datas_{i}\", reaction_constraint=testing_substrates, enzyme_constraint=testing_enzymes)\n", "\n", "\n", " save_data_csv(datas, \"big_datas\")\n", " print(bad_cnt)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Structure" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Extract pocket" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "[16:16:40] Explicit valence for atom # 20 O, 3, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 2321\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[16:17:03] Explicit valence for atom # 25 O, 3, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 3035\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[16:17:03] Explicit valence for atom # 30 O, 3, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 3063\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[16:17:42] Explicit valence for atom # 32 O, 3, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 1524\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[16:18:48] Explicit valence for atom # 11 O, 3, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 2760\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[16:19:20] Explicit valence for atom # 8 O, 3, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 2752\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[16:20:18] Explicit valence for atom # 95 C, 5, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 3001\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[16:21:00] Explicit valence for atom # 42 O, 3, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 1266\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[16:21:44] Explicit valence for atom # 3 O, 3, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 1884\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[16:22:42] Explicit valence for atom # 7 O, 3, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 2204\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[16:24:11] Explicit valence for atom # 46 O, 3, is greater than permitted\n", "[16:24:11] Explicit valence for atom # 46 C, 5, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 2460\n", "Can't read 1360\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[16:25:47] Explicit valence for atom # 17 O, 3, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 3412\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[16:26:32] Explicit valence for atom # 8 O, 3, is greater than permitted\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Can't read 1487\n", "14\n" ] } ], "source": [ "from Bio.PDB import *\n", "from rdkit import Chem\n", "from tqdm import tqdm\n", "import glob\n", "import os\n", "\n", "root_dir = \"/projects/bbto/suyufeng/enzyme_specificity\"\n", "\n", "def distance(x1, y1, z1, x2, y2, z2):\n", " return (1. * (x2 - x1) ** 2 + 1. * (y2 - y1) ** 2 + 1. * (z2 - z1) ** 2) ** 0.5\n", "bad_molecular = 0\n", "mol = None\n", "# for enzyme_tag in [\"Duf\", \"Esterase\", \"Phosphatase\", \"Gt_acceptor\", \"Nitrilase\", \"Thiolase\"]:\n", "list = []\n", "\n", "for enzyme_tag in [\"2023_brenda\"]:\n", " for name in glob.glob(f\"{root_dir}/data/small_family/{enzyme_tag}/structure/af2/structure/*.pdb\"):\n", " id = int(name.split(\"/\")[-1].split(\".\")[0])\n", " os.makedirs(f\"{root_dir}/data/small_family/{enzyme_tag}/structure/af2/pocket\", exist_ok=True)\n", " os.makedirs(f\"{root_dir}/data/small_family/{enzyme_tag}/structure/af2/raw_ligand\", exist_ok=True)\n", " pocket_out_path = f\"{root_dir}/data/small_family/{enzyme_tag}/structure/af2/pocket/{id}.pdb\"\n", " ligand_out_path = f\"{root_dir}/data/small_family/{enzyme_tag}/structure/af2/raw_ligand/{id}.sdf\"\n", "\n", " if os.path.exists(pocket_out_path) and os.path.exists(ligand_out_path):\n", " continue\n", " lines = []\n", " ed = 0\n", " for index, line in enumerate(open(name, \"r\")):\n", " lines.append(line)\n", " if \"COMPND\" in line:\n", " ed = index\n", " \n", " protein_lines = lines[:ed]\n", " ligand_lines = lines[ed+1:]\n", " mol = Chem.MolFromPDBBlock(\"\".join(ligand_lines),\n", " sanitize=True,\n", " removeHs=False,\n", " flavor=8,\n", " proximityBonding=False)\n", " ligand_coords = []\n", " # mol = Chem.RemoveHs(mol, sanitize=False)\n", " try:\n", " for i, atom in enumerate(mol.GetAtoms()):\n", " positions = mol.GetConformer().GetAtomPosition(i)\n", " ligand_coords.append((positions.x, positions.y, positions.z))\n", " except:\n", " bad_molecular += 1\n", " list.append(id)\n", " print(f\"Can't read {id}\")\n", " continue\n", "\n", " try:\n", " writer = Chem.SDWriter(ligand_out_path)\n", " writer.write(mol, confId=0)\n", " except:\n", " print(f\"Can't save {id}\")\n", " bad_molecular += 1\n", " continue\n", "\n", " fin = open(pocket_out_path, \"w\")\n", "\n", " for line in protein_lines:\n", " if \"ATOM\" in line:\n", " try:\n", " x = float(line[30:38])\n", " y = float(line[38:46])\n", " z = float(line[46:54])\n", " for ligand_coord in ligand_coords:\n", " if 'H' not in line[12:16].strip() and distance(x, y, z, ligand_coord[0], ligand_coord[1], ligand_coord[2]) < 10:\n", " fin.write(line)\n", " break\n", " except:\n", " continue\n", " \n", " elif \"HETATM\" in line or \"ENDMDL\" in line:\n", " fin.write(line)\n", " fin.close()\n", " print(bad_molecular)\n", "\n", "import numpy as np\n", "list = np.array(list)\n", "np.savetxt(f\"bad_molecular.txt\", list)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "ename": "KeyboardInterrupt", "evalue": "", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[7], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mrdkit\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mChem\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m rdFMCS\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mrdkit\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mChem\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Draw\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mrdkit\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mChem\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m AllChem,rdDepictor\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mrdkit\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Chem\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpandas\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mpd\u001b[39;00m\n", "File \u001b[0;32m/projects/bcao/suyufeng/miniconda3/envs/specificity/lib/python3.10/site-packages/rdkit/Chem/AllChem.py:36\u001b[0m\n\u001b[1;32m 34\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mrdkit\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mChem\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mrdqueries\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;241m*\u001b[39m\n\u001b[1;32m 35\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mrdkit\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mChem\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mrdReducedGraphs\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;241m*\u001b[39m\n\u001b[0;32m---> 36\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mrdkit\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mChem\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mrdShapeHelpers\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;241m*\u001b[39m\n\u001b[1;32m 37\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mrdkit\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mGeometry\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m rdGeometry\n\u001b[1;32m 38\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mrdkit\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mRDLogger\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m logger\n", "\u001b[0;31mKeyboardInterrupt\u001b[0m: " ] } ], "source": [ "from rdkit.Chem import rdFMCS\n", "from rdkit.Chem import Draw\n", "from rdkit.Chem import AllChem,rdDepictor\n", "from rdkit import Chem\n", "import pandas as pd\n", "import glob\n", "from rdkit import RDLogger\n", "\n", "root_dir = \"/projects/bbto/suyufeng/enzyme_specificity\"\n", "\n", "def AssignBondOrdersFromTemplate(refmol, mol):\n", " \"\"\" assigns bond orders to a molecule based on the\n", " bond orders in a template molecule\n", " Revised from AllChem.AssignBondOrderFromTemplate(refmol, mol)\n", " \"\"\"\n", " AllChem.AssignBondOrdersFromTemplate\n", " refmol2 = Chem.rdchem.Mol(refmol)\n", " mol2 = Chem.rdchem.Mol(mol)\n", " # do the molecules match already?\n", " matching = mol2.GetSubstructMatch(refmol2)\n", " if not matching: # no, they don't match\n", " # check if bonds of mol are SINGLE\n", " for b in mol2.GetBonds():\n", " if b.GetBondType() != Chem.BondType.SINGLE:\n", " b.SetBondType(Chem.BondType.SINGLE)\n", " b.SetIsAromatic(False)\n", " # set the bonds of mol to SINGLE\n", " for b in refmol2.GetBonds():\n", " b.SetBondType(Chem.BondType.SINGLE)\n", " b.SetIsAromatic(False)\n", " # set atom charges to zero;\n", " for a in refmol2.GetAtoms():\n", " a.SetFormalCharge(0)\n", " for a in mol2.GetAtoms():\n", " a.SetFormalCharge(0)\n", "\n", " matching = mol2.GetSubstructMatches(refmol2, uniquify=False)\n", " # do the molecules match now?\n", " if matching:\n", " if len(matching) > 1:\n", " #logger.warning(\"More than one matching pattern found - picking one\")\n", " pass\n", " matchings=matching[:]\n", " for matching in matchings:\n", " #matching = matching[0] ## use each matching\n", " # apply matching: set bond properties\n", " for b in refmol.GetBonds():\n", " atom1 = matching[b.GetBeginAtomIdx()]\n", " atom2 = matching[b.GetEndAtomIdx()]\n", " b2 = mol2.GetBondBetweenAtoms(atom1, atom2)\n", " b2.SetBondType(b.GetBondType())\n", " b2.SetIsAromatic(b.GetIsAromatic())\n", " # apply matching: set atom properties\n", " for a in refmol.GetAtoms():\n", " a2 = mol2.GetAtomWithIdx(matching[a.GetIdx()])\n", " a2.SetHybridization(a.GetHybridization())\n", " a2.SetIsAromatic(a.GetIsAromatic())\n", " a2.SetNumExplicitHs(a.GetNumExplicitHs())\n", " a2.SetFormalCharge(a.GetFormalCharge())\n", " try:\n", " Chem.SanitizeMol(mol2)\n", " if hasattr(mol2, '__sssAtoms'):\n", " mol2.__sssAtoms = None # we don't want all bonds highlighted\n", " break\n", " except ValueError:\n", " pass\n", " # print(\"More than one matching pattern, Fail at this matching. Try next.\")\n", " else:\n", " raise ValueError(\"No matching found\")\n", " return mol2\n", "\n", "def alignment_number_system(sdf, smile_mol):\n", " \n", " template = smile_mol\n", " query = sdf\n", "\n", " mcs = rdFMCS.FindMCS([template, query], timeout=200)\n", " patt = Chem.MolFromSmarts(mcs.smartsString)\n", "\n", " query_match = query.GetSubstructMatch(patt)\n", " template_match = template.GetSubstructMatch(patt)\n", "\n", " result = [-1] * query.GetNumAtoms()\n", "\n", " for query_atom_id, template_atom_id in zip(query_match, template_match):\n", " result[query_atom_id] = template_atom_id\n", "\n", " # Check if there is any atom not matched\n", " for atom in query.GetAtoms():\n", " assert atom.GetAtomicNum() == 1 or result[atom.GetIdx()] != -1\n", "\n", " return result\n", "\n", "def assign_idx(mol, idxs):\n", " for atom, idx in zip(mol.GetAtoms(), idxs):\n", " atom.SetAtomMapNum(idx)\n", " return mol\n", "\n", "def mol_get_atomic_number(mol, atom_map=False):\n", " result = [0] * mol.GetNumAtoms()\n", " for atom in mol.GetAtoms():\n", " if atom.GetAtomMapNum() != -1:\n", " if atom_map:\n", " result[atom.GetAtomMapNum()] = atom.GetAtomicNum()\n", " else:\n", " result[atom.GetIdx()] = atom.GetAtomicNum()\n", " return result\n", "\n", "def check(mol, mol2):\n", " for atom in mol.GetAtoms():\n", " if atom.GetAtomMapNum() != -1:\n", " id = atom.GetAtomMapNum()\n", " \n", " atom2 = mol2.GetAtomWithIdx(id)\n", " if atom.GetAtomicNum() != atom2.GetAtomicNum():\n", " return False\n", " return True\n", "\n", "def view_difference(mol1, mol2):\n", " mcs = rdFMCS.FindMCS([mol1,mol2])\n", " mcs_mol = Chem.MolFromSmarts(mcs.smartsString)\n", " match1 = mol1.GetSubstructMatch(mcs_mol)\n", " target_atm1 = []\n", " for atom in mol1.GetAtoms():\n", " if atom.GetIdx() not in match1:\n", " target_atm1.append(atom.GetIdx())\n", " match2 = mol2.GetSubstructMatch(mcs_mol)\n", " target_atm2 = []\n", " for atom in mol2.GetAtoms():\n", " if atom.GetIdx() not in match2:\n", " target_atm2.append(atom.GetIdx())\n", " return Draw.MolsToGridImage([mol1, mol2],highlightAtomLists=[target_atm1, target_atm2])\n", "\n", "def single_match(item):\n", " id, smile = item\n", "\n", " sdf_path = f\"{root_dir}/data/small_family/{enzyme_tag}/structure/af2/raw_ligand/{id}.sdf\"\n", " RDLogger.DisableLog('rdApp.*')\n", "\n", " try:\n", " mol = next(iter(Chem.SDMolSupplier(sdf_path, sanitize=True)))\n", " mol = Chem.RemoveHs(mol)\n", " except Exception as e:\n", " try:\n", " mol = next(iter(Chem.SDMolSupplier(sdf_path, sanitize=False)))\n", " mol = Chem.RemoveHs(mol, sanitize=False)\n", " except Exception as e:\n", " return 1 \n", " # mol = Chem.MolFromSmiles(Chem.MolToSmiles(mol))\n", " smile = Chem.MolToSmiles(Chem.MolFromSmiles(smile))\n", " smile_mol = Chem.MolFromSmiles(smile)\n", " new_smile = Chem.MolToSmiles(mol)\n", "\n", " # print(mol_get_atomic_number(smile_mol))\n", " # print(len(smile_mol.GetAtoms()))\n", " try:\n", " aligned_idx = alignment_number_system(mol, smile_mol)\n", " except:\n", " \n", " try:\n", " mol = AssignBondOrdersFromTemplate(smile_mol, mol)\n", " except:\n", " print(f\"!!{id}!!\")\n", " print(smile)\n", " print(new_smile)\n", " return 1\n", " \n", " try:\n", " aligned_idx = alignment_number_system(mol, smile_mol)\n", " except:\n", " print(f\"!!{id}!!\")\n", " print(smile)\n", " print(new_smile)\n", " return 1\n", " mol = assign_idx(mol, aligned_idx)\n", " # print(mol_get_atomic_number(mol, atom_map=True))\n", " if not check(mol, smile_mol):\n", " print(f\"!!{id}!!\")\n", "\n", " w = Chem.SDWriter(f\"{root_dir}/data/small_family/{enzyme_tag}/structure/af2/ligand/{id}.sdf\")\n", " try:\n", " w.write(mol)\n", " w.close()\n", " except:\n", " w.close()\n", " return 1\n", " \n", " return 0\n", "\n", "def batched_match(ids):\n", " ans = 0\n", " for id in ids:\n", " ans += single_match(id)\n", " return ans\n", "\n", "from tqdm import tqdm\n", "from multiprocessing.pool import Pool\n", "\n", "import os\n", "mismatches = []\n", "\n", "\n", "# for enzyme_tag in [\"Duf\", \"Esterase\", \"Phosphatase\", \"Gt_acceptor\", \"Nitrilase\", \"Thiolase\"]:\n", "for enzyme_tag in [\"2023_brenda\"]:\n", " os.makedirs(f\"{root_dir}/data/small_family/{enzyme_tag}/structure/af2/ligand\", exist_ok=True)\n", "\n", " df = pd.read_csv(f\"{root_dir}/data/small_family/{enzyme_tag}/big_datas.csv\")\n", " sub_df = pd.read_csv(f\"{root_dir}/data/small_family/{enzyme_tag}/substrates.csv\", sep=',')\n", " sub_index_dict = {index: substrate_id for index, substrate_id in zip(df[\"structure_index\"].values, df[\"reaction\"].values)}\n", "\n", " bad_molecular = 0\n", "\n", " parameters = []\n", " for index, sdf_path in tqdm(enumerate(glob.glob(f\"{root_dir}/data/small_family/{enzyme_tag}/structure/af2/raw_ligand/*.sdf\"))):\n", " \n", " id = int(os.path.basename(sdf_path).split(\".\")[0])\n", " \n", " if id not in sub_index_dict:\n", " bad_molecular += 1\n", " continue\n", "\n", " substrate_id = sub_index_dict[id]\n", " original_smile = sub_df[\"substrates\"].values[substrate_id]\n", "\n", " parameters.append((id, original_smile))\n", " results = [parameters[i*50: (i+1)*50] for i in range(len(parameters) // 50)]\n", " bad_molecular = 0\n", "\n", " with Pool(120) as pool:\n", " for result in tqdm(pool.imap_unordered(batched_match, results)):\n", " bad_molecular += result\n", " \n", " # break\n", " print(bad_molecular)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3.7.13 ('revae')", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "ea8e2fe48c7ffefb1d2d9f58e61432847d99d21375144a203023aa806149d953" } } }, "nbformat": 4, "nbformat_minor": 2 }
Unknown
3D
antecede/EZSpecificity
Datasets/Specific_familty/halogenase.ipynb
.ipynb
30,465
706
{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import sys\n", "from collections import defaultdict\n", "import random\n", "\n", "root_dir = \"/projects/bbto/suyufeng/enzyme_specificity\"\n", "sys.path.append(f\"{root_dir}/src\")\n", "sys.path.append(f\"{root_dir}/src/other_softwares/hgraph2graph\")\n", "sys.path.append(f\"{root_dir}/src/other_softwares/grover_software\")\n", "gpu = 1\n", "\n", "# t = pd.read_csv(f\"{root_dir}/data/halogenase/datas.csv\", sep=',')\n", "# print(t['Substrate0'])\n", "# print(t[\"Product0\"])\n", "# print(t['Sequence'])\n", "# print(t['UniprotID'])" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Create enzyme embedding and vocabulary size \n", "1. esm2 embedding" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/work/yufeng/miniconda/envs/revae/lib/python3.7/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n", "100%|██████████| 383/383 [00:31<00:00, 11.99it/s]" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Save enzyme df\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "import lmdb\n", "import pickle\n", "import esm\n", "import torch\n", "from tqdm import tqdm\n", "import numpy as np\n", "\n", "letter_to_num = {'C': 4, 'D': 3, 'S': 15, 'Q': 5, 'K': 11, 'I': 9,\n", " 'P': 14, 'T': 16, 'F': 13, 'A': 0, 'G': 7, 'H': 8,\n", " 'E': 6, 'L': 10, 'R': 1, 'W': 17, 'V': 19, \n", " 'N': 2, 'Y': 18, 'M': 12, 'X': 20, 'Z': 21, 'U': 22, 'B': 23}\n", "save_lmdb_path = f\"{root_dir}/data/halogenase/enzyme_features.lmdb\"\n", "input_df_path = f\"{root_dir}/data/halogenase/datas.csv\"\n", "save_df_path = f\"{root_dir}/data/halogenase/enzymes.csv\"\n", "\n", "def convert_protein_sequence_to_number(protein_sequence):\n", " protein_number = []\n", " for i in protein_sequence:\n", " protein_number.append(letter_to_num[i])\n", " return np.array(protein_number)\n", "\n", "env = lmdb.open(\n", " save_lmdb_path,\n", " map_size=600*(1024*1024*1024), # 600GB\n", " create=True,\n", " subdir=False,\n", " readonly=False, # Writable\n", ")\n", "model, alphabet = esm.pretrained.esm2_t33_650M_UR50D()\n", "batch_converter = alphabet.get_batch_converter()\n", "model = model.to(torch.device(f\"cuda:{gpu}\"))\n", "\n", "df = pd.read_csv(input_df_path, sep=',')\n", "\n", "data = []\n", "sequence_dict = {}\n", "sequences = []\n", "uniprots = []\n", "ecnumbers = []\n", "\n", "# TODO: download sequence from uniprot\n", "for index, (sequence, uniprot, ecnumber) in enumerate(zip(df['Sequence'].values, df['UniprotID'].values, df['EC'].values)):\n", " # if len(sequence) > 1000:\n", " # continue\n", " if sequence in sequence_dict:\n", " continue\n", " if type(ecnumber) == float or '.' not in ecnumber:\n", " ecnumber = \"Other.\"\n", " sequences.append(sequence)\n", " uniprots.append(uniprot)\n", " ecnumbers.append(ecnumber)\n", " sequence_dict[sequence] = len(uniprots) - 1\n", " data.append((uniprot, sequence))\n", " \n", "for small_data in tqdm(data, total=len(data)):\n", " small_data = [small_data]\n", " atch_labels, batch_strs, batch_tokens = batch_converter(small_data)\n", " batch_tokens = batch_tokens.to(torch.device(f\"cuda:{gpu}\"))\n", " # Extract per-residue representations (on CPU)\n", " with torch.no_grad():\n", " results = model(batch_tokens, repr_layers=[33], return_contacts=True)\n", " token_representations = results[\"representations\"][33].cpu()\n", "\n", " # Generate per-sequence representations via averaging\n", " # NOTE: token 0 is always a beginning-of-sequence token, so the first residue is token 1.\n", " for i, (uniprot, seq) in enumerate(small_data):\n", " with env.begin(write=True, buffers=True) as txn:\n", " data = {\n", " 'embedding': token_representations[i, 1:1+len(seq)].detach().numpy(),\n", " 'sequence': convert_protein_sequence_to_number(seq)\n", " }\n", " txn.put(key=str(sequence_dict[seq]).encode(), value=pickle.dumps(data))\n", " \n", " batch_tokens = batch_tokens.to(torch.device(\"cpu\"))\n", "data = {\n", " \"sequences\": sequences,\n", " \"uniprots\": uniprots,\n", " \"ecnumbers\": ecnumbers\n", "}\n", "df = pd.DataFrame(data)\n", "df.to_csv(save_df_path, sep=',', index=False)\n", "print(\"Save enzyme df\")\n", " # break\n", "env.close()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Create substrate Features\n", "1. Our data input\n", "\n", " Check Datasets/create_features.py \"Create reaction features for halogenase\"\n", "2. Get Morgan fingerprint embedding" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from rdkit.Chem import AllChem, DataStructs\n", "import numpy as np\n", "\n", "df = pd.read_csv(f\"{root_dir}/data/halogenase/reactions.csv\", sep=',')\n", "results = []\n", "for substrate in df['substrates']:\n", " mol = AllChem.MolFromSmiles(substrate)\n", " fp = AllChem.GetMorganFingerprintAsBitVect(mol, 2, 1024)\n", " arr = np.zeros((0,), dtype=np.int8)\n", " DataStructs.ConvertToNumpyArray(fp,arr)\n", " results.append(arr)\n", "np.save(f\"{root_dir}/data/halogenase/morgan_embedding.npy\", np.array(results))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Create training samples" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "# 1. first to preprocess dataset\n", "quality_flag = False\n", "\n", "from rdkit import Chem\n", "\n", "def get_atom_diff(smile1, smile2):\n", "\n", " atomic_count = defaultdict(lambda : 0)\n", "\n", " for smile in smile1.split('.'):\n", " mol1 = Chem.MolFromSmiles(smile)\n", " for atom in mol1.GetAtoms():\n", " atomic_count[atom.GetAtomicNum()] += 1\n", " \n", " for smile in smile2.split('.'):\n", " mol2 = Chem.MolFromSmiles(smile)\n", " for atom in mol2.GetAtoms():\n", " atomic_count[atom.GetAtomicNum()] -= 1\n", " \n", " result = {}\n", " for key in atomic_count.keys():\n", " if atomic_count[key] != 0:\n", " result[key] = atomic_count[key]\n", " return result\n", "\n", "def check_valid(result):\n", " for key in result.keys():\n", " if key == 9 or key == 17 or key == 35 or key == 53 or key == 85:\n", " return True\n", " return False\n", "\n", "df = pd.read_csv(f\"{root_dir}/data/small_family/halogenase/data.csv\", sep=',')\n", "\n", "enzyme_df = pd.read_csv(f\"{root_dir}/data/small_family/halogenase/enzymes.csv\", sep=',')\n", "reaction_df = pd.read_csv(f\"{root_dir}/data/small_family/halogenase/reactions.csv\", sep=',')\n", "\n", "enzyme_dict = {enzyme: index for index, enzyme in enumerate(enzyme_df['sequences'].values)}\n", "reaction_dict = {reaction: index for index, reaction in enumerate(reaction_df['substrates'].values)}\n", "\n", "data = {\n", " \"substrate\": [],\n", " \"label\": [],\n", " \"cofactor\": [],\n", " \"sequence\": [],\n", " \"uniprot\": [],\n", " \"pdb\": [],\n", " \"reaction\": [],\n", " \"reactions\": []\n", "}\n", "\n", "cofactor_enzyme_dict = defaultdict(lambda : [])\n", "cofactor_reaction_dict = defaultdict(lambda : [])\n", "positive_sample_enzyme_dict = defaultdict(lambda : [])\n", "positive_sample_reaction_dict = defaultdict(lambda : [])\n", "enzyme_info_dict = defaultdict(lambda : [])\n", "\n", "# delete redundant data:\n", "# if (substrate, enzmye) appear several times in the dataset, we only keep one and its label is set as the (or among all labels)\n", "results = defaultdict(lambda : 0)\n", "\n", "for index, (substrate, enzyme, cofactor, product, pdb, uniprot, reaction) in enumerate(zip(df['Substrate0'].values, df['SEQ'].values, df['SubstrateCo'].values, df['Product0'].values, df['PDB'].values, df['Enzyme_ID'].values, df['ReactionInLine'].values)):\n", " if substrate in reaction_dict and enzyme in enzyme_dict:\n", " if quality_flag:\n", " if type(pdb) == float:\n", " continue\n", " \n", " label = int(check_valid(get_atom_diff(substrate, product)))\n", "\n", " if (substrate, enzyme) in results:\n", " if label == 1:\n", " results[(substrate, enzyme)][8].append(reaction)\n", " results[(substrate, enzyme)][:8] = [label, substrate, product, cofactor, enzyme, uniprot, pdb, reaction]\n", " else:\n", " if label == 1:\n", " results[(substrate, enzyme)] = [label, substrate, product, cofactor, enzyme, uniprot, pdb, reaction, [reaction]]\n", " else:\n", " results[(substrate, enzyme)] = [label, substrate, product, cofactor, enzyme, uniprot, pdb, reaction, []]\n", "\n", "for (substrate, enzyme), (label, substrate, product, cofactor, enzyme, uniprot, pdb, reaction, reactions) in results.items():\n", " data['label'].append(label)\n", " data['substrate'].append(substrate)\n", " data['cofactor'].append(cofactor)\n", " data['sequence'].append(enzyme)\n", " data['uniprot'].append(uniprot)\n", " data['pdb'].append(pdb)\n", " data['reaction'].append(reaction)\n", " data['reactions'].append(\"??\".join([str(reaction) for reaction in reactions]))\n", " \n", " cofactor_enzyme_dict[cofactor].append(enzyme)\n", " cofactor_reaction_dict[cofactor].append((substrate, reaction))\n", "\n", " enzyme_info_dict[enzyme] = (pdb, uniprot)\n", "\n", " if label == 1:\n", " positive_sample_enzyme_dict[enzyme].append(substrate)\n", " positive_sample_reaction_dict[substrate].append(enzyme)\n", "# print(positive_sample_reaction_dict[\"O=C1CCC(=O)C1\"])\n", "# print(cofactor_enzyme_dict[\"CC1=C8[N]3C(=C1CCC(=O)O)C=C2C(=C(C5=[N]2[Fe]34[N]7=C(C=C6N4C(=C5)C(=C6C)C=C)C(=C(C7=C8)C)C=C)C)CCC(=O)O\"])\n", "# cofactor = \"CC1=C8[N]3C(=C1CCC(=O)O)C=C2C(=C(C5=[N]2[Fe]34[N]7=C(C=C6N4C(=C5)C(=C6C)C=C)C(=C(C7=C8)C)C=C)C)CCC(=O)O\"\n", "# substrate = \"O=C1CCC(=O)C1\"\n", "# print(positive_sample_enzyme_dict[\"MFSKVLPFVGAVAALPHSVRQEPGSGIGYPYDNNTLPYVAPGPTDSRAPCPALNALANHGYIPHDGRAISRETLQNAFLNHMGIANSVIELALTNAFVVCEYVTGSDCGDSLVNLTLLAEPHAFEHDHSFSRKDYKQGVANSNDFIDNRNFDAETFQTSLDVVAGKTHFDYADMNEIRLQRESLSNELDFPGWFTESKPIQNVESGFIFALVSDFNLPDNDENPLVRIDWWKYWFTNESFPYHLGWHPPSPAREIEFVTSASSAVLAASVTSTPSSLPSGAIGPGAEAVPLSFASTMTPFLLATNAPYYAQDPTLGPNDKREAAPAATTSMAVFKNPYLEAIGTQDIKNQQAYVSSKAAAMASAMAANKARNL\"])\n" ] }, { "cell_type": "code", "execution_count": 75, "metadata": {}, "outputs": [], "source": [ "# generate the negative samples\n", "import random\n", "from copy import deepcopy\n", "n_negative_samples = 2\n", "\n", "raw_data = deepcopy(data)\n", "\n", "for index, (substrate, label, uniprot, enzyme, pdb, cofactor, reaction) in enumerate(zip(raw_data['substrate'], raw_data['label'], raw_data['uniprot'], raw_data['sequence'], raw_data['pdb'], raw_data['cofactor'], raw_data['reaction'])):\n", "\n", " # Don't create fake negative samples for real negative samples\n", " if label == 0:\n", " continue\n", "\n", " sample_vocabulary = [x for x in cofactor_enzyme_dict[cofactor] if x not in positive_sample_reaction_dict[substrate] and type(enzyme_info_dict[x][0]) != float]\n", " sample_vocabulary = list(set(sample_vocabulary))\n", " for fake_enzyme in random.choices(sample_vocabulary, k=min(n_negative_samples, len(sample_vocabulary))):\n", " data['substrate'].append(substrate)\n", " data['label'].append(2)\n", " data['cofactor'].append(cofactor)\n", " data['sequence'].append(fake_enzyme)\n", " data['uniprot'].append(enzyme_info_dict[fake_enzyme][1])\n", " data['pdb'].append(enzyme_info_dict[fake_enzyme][0])\n", " data['reaction'].append(reaction)\n", " data['reactions'].append(\"\")\n", "\n", "\n", " sample_vocabulary = [x for x in cofactor_reaction_dict[cofactor] if x[0] not in positive_sample_enzyme_dict[enzyme]]\n", " sample_vocabulary = list(set(sample_vocabulary))\n", " for (fake_substrate, fake_reaction) in random.choices(sample_vocabulary, k=min(n_negative_samples, len(sample_vocabulary))):\n", " data['substrate'].append(fake_substrate)\n", " data['label'].append(2)\n", " data['cofactor'].append(cofactor)\n", " data['sequence'].append(enzyme)\n", " data['uniprot'].append(enzyme_info_dict[enzyme][1])\n", " data['pdb'].append(enzyme_info_dict[enzyme][0])\n", " data['reaction'].append(fake_reaction)\n", " data['reactions'].append(\"\")\n", " # break\n", "\n", "data = pd.DataFrame(data)\n", "if quality_flag:\n", " data.to_csv(f\"{root_dir}/data/halogenase/raw_training_datas_quality.csv\", sep=',', index=False)\n", "else:\n", " data.to_csv(f\"{root_dir}/data/halogenase/raw_training_datas.csv\", sep=',', index=False)" ] }, { "cell_type": "code", "execution_count": 76, "metadata": {}, "outputs": [], "source": [ "# change enzyme and reaction id\n", "from collections import defaultdict\n", "if quality_flag:\n", " df = pd.read_csv(f\"{root_dir}/data/halogenase/raw_training_datas_quality.csv\", sep=',')\n", "else:\n", " df = pd.read_csv(f\"{root_dir}/data/halogenase/raw_training_datas.csv\", sep=',')\n", "enzyme_df = pd.read_csv(f\"{root_dir}/data/halogenase/enzymes.csv\", sep=',')\n", "reaction_df = pd.read_csv(f\"{root_dir}/data/halogenase/reactions.csv\", sep=',')\n", "enzyme_dict = {enzyme: index for index, enzyme in enumerate(enzyme_df['sequences'].values)}\n", "reaction_dict = {reaction: index for index, reaction in enumerate(reaction_df['reactions'].values)}\n", "\n", "data = defaultdict(lambda : [])\n", "for substrate,enzyme,label,cofactor, reaction, reactions in zip(df['substrate'].values,df['sequence'].values,df['label'].values,df['cofactor'].values, df['reaction'].values, df['reactions'].values):\n", " if reaction in reaction_dict and enzyme in enzyme_dict:\n", " data['reaction'].append(reaction_dict[reaction])\n", " data['enzyme'].append(enzyme_dict[enzyme])\n", " if type(reactions) != float:\n", " data['positive_reactions'].append(\",\".join([str(reaction_dict[reaction]) for reaction in reactions.split(\"??\")]))\n", " else:\n", " data['positive_reactions'].append(\"\")\n", " data['label'].append(label)\n", "data = pd.DataFrame(data)\n", "if quality_flag:\n", " data.to_csv(f\"{root_dir}/data/small_family/halogenase/training_datas_quality.csv\", sep=',', index=False)\n", "else:\n", " data.to_csv(f\"{root_dir}/data/small_family/halogenase/training_datas.csv\", sep=',', index=False)\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Delete conflict data and split training, testing" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import os\n", "def save_data_csv(data, file_name, reaction_constraint=None, enzyme_constraint=None):\n", " data_df = {\n", " \"reaction\": [],\n", " \"enzyme\": [],\n", " \"label\": [],\n", " \"structure_index\": [],\n", " \"positive_reactions\": []\n", " }\n", " if reaction_constraint is not None:\n", " substrate_dict = {substrate: 1 for substrate in reaction_constraint}\n", " else:\n", " substrate_dict = None\n", " if enzyme_constraint is not None:\n", " enzyme_dict = {enzyme: 1 for enzyme in enzyme_constraint}\n", " else:\n", " enzyme_dict = None\n", "\n", " for reaction, enzyme, label, index, positive_reactions in data:\n", " if substrate_dict is not None and reaction not in substrate_dict:\n", " continue\n", " if enzyme_dict is not None and enzyme not in enzyme_dict:\n", " continue\n", " data_df[\"reaction\"].append(reaction)\n", " data_df[\"enzyme\"].append(enzyme)\n", " data_df[\"label\"].append(label)\n", " data_df[\"structure_index\"].append(index)\n", " data_df[\"positive_reactions\"].append(positive_reactions)\n", "\n", " data_df = pd.DataFrame(data_df)\n", " data_df.to_csv(f\"{root_dir}/data/small_family/halogenase/{file_name}.csv\", sep=',', index=False)\n", "\n", "df = pd.read_csv(f\"{root_dir}/data/small_family/halogenase/training_datas.csv\", sep=',')\n", "data = defaultdict(lambda : 0)\n", "for index, (reaction, enzyme, label, reactions) in enumerate(zip(df['reaction'], df['enzyme'], df['label'], df['positive_reactions'])):\n", " if (reaction, enzyme) in data and data[(reaction, enzyme)][0] == 1:\n", " print(reaction, enzyme)\n", " if label == 1:\n", " data[(reaction, enzyme)] = (1, index, reactions)\n", " else:\n", " data[(reaction, enzyme)] = (0, index, reactions)\n", "datas = [(reaction, enzyme, label, index, reactions) for (reaction, enzyme), (label, index, reactions) in data.items()]\n", "reactions = list(set([a[0] for a in datas]))\n", "enzymes = list(set([a[1] for a in datas]))\n", "random.shuffle(datas)\n", "random.shuffle(reactions)\n", "random.shuffle(enzymes)\n", "\n", "os.makedirs(f\"{root_dir}/data/small_family/halogenase/random_split\", exist_ok=True)\n", "os.makedirs(f\"{root_dir}/data/small_family/halogenase/reaction_split\", exist_ok=True)\n", "os.makedirs(f\"{root_dir}/data/small_family/halogenase/enzyme_split\", exist_ok=True)\n", "os.makedirs(f\"{root_dir}/data/small_family/halogenase/all_split\", exist_ok=True)\n", "\n", "# random split\n", "for i in range(4):\n", " training_datas = datas[:int(len(datas) * 0.25 * i)] + datas[int(len(datas) * 0.25 * (i + 1)):]\n", " \n", " testing_datas = datas[int(len(datas) * 0.25 * i):int(len(datas) * 0.25 * (i + 1))]\n", " val_datas = testing_datas[:int(len(testing_datas) * 0.3)]\n", " testing_datas = testing_datas[int(len(testing_datas) * 0.3):]\n", "\n", " save_data_csv(training_datas, f\"random_split/training_datas_{i}\")\n", " save_data_csv(val_datas, f\"random_split/val_datas_{i}\")\n", " save_data_csv(testing_datas, f\"random_split/testing_datas_{i}\")\n", " \n", "# reaction split\n", "for i in range(4):\n", " training_reaction = reactions[:int(len(reactions) * 0.25 * i)] + reactions[int(len(reactions) * 0.25 * (i + 1)):]\n", " \n", " testing_reaction = reactions[int(len(reactions) * 0.25 * i):int(len(reactions) * 0.25 * (i + 1))]\n", " val_reaction = testing_reaction[:int(len(testing_reaction) * 0.3)]\n", " testing_reaction = testing_reaction[int(len(testing_reaction) * 0.3):]\n", "\n", " training_enzymes = enzymes[:int(len(enzymes) * 0.25 * i)] + enzymes[int(len(enzymes) * 0.25 * (i + 1)):]\n", "\n", " testing_enzymes = enzymes[int(len(enzymes) * 0.25 * i):int(len(enzymes) * 0.25 * (i + 1))]\n", " val_enzymes = testing_enzymes[:int(len(testing_enzymes) * 0.3)]\n", " testing_enzymes = testing_enzymes[int(len(testing_enzymes) * 0.3):]\n", "\n", " save_data_csv(datas, f\"reaction_split/training_datas_{i}\", reaction_constraint=training_reaction)\n", " save_data_csv(datas, f\"reaction_split/val_datas_{i}\", reaction_constraint=val_reaction)\n", " save_data_csv(datas, f\"reaction_split/testing_datas_{i}\", reaction_constraint=testing_reaction)\n", "\n", " save_data_csv(datas, f\"enzyme_split/training_datas_{i}\", enzyme_constraint=training_enzymes)\n", " save_data_csv(datas, f\"enzyme_split/val_datas_{i}\", enzyme_constraint=val_enzymes)\n", " save_data_csv(datas, f\"enzyme_split/testing_datas_{i}\", enzyme_constraint=testing_enzymes)\n", " save_data_csv(datas, f\"all_split/training_datas_{i}\", reaction_constraint=training_reaction, enzyme_constraint=training_enzymes)\n", " save_data_csv(datas, f\"all_split/val_datas_{i}\", reaction_constraint=val_reaction, enzyme_constraint=val_enzymes)\n", " save_data_csv(datas, f\"all_split/testing_datas_{i}\", reaction_constraint=testing_reaction, enzyme_constraint=testing_enzymes)\n", "\n", "save_data_csv(datas, \"big_datas\")\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Select relevant datapoint and create negative samples" ] }, { "cell_type": "code", "execution_count": 78, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/work/yufeng/miniconda/envs/revae/lib/python3.7/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n", "100%|██████████| 64124/64124 [00:01<00:00, 47975.21it/s]\n" ] } ], "source": [ "from Datasets.utils import generate_negative_sample\n", "from easydict import EasyDict\n", "ecnumbers = [\"1.11.1.10\", \"1.11.1.-\", \"1.11.1.18\", \"1.14.19.9\", \"1.14.14.-\",\"1.14.19.56\", \"1.14.19.-\", \"1.14.99.-\", \"1.14.19.49\", \"3.8.1.1\", \"1.14.20.-\", \"2.5.1.94\", \"2.2.1.6\", \"2.5.1.63\", \"3.13.1.8\", \"2.5.1.-\"]\n", "n_digit = 0\n", "config = {\n", " \"data\": {\n", " \"sampling\": {\n", " \"same_digits\": 0,\n", " \"num_negative_enzyme\": 2\n", " }\n", " }\n", "}\n", "config = EasyDict(config)\n", "\n", "def get_number_same_digits(ecnumber1, ecnumber2):\n", " ecnumber_digits1 = ecnumber1.split(\".\")\n", " ecnumber_digits2 = ecnumber2.split(\".\")\n", " for index, (digit1, digit2) in enumerate(zip(ecnumber_digits1, ecnumber_digits2)):\n", " if digit1 == '-' or digit2 == '-':\n", " continue\n", " if digit1 != digit2:\n", " return index\n", " return 4\n", "\n", "df = pd.read_csv(f\"{root_dir}/data/positive_data.csv\", sep=',')\n", "\n", "drop_indexs = []\n", "for index, ecnumber in enumerate(df['ecnumber']):\n", " flag = False\n", " for ecnumber in ecnumbers:\n", " if get_number_same_digits(ecnumber, df['ecnumber'][index]) >= n_digit:\n", " flag = True\n", " break\n", " if not flag:\n", " drop_indexs.append(index)\n", "df = df.drop(drop_indexs).reset_index(drop=True)\n", "df = generate_negative_sample(config, df)\n", "df.to_csv(f\"{root_dir}/data/halogenase/brenda_positive_data_{n_digit}.csv\", sep=',', index=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Create grover embedding" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "# 1. Tou Tou is going to create smile only csv\n", "import pandas as pd\n", "import os\n", "\n", "df = pd.read_csv(f\"{root_dir}/data/small_family/halogenase/reactions.csv\", sep=',')\n", "results = [smile for smile in df['substrates']]\n", "data = {\n", " \"substrates\": results\n", "}\n", "data = pd.DataFrame(data)\n", "data.to_csv(f\"{root_dir}/data/small_family/halogenase/substrates.csv\", index=False)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "python /projects/bbto/suyufeng/enzyme_specificity/src/other_softwares/grover_software/scripts/save_features.py --data_path /projects/bbto/suyufeng/enzyme_specificity/data/small_family/halogenase/substrates.csv --save_path /projects/bbto/suyufeng/enzyme_specificity/data/small_family/halogenase/substrates.npz --features_generator fgtasklabel --restart\n" ] } ], "source": [ "# 2. Get npz feature\n", "print(f\"python {root_dir}/src/other_softwares/grover_software/scripts/save_features.py --data_path {root_dir}/data/small_family/halogenase/substrates.csv \\\n", " --save_path {root_dir}/data/small_family/halogenase/substrates.npz \\\n", " --features_generator fgtasklabel \\\n", " --restart\")" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "python /projects/bbto/suyufeng/enzyme_specificity/src/other_softwares/grover_software/scripts/build_vocab.py --data_path /projects/bbto/suyufeng/enzyme_specificity/data/small_family/halogenase/substrates.csv --vocab_save_folder /projects/bbto/suyufeng/enzyme_specificity/data/small_family/halogenase/grover_vocab --dataset_name halogenase\n" ] } ], "source": [ "# 3. Get build vocab\n", "print(f\"python {root_dir}/src/other_softwares/grover_software/scripts/build_vocab.py --data_path {root_dir}/data/small_family/halogenase/substrates.csv \\\n", " --vocab_save_folder {root_dir}/data/small_family/halogenase/grover_vocab \\\n", " --dataset_name halogenase\")\n" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CUDA_VISIBLE_DEVICES=0 python main.py fingerprint --data_path /projects/bbto/suyufeng/enzyme_specificity/data/small_family/halogenase/substrates.csv --features_path /projects/bbto/suyufeng/enzyme_specificity/data/small_family/halogenase/substrates.npz --checkpoint_path /projects/bbto/suyufeng/enzyme_specificity/data/pretrain_model/grover_large.pt --fingerprint_source both --output /projects/bbto/suyufeng/enzyme_specificity/data/small_family/halogenase/fingerprint.npz --save_lmdb_path /projects/bbto/suyufeng/enzyme_specificity/data/small_family/halogenase/grover_fingerprint.lmdb --fingerprint_source both\n" ] } ], "source": [ "# 4. Get fingerprint\n", "print(f\"CUDA_VISIBLE_DEVICES=0 python main.py fingerprint --data_path {root_dir}/data/small_family/halogenase/substrates.csv --features_path {root_dir}/data/small_family/halogenase/substrates.npz --checkpoint_path {root_dir}/data/pretrain_model/grover_large.pt --fingerprint_source both --output {root_dir}/data/small_family/halogenase/fingerprint.npz --save_lmdb_path {root_dir}/data/small_family/halogenase/grover_fingerprint.lmdb --fingerprint_source both\")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Create morgan fingerprint" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "from rdkit.Chem import AllChem\n", "from rdkit import Chem\n", "import numpy as np\n", "path = f\"{root_dir}/data/small_family/halogenase/substrates.csv\"\n", "df = pd.read_csv(path, sep=',')\n", "results = []\n", "for smile in df['substrates']:\n", " m1 = Chem.MolFromSmiles(smile)\n", " result = np.array(AllChem.GetMorganFingerprintAsBitVect(m1,2,nBits=1024))\n", " results.append(result)\n", "np.save(f\"{root_dir}/data/small_family/halogenase/morgan_fingerprint.npy\", np.array(results))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3.7.13 ('revae')", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "ea8e2fe48c7ffefb1d2d9f58e61432847d99d21375144a203023aa806149d953" } } }, "nbformat": 4, "nbformat_minor": 2 }
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
Panel.cpp
.cpp
4,770
216
#include "StdAfx.h" #include "Panel.h" #include "Histogram.h" #include "Resource.h" #include "MainFrm.h" #include "DICOM ViewerDoc.h" BEGIN_MESSAGE_MAP(CPanel, CDockablePane) ON_WM_PAINT() ON_WM_SIZE() ON_WM_ERASEBKGND() ON_WM_MOUSEMOVE() ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_CREATE() ON_WM_DESTROY() ON_BN_CLICKED(IDC_SEG, &CPanel::OnBnClickedSeg) ON_BN_CLICKED(IDC_RESET, &CPanel::OnBnClickedReset) END_MESSAGE_MAP() CPanel::CPanel(void) { m_pannel_mode = PANEL_NONE; } CPanel::~CPanel(void) { } void CPanel::OnPaint() { CPaintDC dc(this); m_HistoDlg.OnPaint(); m_SpectDlg.OnPaint(); } void CPanel::OnSize(UINT nType, int cx, int cy) { //CDockablePane::OnSize(nType, cx, cy); CRect rc1; CRect rc2; CRect rc_sum; m_HistoDlg.GetClientRect(&rc1); m_SpectDlg.GetClientRect(&rc2); rc_sum.left = min(rc1.left, rc2.left); rc_sum.right = max(rc1.right,rc2.right); rc_sum.top = min(rc1.top, rc2.top); rc_sum.bottom = max(rc1.bottom,rc2.bottom); CDockablePane::OnSize(nType, rc_sum.right - rc_sum.left, rc_sum.bottom - rc_sum.top); // TODO: ¿©±â¿¡ ¸Þ½ÃÁö 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù. //AdjustWindowRect(&rc_sum,WS_OVERLAPPED,FALSE); m_HistoDlg.MoveWindow(0,0,300,400); m_SpectDlg.MoveWindow(0,400,300,300); } BOOL CPanel::OnEraseBkgnd(CDC* pDC) { // TODO: ¿©±â¿¡ ¸Þ½ÃÁö 󸮱â Äڵ带 Ãß°¡ ¹×/¶Ç´Â ±âº»°ªÀ» È£ÃâÇÕ´Ï´Ù. CBrush backBrush(RGB(255, 255, 255)); // <- Èò»öÄ®·¯·Î. CBrush* pOldBrush = pDC->SelectObject(&backBrush); CRect rect; GetClientRect(&rect); pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY); pDC->SelectObject(pOldBrush); return CDockablePane::OnEraseBkgnd(pDC); } void CPanel::OnMouseMove(UINT nFlags, CPoint point) { // TODO: ¿©±â¿¡ ¸Þ½ÃÁö 󸮱â Äڵ带 Ãß°¡ ¹×/¶Ç´Â ±âº»°ªÀ» È£ÃâÇÕ´Ï´Ù. m_HistoDlg.OnMouseMove(nFlags, point); m_SpectDlg.OnMouseMove(nFlags, point); CDockablePane::OnMouseMove(nFlags, point); } void CPanel::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: ¿©±â¿¡ ¸Þ½ÃÁö 󸮱â Äڵ带 Ãß°¡ ¹×/¶Ç´Â ±âº»°ªÀ» È£ÃâÇÕ´Ï´Ù. m_HistoDlg.OnLButtonDown(nFlags, point); m_SpectDlg.OnLButtonDown(nFlags, point); CDockablePane::OnLButtonDown(nFlags, point); } void CPanel::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: ¿©±â¿¡ ¸Þ½ÃÁö 󸮱â Äڵ带 Ãß°¡ ¹×/¶Ç´Â ±âº»°ªÀ» È£ÃâÇÕ´Ï´Ù. m_HistoDlg.OnLButtonUp(nFlags,point); m_SpectDlg.OnLButtonUp(nFlags, point); CDockablePane::OnLButtonUp(nFlags, point); } int CPanel::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDockablePane::OnCreate(lpCreateStruct) == -1) return -1; // TODO: ¿©±â¿¡ Ư¼öÈ­µÈ ÀÛ¼º Äڵ带 Ãß°¡ÇÕ´Ï´Ù. BOOL bRet = m_HistoDlg.Create(IDD_HISTOGRAM, this); ASSERT( bRet ); bRet = m_SpectDlg.Create(IDD_SPECTRUM, this); ASSERT( bRet ); btn_seg.Create(L"seg",BS_DEFPUSHBUTTON,CRect(0,0,100,30),this,100); btn_reset.Create(L"reset",BS_DEFPUSHBUTTON,CRect(0,50,100,30),this,101); return 0; } void CPanel::OnDestroy() { CDockablePane::OnDestroy(); } void CPanel::OnThreshold() { CDICOMViewerDoc* pDoc = (CDICOMViewerDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument(); if(!pDoc) return; pDoc->m_SegMode = THRESHOLD; m_HistoDlg.ShowWindow(SW_SHOW); m_SpectDlg.ShowWindow(SW_SHOW); } void CPanel::OnAThreshold() { CDICOMViewerDoc* pDoc = (CDICOMViewerDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument(); if(!pDoc) return; pDoc->m_SegMode = ATHRESHOLD; m_HistoDlg.ShowWindow(SW_SHOW); } void CPanel::OnGraphCut() { CDICOMViewerDoc* pDoc = (CDICOMViewerDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument(); if(!pDoc) return; pDoc->m_SegMode = GRAPHCUT; m_HistoDlg.ShowWindow(SW_SHOW); } void CPanel::OnDynamicRegionGrowing() { CDICOMViewerDoc* pDoc = (CDICOMViewerDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument(); if(!pDoc) return; pDoc->m_SegMode = DYNAMICREGIONGROWING; m_HistoDlg.ShowWindow(SW_HIDE); } void CPanel::OnLevelSet2D() { CDICOMViewerDoc* pDoc = (CDICOMViewerDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument(); if(!pDoc) return; pDoc->m_SegMode = LEVELSET_2D; m_HistoDlg.ShowWindow(SW_HIDE); } void CPanel::OnLevelSet3D() { CDICOMViewerDoc* pDoc = (CDICOMViewerDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument(); if(!pDoc) return; pDoc->m_SegMode = LEVELSET_3D; m_HistoDlg.ShowWindow(SW_HIDE); } void CPanel::OnBnClickedSeg() { // TODO: ¿©±â¿¡ ÄÁÆ®·Ñ ¾Ë¸² 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù. ((CMainFrame *)AfxGetMainWnd())->OnButtonSeg(); } void CPanel::OnBnClickedReset() { // TODO: ¿©±â¿¡ ÄÁÆ®·Ñ ¾Ë¸² 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù. }
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
graph.h
.h
17,233
507
/* graph.h */ /* This software library implements the maxflow algorithm described in "An Experimental Comparison of Min-Cut/Max-Flow Algorithms for Energy Minimization in Vision." Yuri Boykov and Vladimir Kolmogorov. In IEEE Transactions on Pattern Analysis and Machine Intelligence (PAMI), September 2004 This algorithm was developed by Yuri Boykov and Vladimir Kolmogorov at Siemens Corporate Research. To make it available for public use, it was later reimplemented by Vladimir Kolmogorov based on open publications. If you use this software for research purposes, you should cite the aforementioned paper in any resulting publication. ---------------------------------------------------------------------- REUSING TREES: Starting with version 3.0, there is a also an option of reusing search trees from one maxflow computation to the next, as described in "Efficiently Solving Dynamic Markov Random Fields Using Graph Cuts." Pushmeet Kohli and Philip H.S. Torr International Conference on Computer Vision (ICCV), 2005 If you use this option, you should cite the aforementioned paper in any resulting publication. */ /* For description, license, example usage see README.TXT. */ #ifndef __GRAPH_H__ #define __GRAPH_H__ #include <string.h> #include "block.h" #include <assert.h> // NOTE: in UNIX you need to use -DNDEBUG preprocessor option to supress assert's!!! // captype: type of edge capacities (excluding t-links) // tcaptype: type of t-links (edges between nodes and terminals) // flowtype: type of total flow // // Current instantiations are in instances.inc template <typename captype, typename tcaptype, typename flowtype> class Graph { public: typedef enum { SOURCE = 0, SINK = 1 } termtype; // terminals typedef int node_id; ///////////////////////////////////////////////////////////////////////// // BASIC INTERFACE FUNCTIONS // // (should be enough for most applications) // ///////////////////////////////////////////////////////////////////////// // Constructor. // The first argument gives an estimate of the maximum number of nodes that can be added // to the graph, and the second argument is an estimate of the maximum number of edges. // The last (optional) argument is the pointer to the function which will be called // if an error occurs; an error message is passed to this function. // If this argument is omitted, exit(1) will be called. // // IMPORTANT: It is possible to add more nodes to the graph than node_num_max // (and node_num_max can be zero). However, if the count is exceeded, then // the internal memory is reallocated (increased by 50%) which is expensive. // Also, temporarily the amount of allocated memory would be more than twice than needed. // Similarly for edges. // If you wish to avoid this overhead, you can download version 2.2, where nodes and edges are stored in blocks. Graph(int node_num_max, int edge_num_max, void (*err_function)(char *) = NULL); // Destructor ~Graph(); // Adds node(s) to the graph. By default, one node is added (num=1); then first call returns 0, second call returns 1, and so on. // If num>1, then several nodes are added, and node_id of the first one is returned. // IMPORTANT: see note about the constructor node_id add_node(int num = 1); // Adds a bidirectional edge between 'i' and 'j' with the weights 'cap' and 'rev_cap'. // IMPORTANT: see note about the constructor void add_edge(node_id i, node_id j, captype cap, captype rev_cap); // Adds new edges 'SOURCE->i' and 'i->SINK' with corresponding weights. // Can be called multiple times for each node. // Weights can be negative. // NOTE: the number of such edges is not counted in edge_num_max. // No internal memory is allocated by this call. void add_tweights(node_id i, tcaptype cap_source, tcaptype cap_sink); // Computes the maxflow. Can be called several times. // FOR DESCRIPTION OF reuse_trees, SEE mark_node(). // FOR DESCRIPTION OF changed_list, SEE remove_from_changed_list(). flowtype maxflow(bool reuse_trees = false, Block<node_id>* changed_list = NULL); // After the maxflow is computed, this function returns to which // segment the node 'i' belongs (Graph<captype,tcaptype,flowtype>::SOURCE or Graph<captype,tcaptype,flowtype>::SINK). // // Occasionally there may be several minimum cuts. If a node can be assigned // to both the source and the sink, then default_segm is returned. termtype what_segment(node_id i, termtype default_segm = SOURCE); ////////////////////////////////////////////// // ADVANCED INTERFACE FUNCTIONS // // (provide access to the graph) // ////////////////////////////////////////////// private: struct node; struct arc; public: //////////////////////////// // 1. Reallocating graph. // //////////////////////////// // Removes all nodes and edges. // After that functions add_node() and add_edge() must be called again. // // Advantage compared to deleting Graph and allocating it again: // no calls to delete/new (which could be quite slow). // // If the graph structure stays the same, then an alternative // is to go through all nodes/edges and set new residual capacities // (see functions below). void reset(); //////////////////////////////////////////////////////////////////////////////// // 2. Functions for getting pointers to arcs and for reading graph structure. // // NOTE: adding new arcs may invalidate these pointers (if reallocation // // happens). So it's best not to add arcs while reading graph structure. // //////////////////////////////////////////////////////////////////////////////// // The following two functions return arcs in the same order that they // were added to the graph. NOTE: for each call add_edge(i,j,cap,cap_rev) // the first arc returned will be i->j, and the second j->i. // If there are no more arcs, then the function can still be called, but // the returned arc_id is undetermined. typedef arc* arc_id; arc_id get_first_arc(); arc_id get_next_arc(arc_id a); // other functions for reading graph structure int get_node_num() { return node_num; } int get_arc_num() { return (int)(arc_last - arcs); } void get_arc_ends(arc_id a, node_id& i, node_id& j); // returns i,j to that a = i->j /////////////////////////////////////////////////// // 3. Functions for reading residual capacities. // /////////////////////////////////////////////////// // returns residual capacity of SOURCE->i minus residual capacity of i->SINK tcaptype get_trcap(node_id i); // returns residual capacity of arc a captype get_rcap(arc* a); ///////////////////////////////////////////////////////////////// // 4. Functions for setting residual capacities. // // NOTE: If these functions are used, the value of the flow // // returned by maxflow() will not be valid! // ///////////////////////////////////////////////////////////////// void set_trcap(node_id i, tcaptype trcap); void set_rcap(arc* a, captype rcap); //////////////////////////////////////////////////////////////////// // 5. Functions related to reusing trees & list of changed nodes. // //////////////////////////////////////////////////////////////////// // If flag reuse_trees is true while calling maxflow(), then search trees // are reused from previous maxflow computation. // In this case before calling maxflow() the user must // specify which parts of the graph have changed by calling mark_node(): // add_tweights(i),set_trcap(i) => call mark_node(i) // add_edge(i,j),set_rcap(a) => call mark_node(i); mark_node(j) // // This option makes sense only if a small part of the graph is changed. // The initialization procedure goes only through marked nodes then. // // mark_node(i) can either be called before or after graph modification. // Can be called more than once per node, but calls after the first one // do not have any effect. // // NOTE: // - This option cannot be used in the first call to maxflow(). // - It is not necessary to call mark_node() if the change is ``not essential'', // i.e. sign(trcap) is preserved for a node and zero/nonzero status is preserved for an arc. // - To check that you marked all necessary nodes, you can call maxflow(false) after calling maxflow(true). // If everything is correct, the two calls must return the same value of flow. (Useful for debugging). void mark_node(node_id i); // If changed_list is not NULL while calling maxflow(), then the algorithm // keeps a list of nodes which could potentially have changed their segmentation label. // Nodes which are not in the list are guaranteed to keep their old segmentation label (SOURCE or SINK). // Example usage: // // typedef Graph<int,int,int> G; // G* g = new Graph(nodeNum, edgeNum); // Block<G::node_id>* changed_list = new Block<G::node_id>(128); // // ... // add nodes and edges // // g->maxflow(); // first call should be without arguments // for (int iter=0; iter<10; iter++) // { // ... // change graph, call mark_node() accordingly // // g->maxflow(true, changed_list); // G::node_id* ptr; // for (ptr=changed_list->ScanFirst(); ptr; ptr=changed_list->ScanNext()) // { // G::node_id i = *ptr; assert(i>=0 && i<nodeNum); // g->remove_from_changed_list(i); // // do something with node i... // if (g->what_segment(i) == G::SOURCE) { ... } // } // changed_list->Reset(); // } // delete changed_list; // // NOTE: // - If changed_list option is used, then reuse_trees must be used as well. // - In the example above, the user may omit calls g->remove_from_changed_list(i) and changed_list->Reset() in a given iteration. // Then during the next call to maxflow(true, &changed_list) new nodes will be added to changed_list. // - If the next call to maxflow() does not use option reuse_trees, then calling remove_from_changed_list() // is not necessary. ("changed_list->Reset()" or "delete changed_list" should still be called, though). void remove_from_changed_list(node_id i) { assert(i>=0 && i<node_num && nodes[i].is_in_changed_list); nodes[i].is_in_changed_list = 0; } ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// private: // internal variables and functions struct node { arc *first; // first outcoming arc arc *parent; // node's parent node *next; // pointer to the next active node // (or to itself if it is the last node in the list) int TS; // timestamp showing when DIST was computed int DIST; // distance to the terminal int is_sink : 1; // flag showing whether the node is in the source or in the sink tree (if parent!=NULL) int is_marked : 1; // set by mark_node() int is_in_changed_list : 1; // set by maxflow if tcaptype tr_cap; // if tr_cap > 0 then tr_cap is residual capacity of the arc SOURCE->node // otherwise -tr_cap is residual capacity of the arc node->SINK }; struct arc { node *head; // node the arc points to arc *next; // next arc with the same originating node arc *sister; // reverse arc captype r_cap; // residual capacity }; struct nodeptr { node *ptr; nodeptr *next; }; static const int NODEPTR_BLOCK_SIZE = 128; node *nodes, *node_last, *node_max; // node_last = nodes+node_num, node_max = nodes+node_num_max; arc *arcs, *arc_last, *arc_max; // arc_last = arcs+2*edge_num, arc_max = arcs+2*edge_num_max; int node_num; DBlock<nodeptr> *nodeptr_block; void (*error_function)(char *); // this function is called if a error occurs, // with a corresponding error message // (or exit(1) is called if it's NULL) flowtype flow; // total flow // reusing trees & list of changed pixels int maxflow_iteration; // counter Block<node_id> *changed_list; ///////////////////////////////////////////////////////////////////////// node *queue_first[2], *queue_last[2]; // list of active nodes nodeptr *orphan_first, *orphan_last; // list of pointers to orphans int TIME; // monotonically increasing global counter ///////////////////////////////////////////////////////////////////////// void reallocate_nodes(int num); // num is the number of new nodes void reallocate_arcs(); // functions for processing active list void set_active(node *i); node *next_active(); // functions for processing orphans list void set_orphan_front(node* i); // add to the beginning of the list void set_orphan_rear(node* i); // add to the end of the list void add_to_changed_list(node* i); void maxflow_init(); // called if reuse_trees == false void maxflow_reuse_trees_init(); // called if reuse_trees == true void augment(arc *middle_arc); void process_source_orphan(node *i); void process_sink_orphan(node *i); void test_consistency(node* current_node=NULL); // debug function }; /////////////////////////////////////// // Implementation - inline functions // /////////////////////////////////////// template <typename captype, typename tcaptype, typename flowtype> inline typename Graph<captype,tcaptype,flowtype>::node_id Graph<captype,tcaptype,flowtype>::add_node(int num) { assert(num > 0); if (node_last + num > node_max) reallocate_nodes(num); if (num == 1) { node_last -> first = NULL; node_last -> tr_cap = 0; node_last -> is_marked = 0; node_last -> is_in_changed_list = 0; node_last ++; return node_num ++; } else { memset(node_last, 0, num*sizeof(node)); node_id i = node_num; node_num += num; node_last += num; return i; } } template <typename captype, typename tcaptype, typename flowtype> inline void Graph<captype,tcaptype,flowtype>::add_tweights(node_id i, tcaptype cap_source, tcaptype cap_sink) { assert(i >= 0 && i < node_num); tcaptype delta = nodes[i].tr_cap; if (delta > 0) cap_source += delta; else cap_sink -= delta; flow += (cap_source < cap_sink) ? cap_source : cap_sink; nodes[i].tr_cap = cap_source - cap_sink; } template <typename captype, typename tcaptype, typename flowtype> inline void Graph<captype,tcaptype,flowtype>::add_edge(node_id _i, node_id _j, captype cap, captype rev_cap) { assert(_i >= 0 && _i < node_num); assert(_j >= 0 && _j < node_num); assert(_i != _j); assert(cap >= 0); assert(rev_cap >= 0); if (arc_last == arc_max) reallocate_arcs(); arc *a = arc_last ++; arc *a_rev = arc_last ++; node* i = nodes + _i; node* j = nodes + _j; a -> sister = a_rev; a_rev -> sister = a; a -> next = i -> first; i -> first = a; a_rev -> next = j -> first; j -> first = a_rev; a -> head = j; a_rev -> head = i; a -> r_cap = cap; a_rev -> r_cap = rev_cap; } template <typename captype, typename tcaptype, typename flowtype> inline typename Graph<captype,tcaptype,flowtype>::arc* Graph<captype,tcaptype,flowtype>::get_first_arc() { return arcs; } template <typename captype, typename tcaptype, typename flowtype> inline typename Graph<captype,tcaptype,flowtype>::arc* Graph<captype,tcaptype,flowtype>::get_next_arc(arc* a) { return a + 1; } template <typename captype, typename tcaptype, typename flowtype> inline void Graph<captype,tcaptype,flowtype>::get_arc_ends(arc* a, node_id& i, node_id& j) { assert(a >= arcs && a < arc_last); i = (node_id) (a->sister->head - nodes); j = (node_id) (a->head - nodes); } template <typename captype, typename tcaptype, typename flowtype> inline tcaptype Graph<captype,tcaptype,flowtype>::get_trcap(node_id i) { assert(i>=0 && i<node_num); return nodes[i].tr_cap; } template <typename captype, typename tcaptype, typename flowtype> inline captype Graph<captype,tcaptype,flowtype>::get_rcap(arc* a) { assert(a >= arcs && a < arc_last); return a->r_cap; } template <typename captype, typename tcaptype, typename flowtype> inline void Graph<captype,tcaptype,flowtype>::set_trcap(node_id i, tcaptype trcap) { assert(i>=0 && i<node_num); nodes[i].tr_cap = trcap; } template <typename captype, typename tcaptype, typename flowtype> inline void Graph<captype,tcaptype,flowtype>::set_rcap(arc* a, captype rcap) { assert(a >= arcs && a < arc_last); a->r_cap = rcap; } template <typename captype, typename tcaptype, typename flowtype> inline typename Graph<captype,tcaptype,flowtype>::termtype Graph<captype,tcaptype,flowtype>::what_segment(node_id i, termtype default_segm) { if (nodes[i].parent) { return (nodes[i].is_sink) ? SINK : SOURCE; } else { return default_segm; } } template <typename captype, typename tcaptype, typename flowtype> inline void Graph<captype,tcaptype,flowtype>::mark_node(node_id _i) { node* i = nodes + _i; if (!i->next) { /* it's not in the list yet */ if (queue_last[1]) queue_last[1] -> next = i; else queue_first[1] = i; queue_last[1] = i; i -> next = i; } i->is_marked = 1; } #endif
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
Scale.cpp
.cpp
679
34
#include "stdafx.h" #include "Scale.h" #include "MainFrm.h" #include "Panel.h" #include "Spectrum.h" #include "DICOM ViewerDoc.h" void DICOMtoImage(int min, int max) { int value, x, y, z; for (z=0; z<512; z++) for (y=0; y<512; y++) for (x=0; x<512; x++) { value = 255 * 2.5 * (m_DicomData[z][y][x]- min)/(max - min) - 50; if(value < 0) value = 0; if(value > 255) value = 255; m_Volume[z][y][x] = value; } } COLORREF GetKeyColor(int input) { static Spectrum* sp = (Spectrum*)&(((CMainFrame *)AfxGetMainWnd())->GetPanel()->m_SpectDlg); if(sp == NULL) return 0; return sp->m_key_point[input].m_color; }
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
SpectrumPoint.cpp
.cpp
378
26
#include "StdAfx.h" #include "SpectrumPoint.h" SpectrumPoint::SpectrumPoint(void) { m_bExist = false; m_bDrag = false; m_bFixed = false; } SpectrumPoint::~SpectrumPoint(void) { } bool SpectrumPoint::InsideRect(int x, int y) { if((m_rt.left <= x)&&(x <= m_rt.right) &&(m_rt.top <= y)&&(y <= m_rt.bottom)) { return true; } return false; }
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
RendererSeg.h
.h
1,741
71
#pragma once #include <glm/glm.hpp> #include "DICOM ViewerView.h" #include "TranformationMgr.h" #include "glsl.h" using namespace cwc; class RendererSeg { public: RendererSeg(void); ~RendererSeg(void); bool Initialize(); bool SetParent(CScrollView* _parent); void Destroy(); void Resize( int cx, int cy); void Render(); void GetMeanVector3(); void MouseMove(UINT nFlags, CPoint point); void LButtonDown(UINT nFlags, CPoint point); void LButtonUp(UINT nFlags, CPoint point); BOOL MouseWheel(UINT nFlags, short zDelta, CPoint pt); void RButtonDown(UINT nFlags, CPoint point); void RButtonUp(UINT nFlags, CPoint point); private: void Normal(float v[3][3], float* normal); void Normalize (float* v); void DemoLight(void); void DrawBox(float x, float y, float z, float w, float h, float d); void DrawBox(); int CreateDisplayLists(); //void Get3DRayUnderMouse(int x, int y, glm::vec3* v1, glm::vec3* v2); //bool RaySphereCollision(glm::vec3 vSphereCenter, float fSphereRadius, glm::vec3 vA, glm::vec3 vB); //int CheckLineBox( glm::vec3 B1, glm::vec3 B2, glm::vec3 L1, glm::vec3 L2, glm::vec3 &Hit); //inline int GetIntersection( float fDst1, float fDst2, glm::vec3 P1, glm::vec3 P2, glm::vec3 &Hit); //inline int InBox( glm::vec3 Hit, glm::vec3 B1, glm::vec3 B2, const int Axis); HGLRC m_hRC; HDC m_hDC; CScrollView* m_parent; BOOL m_bStartToMove4; CPoint m_StartPoint4; CPoint m_MovePoint4; CPoint m_DownPoint4; LONG mouse_down; float prev_x; float prev_y; float zoom; float pitch; float yaw; GLfloat m_mean_vector[3]; float m_min_vector[3]; float m_max_vector[3]; CTranformationMgr m_transMgr; glShader* shader; };
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
TranformationMgr.cpp
.cpp
1,251
42
#include "StdAfx.h" #include "TranformationMgr.h" #include <GL/GL.h> CTranformationMgr::CTranformationMgr(void) { mdRotation[0]=mdRotation[5]=mdRotation[10]=mdRotation[15] = 1.0f; mdRotation[1]=mdRotation[2]=mdRotation[3]=mdRotation[4] = 0.0f; mdRotation[6]=mdRotation[7]=mdRotation[8]=mdRotation[9] = 0.0f; mdRotation[11]=mdRotation[12]=mdRotation[13]=mdRotation[14] = 0.0f; mfRot[0]=mfRot[1]=mfRot[2]=0.0f; } CTranformationMgr::~CTranformationMgr(void) { } void CTranformationMgr::Rotate(float fx_i, float fy_i, float fz_i ) { mfRot[0] = fx_i; mfRot[1] = fy_i; mfRot[2] = fz_i; glMatrixMode( GL_MODELVIEW ); glLoadMatrixd( mdRotation ); glRotated( mfRot[0], 1.0f, 0,0 ); glRotated( mfRot[1], 0, 1.0f,0 ); glRotated( mfRot[2], 0, 0,1.0f ); glGetDoublev( GL_MODELVIEW_MATRIX, mdRotation ); glLoadIdentity(); } void CTranformationMgr::ResetRotation() { mdRotation[0]=mdRotation[5]=mdRotation[10]=mdRotation[15] = 1.0f; mdRotation[1]=mdRotation[2]=mdRotation[3]=mdRotation[4] = 0.0f; mdRotation[6]=mdRotation[7]=mdRotation[8]=mdRotation[9] = 0.0f; mdRotation[11]=mdRotation[12]=mdRotation[13]=mdRotation[14] = 0.0f; }
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
TranformationMgr.h
.h
401
21
#pragma once class CTranformationMgr { public: CTranformationMgr(void); virtual ~CTranformationMgr(void); const double* GetMatrix() { return mdRotation; } // Call this only after the open gl is initialized. void Rotate(float fx_i, float fy_i, float fz_i ); void ResetRotation(); private: float mfRot[3]; double mdRotation[16]; };
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
segmentation.h
.h
3,796
153
#include "stdio.h" #include <math.h> #include <cstdio> #include <vector> #include "MarchingCube.h" #if 0 #include "itkCurvatureAnisotropicDiffusionImageFilter.h" #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h" #include "itkSigmoidImageFilter.h" #include "itkFastMarchingImageFilter.h" #include "itkShapeDetectionLevelSetImageFilter.h" #include "itkBinaryThresholdImageFilter.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkImageSeriesWriter.h" #include "itkNumericSeriesFileNames.h" #include "itkRescaleIntensityImageFilter.h" #endif #define __ITERATION__ //#define __INTERPOLATION__ #define sizex 512 #define sizey 512 #define sizexy sizex*sizey #define MaxElementNo 10000000 #define NoOfVector MaxElementNo/1000000 #define sigmalevel 66 #define WinSize 19 // Odd value #define HWinSize (int)((WinSize-1)/2) #define BlockSize 9 enum SEG_MODE { NONE = 0, THRESHOLD, ATHRESHOLD, GRAPHCUT, DYNAMICREGIONGROWING, LEVELSET_2D, LEVELSET_3D, }; #pragma once typedef struct index_T { bool IsObject : 1; bool IsBoundary : 1; bool IsBackground : 1; bool Seed : 1; bool TempObject : 1; } tIndex; using namespace std; #if 0 class CSegmentation { protected: private: #endif // int ***m_Voxel; // int ***m_InputImg; // int ***m_Thres; // tIndex ***m_Index; // double m_Gauss[WinSize][WinSize][WinSize]; // double m_Gauss2D[WinSize][WinSize]; // vector<vPoint> m_CurrentBoundary, m_NextBoundary; // vector<vPoint> m_CurBound[NoOfVector], m_NextBound[NoOfVector]; // unsigned int m_CurBoundNo, m_NextBoundNo; // unsigned int m_CurBoundMax, m_NextBoundMax; // int m_IterationCnt; // int m_HistoMin, m_HistoMax; // int m_CheckRange; // int m_TargetValue; // int m_TargetValueMin; // int m_TargetValueMax; // int m_MinThres, m_MaxThres; // int m_MaxIterationNo; // int m_BgThres; // int m_sizez; // int m_HUmin; // int m_HUmax; // int m_HWinSizeZ; // double m_ObjectMean; // double m_ObjectVariable; // SEG_MODE m_SegMode; // int m_currentZ; // void currentBoundary_clear(); // void nextBoundary_clear(); // void currentBoundary_reserve(); // void nextBoundary_reserve(); // void currentBoundary_push_back(vPoint point); // void nextBoundary_push_back(vPoint point); // bool GetCur_IsInside(int vIndex); // int GetCur_x(int vIndex); // int GetCur_y(int vIndex); // int GetCur_z(int vIndex); // bool GetNext_IsInside(int vIndex); // int GetNext_x(int vIndex); // int GetNext_y(int vIndex); // int GetNext_z(int vIndex); void VectorInit(); // bool checkUnimodal(double* histogram, int thres); // int OtsuThreshold(double* histogram, double total); void MakeGaussianKernel(); void MakeGaussianKernel2D(); // int GetThreshold3D(int x, int y, int z); int GetThreshold2D(int x, int y); void MakeVoxelThreshold1(); void FindInitialArea(); // void FloodFill(); // void SetInitialBG(); // bool FindNextBG(); // void FillInside(); void vFindBoundary(); // int vApplyThreshold1(); void ReadyForNextIteration(); void IterationProcess(); void InitSegmentation(); void StoreSegmentationResult(); void DeleteMemory(); void Thresholding(); void AdaptiveThreshold3D(); // void MakeVoxel2D(); void MakeVoxel3D(); void GraphCutSegmentation(); void DynamicRegionGrowing(); void InitDynamicRegionGrowing(); void IterationProcessDRG(); void vFindBoundaryDRG(); int vApplyThresholdDRG(); int GetObjectMean(int x, int y, int z); void LevelSet2D(); void LevelSet3D(); //public: // CSegmentation(); // virtual ~CSegmentation(); void Destroy(); void Segmentation(SEG_MODE SegMode, int StartLevel, int Zsize, vector<tTri> *triangles, int min, int max, int currentZ); //};
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
MarchingCube.h
.h
1,273
77
#include "stdio.h" #include <math.h> #include <cstdio> #include <vector> #pragma once #define sizex 512 #define sizey 512 typedef struct vector_T { float fX; float fY; float fZ; } tVector; typedef struct facet_T { float normal[3]; float v1[3]; float v2[3]; float v3[3]; } facet; typedef struct Tri_T { float normal[3]; float vertex[3][3]; unsigned int Attr; COLORREF color; } tTri; typedef struct STLTri_T { float normal[3]; float v1[3]; float v2[3]; float v3[3]; unsigned short attri; } STLTri; typedef struct vPoint_T { unsigned short x; unsigned short y; unsigned short z; bool IsInside; } vPoint; using namespace std; class CMarchingCube { protected: private: // int ***m_volume; int m_sizez; float m_thres; float m_StepSize; float m_Vfactor; float VoxelVal(float fX, float fY, float fZ); float fGetOffset(float fValue1, float fValue2, float fValueDesired); void GetNormal(tVector &rfNormal, float *p1, float *p2, float *p3); void MarchingCube(float fX, float fY, float fZ, vector<tTri> *triangles, COLORREF _c); public: CMarchingCube(); virtual ~CMarchingCube(); void Start(int threshold, vector<tTri> *triangles, int sizez); };
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
RendererSeg.cpp
.cpp
25,635
916
#include "StdAfx.h" #include "RendererSeg.h" #include "DICOM ViewerDoc.h" #include "MainFrm.h" //#include "glsl.h" #include <glm/gtc/matrix_transform.hpp> #define M_PI 3.14159265358979323846 void CreateRotationalMatrix(double** matrix, double phi, double theta, double psi) { matrix[0][0] = cos(theta)*cos(psi); matrix[1][0] = -cos(phi)*sin(psi)+sin(phi)*sin(theta)*cos(psi); matrix[2][0] = sin(phi)*sin(psi)+cos(phi)*sin(theta)*cos(psi); matrix[0][1] = cos(theta)*sin(psi); matrix[1][1] = cos(phi)*cos(psi)+sin(phi)*sin(theta)*sin(psi); matrix[2][1] = -sin(phi)*cos(psi)+cos(phi)*sin(theta)*sin(psi); matrix[0][2] = -sin(theta); matrix[1][2] = sin(phi)*cos(theta); matrix[2][2] = cos(phi)*cos(theta); } RendererSeg::RendererSeg(void) { m_bStartToMove4 = FALSE; zoom = 30.0f; pitch = 0.0f; yaw = 0.0f; } RendererSeg::~RendererSeg(void) { } bool RendererSeg::Initialize() { return true; } bool RendererSeg::SetParent(CScrollView* _parent) { if(_parent == NULL) return false; m_parent = _parent; return true; } void RendererSeg::Destroy() { CDICOMViewerDoc* pDoc = (CDICOMViewerDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument(); if(!pDoc) return; pDoc->m_triangles.clear(); } void RendererSeg::Resize( int cx, int cy) { GLdouble aspect; if(cy == 0) { aspect = (GLdouble)cx; } else { aspect = (GLdouble)cx / (GLdouble)cy; } glViewport(0,0, cx, cy); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, aspect, 1.0f, 10000.0f); glShadeModel(GL_SHININESS); glEnable( GL_ALPHA_TEST ); glAlphaFunc( GL_GREATER, 0.05f ); glEnable(GL_BLEND); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glShadeModel(GL_SMOOTH); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); glEnable(GL_COLOR_MATERIAL); glEnable(GL_DEPTH_TEST); glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); GLfloat ambient[] = {0.0, 0.0, 0.0, 1.0}; GLfloat diffuse[] = {0.55, 0.55, 0.55, 1.0}; GLfloat specular[] = {0.70, 0.70, 0.70, 1.0}; GLfloat shininess = 0.25; glMaterialfv(GL_FRONT, GL_AMBIENT, ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, specular); glMaterialfv(GL_FRONT, GL_SHININESS, &shininess); // ------------------------------------------- // Material parameters: GLfloat material_Ka[] = {0.5f, 0.5f, 0.5f, 1.0f}; GLfloat material_Kd[] = {0.4f, 0.4f, 0.4f, 1.0f}; GLfloat material_Ks[] = {0.8f, 0.8f, 0.8f, 1.0f}; GLfloat material_Ke[] = {0.1f, 0.1f, 0.1f, 0.0f}; GLfloat material_Se = 30.0f; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, material_Ka); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, material_Kd); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, material_Ks); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, material_Ke); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material_Se); //glShaderManager SM; //shader = NULL; //shader = SM.loadfromFile("vertexshader.txt","fragmentshader.txt"); // load (and compile, link) from file //if (shader==NULL) // return; //shader->enable(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void RendererSeg::Normalize(float* v) { // calculate the length of the vector float len = (float)(sqrt((v[0] * v[0]) + (v[1] * v[1]) + (v[2] * v[2]))); // avoid division by 0 if (len == 0.0f) len = 1.0f; // reduce to unit size v[0] /= len; v[1] /= len; v[2] /= len; } void RendererSeg::Normal(float v[3][3], float* normal) { float a[3], b[3]; // calculate the vectors A and B // note that v[3] is defined with counterclockwise winding in mind // a a[0] = v[0][0] - v[1][0]; a[1] = v[0][1] - v[1][1]; a[2] = v[0][2] - v[1][2]; // b b[0] = v[1][0] - v[2][0]; b[1] = v[1][1] - v[2][1]; b[2] = v[1][2] - v[2][2]; // calculate the cross product and place the resulting vector // into the address specified by vertex_t *normal normal[0] = (a[1] * b[2]) - (a[2] * b[1]); normal[1] = (a[2] * b[0]) - (a[0] * b[2]); normal[2] = (a[0] * b[1]) - (a[1] * b[0]); // normalize Normalize(normal); } void RendererSeg::Render() { CDICOMViewerDoc* pDoc = (CDICOMViewerDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument(); if(!pDoc) return; //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //glClearDepth(1.0f); //glClearColor(0.3f, 0.3f, 0.3f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); DemoLight(); glLoadIdentity(); if(pDoc->m_bCalcMean == false) { if(pDoc->m_triangles.empty()) return; GetMeanVector3(); pDoc->m_bCalcMean = true; glTranslatef(0.0f, 0.0f, 0.0f); GLfloat x = m_max_vector[0] - m_min_vector[0]; GLfloat y = m_max_vector[1] - m_min_vector[1]; if(x > y) { zoom = x + 5.0f; } else { zoom = y + 5.0f; } glTranslatef(-m_mean_vector[0], -m_mean_vector[1], -zoom); m_StartPoint4.x = -(m_mean_vector[0] * 10.0f); m_StartPoint4.y = -(m_mean_vector[1] * 10.0f); m_MovePoint4.x = 0; m_MovePoint4.y = 0; } //glPushMatrix(); //if (shader) shader->begin(); glTranslatef((m_StartPoint4.x + m_MovePoint4.x) * 0.1f, (m_StartPoint4.y + m_MovePoint4.y) * 0.1f, -zoom); glTranslatef(m_mean_vector[0], m_mean_vector[1], m_mean_vector[2]); glRotatef(yaw, 0.0f, 1.0f, 0.0f); glRotatef(abs(pitch), 1.0f, 0.0f, 0.0f); glTranslatef(-m_mean_vector[0], -m_mean_vector[1], -m_mean_vector[2]); glBegin(GL_TRIANGLES); for(size_t i = 0; i < pDoc->m_triangles.size(); i++) { float* n1 = pDoc->m_triangles[i].normal; COLORREF c = pDoc->m_triangles[i].color; GLfloat* v1 = pDoc->m_triangles[i].vertex[0]; GLfloat* v2 = pDoc->m_triangles[i].vertex[1]; GLfloat* v3 = pDoc->m_triangles[i].vertex[2]; glNormal3f(n1[0], n1[1], n1[2]); glColor4f(GetRValue(c)/255.0, GetGValue(c)/255.0, GetBValue(c)/255.0, 1.0f); glVertex3f(v1[0], v1[1], v1[2]); glVertex3f(v2[0], v2[1], v2[2]); glVertex3f(v3[0], v3[1], v3[2]); } glEnd(); //if (shader) shader->end(); //// ¸Þ½¬ Á᫐ //glBegin(GL_LINES); // X, Y, Z ¼± Ç¥½Ã //glColor3f(1.0, 0.0, 0.0); // XÃà //glVertex3f(m_mean_vector[0]+0.0, m_mean_vector[1], m_mean_vector[2]); //glVertex3f(m_mean_vector[0]+10.0, m_mean_vector[1], m_mean_vector[2]); //glColor3f(0.0, 1.0, 0.0); // YÃà //glVertex3f(m_mean_vector[0], m_mean_vector[1]+0.0, m_mean_vector[2]); //glVertex3f(m_mean_vector[0], m_mean_vector[1]+10.0, m_mean_vector[2]); //glColor3f(0.0, 0.0, 1.0); // ZÃà //glVertex3f(m_mean_vector[0], m_mean_vector[1], m_mean_vector[2]+0.0); //glVertex3f(m_mean_vector[0], m_mean_vector[1], m_mean_vector[2]+10.0); //glEnd(); //// Áß½ÉÃà //glBegin(GL_LINES); // X, Y, Z ¼± Ç¥½Ã //glColor3f(1.0, 0.0, 0.0); // XÃà //glVertex3f(0.0, 0, 0); //glVertex3f(10.0,0, 0); //glColor3f(0.0, 1.0, 0.0); // YÃà //glVertex3f(0, 0.0, 0); //glVertex3f(0, 10.0, 0); //glColor3f(0.0, 0.0, 1.0); // ZÃà //glVertex3f(0, 0, 0.0); //glVertex3f(0, 0, 10.0); //glEnd(); //DrawBox(); //gluLookAt(0.0f, 0.0f, 100.0f, 0.0f, 10.0f, 0.0f, 0.0f, 1.0f, 0.0f); //if(selectItem == 1) //{ // glColor4f(1.0f, 1.0f, 0.5f, 0.8f); //} //else //{ // glColor4f(1.0f, 1.0f, 1.0f, 0.5f); //} //// contour //glNewList( 1, GL_COMPILE ); //glPushAttrib( GL_ALL_ATTRIB_BITS ); //glEnable( GL_LIGHTING ); //glClearStencil(0); //glClear( GL_STENCIL_BUFFER_BIT ); //glEnable( GL_STENCIL_TEST ); //glStencilFunc( GL_ALWAYS, 1, 0xFFFF ); //glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE ); //glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); //glColor3f( 0.2f, 0.2f, 1.0f ); //// contour //glDisable( GL_LIGHTING ); //glStencilFunc( GL_NOTEQUAL, 1, 0xFFFF ); //glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE ); //glLineWidth( 3.0f ); //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); //glColor3f( 0.0f, 0.0f, 1.0f ); //glBegin(GL_TRIANGLES); //for(size_t i = 0; i < pDoc->m_triangles.size(); i++) //{ // //float* n1 = pDoc->m_triangles[i].normal; // COLORREF c = pDoc->m_triangles[i].color; // GLfloat* v1 = pDoc->m_triangles[i].vertex[0]; // GLfloat* v2 = pDoc->m_triangles[i].vertex[1]; // GLfloat* v3 = pDoc->m_triangles[i].vertex[2]; // glVertex3f(v1[0], v1[1], v1[2]); // glVertex3f(v2[0], v2[1], v2[2]); // glVertex3f(v3[0], v3[1], v3[2]); //} //glEnd(); //// contour //glPopAttrib(); //glEndList(); //glCallList( 1 ); //// //// ¿Ü°û¼± ó¸® //bool outlineDraw = true; // Flag To Draw The Outline ( NEW ) //bool outlineSmooth = false; // Flag To Anti-Alias The Lines ( NEW ) //float outlineColor[3] = { 0.0f, 0.0f, 0.0f }; // Color Of The Lines ( NEW ) //float outlineWidth = 0.5f; // Width Of The Lines ( NEW ) // //if (outlineDraw) // Check To See If We Want To Draw The Outline ( NEW ) //{ // glEnable (GL_BLEND); // Enable Blending ( NEW ) // glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // Set The Blend Mode ( NEW ) // glPolygonMode (GL_BACK, GL_LINE); // Draw Backfacing Polygons As Wireframes ( NEW ) // glLineWidth (outlineWidth); // Set The Line Width ( NEW ) // glCullFace (GL_FRONT); // Don't Draw Any Front-Facing Polygons ( NEW ) // glDepthFunc (GL_LEQUAL); // Change The Depth Mode ( NEW ) // glColor3fv (&outlineColor[0]); // Set The Outline Color ( NEW ) // glBegin (GL_TRIANGLES); // Tell OpenGL What We Want To Draw // for (int i = 0; i < pDoc->m_triangles.size(); i++) // Loop Through Each Polygon ( NEW ) // { // GLfloat* v1 = pDoc->m_triangles[i].vertex[0]; // GLfloat* v2 = pDoc->m_triangles[i].vertex[1]; // GLfloat* v3 = pDoc->m_triangles[i].vertex[2]; // //glVertex3f(v1[0], v1[1], v1[2]); // //glVertex3f(v2[0], v2[1], v2[2]); // //glVertex3f(v3[0], v3[1], v3[2]); // glVertex3fv (v1); // glVertex3fv (v2); // glVertex3fv (v3); // } // glEnd (); // Tell OpenGL We've Finished // glDepthFunc (GL_LESS); // Reset The Depth-Testing Mode ( NEW ) // glCullFace (GL_BACK); // Reset The Face To Be Culled ( NEW ) // glPolygonMode (GL_BACK, GL_FILL); // Reset Back-Facing Polygon Drawing Mode ( NEW ) // glDisable (GL_BLEND); // Disable Blending ( NEW ) //} glFlush(); } void RendererSeg::DemoLight(void) { glEnable(GL_LIGHTING); //glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glEnable(GL_LIGHT2); glEnable(GL_NORMALIZE); // Light model parameters: // ------------------------------------------- GLfloat lmKa[] = {0.3, 0.3, 0.3, 1.0 }; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmKa); glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, 1.0); glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, 0.0); // ------------------------------------------- // Spotlight Attenuation GLfloat spot_direction[] = {0.0, 0.0, 0.0 }; //glColor3f(1.0,0.0,0.0); //DrawBox(spot_direction[0],spot_direction[1],spot_direction[2],2,2,2); GLint spot_exponent = 30; GLint spot_cutoff = 180; glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spot_direction); glLighti(GL_LIGHT0, GL_SPOT_EXPONENT, spot_exponent); glLighti(GL_LIGHT0, GL_SPOT_CUTOFF, spot_cutoff); GLfloat Kc = 1.0; GLfloat Kl = 0.0; GLfloat Kq = 0.0; glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION,Kc); glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, Kl); glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, Kq); // ------------------------------------------- // Lighting parameters: // LIGHT 0 //GLfloat light_pos0[] = {m_mean_vector[0], m_min_vector[1] - 7.0f, m_mean_vector[2] + 5.0f, 1.0f}; ////GLfloat light_pos0[] = {0.0f, -7.0f, 5.0f, 1.0f}; //glColor3f(1.0,0.0,0.0); //DrawBox(light_pos0[0],light_pos0[1],light_pos0[2],2,2,2); GLfloat light_Ka0[] = {0.5f, 0.5f, 0.5f, 1.0f}; GLfloat light_Kd0[] = {0.1f, 0.1f, 0.1f, 1.0f}; GLfloat light_Ks0[] = {1.0f, 1.0f, 1.0f, 1.0f}; //glLightfv(GL_LIGHT0, GL_POSITION, light_pos0); //glLightfv(GL_LIGHT0, GL_AMBIENT, light_Ka0); //glLightfv(GL_LIGHT0, GL_DIFFUSE, light_Kd0); //glLightfv(GL_LIGHT0, GL_SPECULAR, light_Ks0); // ligth 1 GLfloat light_pos1[] = {m_max_vector[0] + 5.0f, m_mean_vector[1], m_max_vector[2] + 5.0f, 1.0f}; //GLfloat light_pos1[] = {15.0f, 0.0f, 10.0f, 1.0f}; glColor3f(1.0,0.0,0.0); DrawBox(light_pos1[0],light_pos1[1],light_pos1[2],2,2,2); glLightfv(GL_LIGHT1, GL_POSITION, light_pos1); glLightfv(GL_LIGHT1, GL_AMBIENT, light_Ka0); glLightfv(GL_LIGHT1, GL_DIFFUSE, light_Kd0); glLightfv(GL_LIGHT1, GL_SPECULAR, light_Ks0); // light 2 GLfloat light_pos2[] = {m_min_vector[0] - 5.0f, m_max_vector[1] + 5.0f, m_max_vector[2] + 5.0f, 1.0f}; //GLfloat light_pos2[] = {-15.0f, 5.0f, 10.0f, 1.0f}; glColor3f(1.0,0.0,0.0); DrawBox(light_pos2[0],light_pos2[1],light_pos2[2],2,2,2); glLightfv(GL_LIGHT2, GL_POSITION, light_pos2); glLightfv(GL_LIGHT2, GL_AMBIENT, light_Ka0); glLightfv(GL_LIGHT2, GL_DIFFUSE, light_Kd0); glLightfv(GL_LIGHT2, GL_SPECULAR, light_Ks0); // ------------------------------------------- // Material parameters: GLfloat material_Ka[] = {0.0f, 0.0f, 0.0f, 1.0f}; GLfloat material_Kd[] = {0.01f, 0.01f, 0.01f, 1.0f}; GLfloat material_Ks[] = {0.5f, 0.5f, 0.5f, 1.0f}; GLfloat material_Ke[] = {0.0f, 0.0f, 0.0f, 0.0f}; GLfloat material_Se = 0.25f; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, material_Ka); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, material_Kd); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, material_Ks); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, material_Ke); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material_Se); } void RendererSeg::DrawBox() { glBegin(GL_LINES); // X, Y, Z ¼± Ç¥½Ã glColor3f(0.0, 1.0, 0.0); // XÃà // glVertex3f(m_min_vector[0], m_min_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_min_vector[1], m_min_vector[2]); glVertex3f(m_min_vector[0], m_min_vector[1], m_max_vector[2]); glVertex3f(m_max_vector[0], m_min_vector[1], m_max_vector[2]); glVertex3f(m_min_vector[0], m_min_vector[1], m_min_vector[2]); glVertex3f(m_min_vector[0], m_min_vector[1], m_max_vector[2]); glVertex3f(m_max_vector[0], m_min_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_min_vector[1], m_max_vector[2]); // glVertex3f(m_min_vector[0], m_max_vector[1], m_max_vector[2]); glVertex3f(m_max_vector[0], m_max_vector[1], m_max_vector[2]); glVertex3f(m_min_vector[0], m_max_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_max_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_max_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_max_vector[1], m_max_vector[2]); glVertex3f(m_min_vector[0], m_max_vector[1], m_min_vector[2]); glVertex3f(m_min_vector[0], m_max_vector[1], m_max_vector[2]); // glVertex3f(m_min_vector[0], m_min_vector[1], m_max_vector[2]); glVertex3f(m_min_vector[0], m_max_vector[1], m_max_vector[2]); glVertex3f(m_max_vector[0], m_min_vector[1], m_max_vector[2]); glVertex3f(m_max_vector[0], m_max_vector[1], m_max_vector[2]); glVertex3f(m_min_vector[0], m_min_vector[1], m_min_vector[2]); glVertex3f(m_min_vector[0], m_max_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_min_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_max_vector[1], m_min_vector[2]); glEnd(); } void RendererSeg::DrawBox(float x, float y, float z, float w, float h, float d) { glBegin(GL_LINES); // X, Y, Z ¼± Ç¥½Ã glVertex3f(x, y, z); glVertex3f(x+w, y, z); glVertex3f(x, y, z+d); glVertex3f(x+w, y, z+d); glVertex3f(x, y, z); glVertex3f(x, y, z+d); glVertex3f(x+w, y, z); glVertex3f(x+w, y, z+d); // glVertex3f(x, y+h, z+d); glVertex3f(x+w, y+h, z+d); glVertex3f(x, y+h, z); glVertex3f(x+w, y+h, z); glVertex3f(x+w, y+h, z); glVertex3f(x+w, y+h, z+d); glVertex3f(x, y+h, z); glVertex3f(x, y+h, z+d); // glVertex3f(x, y, z+d); glVertex3f(x, y+h, z+d); glVertex3f(x+w, y, z+d); glVertex3f(x+w, y+h, z+d); glVertex3f(x, y, z); glVertex3f(x, y+h, z); glVertex3f(x+w, y, z); glVertex3f(x+w, y+h, z); glEnd(); } int RendererSeg::CreateDisplayLists() { glNewList( 1, GL_COMPILE ); glPushAttrib( GL_ALL_ATTRIB_BITS ); glEnable( GL_LIGHTING ); glClearStencil(0); glClear( GL_STENCIL_BUFFER_BIT ); glEnable( GL_STENCIL_TEST ); glStencilFunc( GL_ALWAYS, 1, 0xFFFF ); glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE ); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); glColor3f( 0.2f, 0.2f, 1.0f ); //RenderMesh3(); glDisable( GL_LIGHTING ); glStencilFunc( GL_NOTEQUAL, 1, 0xFFFF ); glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE ); glLineWidth( 3.0f ); glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); glColor3f( 1.0f, 1.0f, 1.0f ); //RenderMesh3(); glPopAttrib(); glEndList(); glNewList( 2, GL_COMPILE ); glPushAttrib( GL_ALL_ATTRIB_BITS ); glEnable( GL_LIGHTING ); glClearStencil(0); glClear( GL_STENCIL_BUFFER_BIT ); glEnable( GL_STENCIL_TEST ); glStencilFunc( GL_ALWAYS, 1, -1 ); glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE ); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); glColor3f( 0.2f, 0.2f, 1.0f ); //RenderMesh2(); glDisable( GL_LIGHTING ); glStencilFunc( GL_NOTEQUAL, 1, -1 ); glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE ); glLineWidth( 3.0f ); glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); glColor3f( 1.0f, 1.0f, 1.0f ); //RenderMesh2(); glPopAttrib(); glEndList(); return TRUE; } void RendererSeg::GetMeanVector3() { CDICOMViewerDoc* pDoc = (CDICOMViewerDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument(); if(!pDoc) return; m_min_vector[0] = pDoc->m_triangles[0].vertex[0][0]; m_min_vector[1] = pDoc->m_triangles[0].vertex[0][1]; m_min_vector[2] = pDoc->m_triangles[0].vertex[0][2]; m_max_vector[0] = pDoc->m_triangles[0].vertex[0][0]; m_max_vector[1] = pDoc->m_triangles[0].vertex[0][1]; m_max_vector[2] = pDoc->m_triangles[0].vertex[0][2]; for(size_t i = 0; i < pDoc->m_triangles.size(); i++) { float* v1 = pDoc->m_triangles[i].vertex[0]; float* v2 = pDoc->m_triangles[i].vertex[1]; float* v3 = pDoc->m_triangles[i].vertex[2]; float local_min_vector[3] = {0,}; float local_max_vector[3] = {0,}; // x local_min_vector[0] = min(min(v1[0],v2[0]),v3[0]); local_max_vector[0] = max(max(v1[0],v2[0]),v3[0]); // y local_min_vector[1] = min(min(v1[1],v2[1]),v3[1]); local_max_vector[1] = max(max(v1[1],v2[1]),v3[1]); // z local_min_vector[2] = min(min(v1[2],v2[2]),v3[2]); local_max_vector[2] = max(max(v1[2],v2[2]),v3[2]); for(int k = 0; k < 3; k++) { if(local_min_vector[k] < m_min_vector[k]) { m_min_vector[k] = local_min_vector[k]; } if(local_max_vector[k] > m_max_vector[k]) { m_max_vector[k] = local_max_vector[k]; } } } for(int i = 0; i < 3; i++) { m_mean_vector[i] = (m_min_vector[i]+m_max_vector[i])/2.0f; } return; } void RendererSeg::MouseMove(UINT nFlags, CPoint point) { // ¸¶¿ì½º ¿ÞÂÊ “¸Æ° if(m_bStartToMove4 == TRUE) { m_MovePoint4.x = point.x - m_DownPoint4.x; m_MovePoint4.y = - (point.y - m_DownPoint4.y); //Camera.RotateY(m_MovePoint4.x*0.01); //Camera.RotateX(m_MovePoint4.y*0.01); m_parent->Invalidate(FALSE); } // ¸¶¿ì½º ¿À¸¥ÂÊ ¹öư if( mouse_down == 1 ) { //yaw += ((float)point.x - prev_x) * 0.2; //pitch += ((float)point.y - prev_y) * 0.2; yaw -= ((float)prev_x - (float)point.x)*0.2; pitch -= ((float)prev_y - (float)point.y)*0.2; if(yaw < 0) { yaw += 360; } if(yaw > 360) { yaw -= 360; } if(pitch < 0) { pitch += 360; } if(pitch > 360) { pitch -= 360; } //m_camera.RotateX(pitch); //m_camera.RotateY(yaw); //m_camera.Rotate( yaw, 0, -pitch ); prev_x = point.x; prev_y = point.y; m_parent->Invalidate(FALSE); } //if( nFlags & MK_RBUTTON ) //{ // //m_camera.Rotate( prev_y -point.y, prev_x-point.x, 0 ); // m_camera.Rotate( mRotReference.y-point.y, mRotReference.x-point.x, 0 ); // mRotReference = point; // m_parent->Invalidate(FALSE); //} } //void RendererSeg::Get3DRayUnderMouse(int x, int y, glm::vec3* v1, glm::vec3* v2) //{ // GLdouble modelview[16]; // glGetDoublev(GL_MODELVIEW_MATRIX, modelview); // // GLdouble projection[16]; // glGetDoublev(GL_PROJECTION_MATRIX, projection); // // GLint viewport[4]; // glGetIntegerv(GL_VIEWPORT, viewport); // // GLdouble dv1[3]; // GLdouble dv2[3]; // gluUnProject (float(x), float(y), 0.0f, modelview, projection, viewport, &dv1[0],&dv1[1],&dv1[2]); // gluUnProject (float(x), float(y), 10.0f, modelview, projection, viewport,&dv2[0],&dv2[1],&dv2[2]); // // v1->x = (GLfloat)dv1[0]; // v1->y = (GLfloat)dv1[1]; // v1->z = (GLfloat)dv1[2]; // // v2->x = (GLfloat)dv2[0]; // v2->y = (GLfloat)dv2[1]; // v2->z = (GLfloat)dv2[2]; //} //int RendererSeg::GetIntersection( float fDst1, float fDst2, glm::vec3 P1, glm::vec3 P2, glm::vec3 &Hit) //{ // if ( (fDst1 * fDst2) >= 0.0f) // return 0; // if ( fDst1 == fDst2) // return 0; // // Hit = P1 + (P2-P1) * ( -fDst1/(fDst2-fDst1) ); // // return 1; //} // //int RendererSeg::InBox( glm::vec3 Hit, glm::vec3 B1, glm::vec3 B2, const int Axis) //{ // if ( Axis==1 && Hit.z > B1.z && Hit.z < B2.z && Hit.y > B1.y && Hit.y < B2.y) return 1; // if ( Axis==2 && Hit.z > B1.z && Hit.z < B2.z && Hit.x > B1.x && Hit.x < B2.x) return 1; // if ( Axis==3 && Hit.x > B1.x && Hit.x < B2.x && Hit.y > B1.y && Hit.y < B2.y) return 1; // // return 0; //} // //// returns true if line (L1, L2) intersects with the box (B1, B2) //// returns intersection point in Hit //int RendererSeg::CheckLineBox( glm::vec3 B1, glm::vec3 B2, glm::vec3 L1, glm::vec3 L2, glm::vec3 &Hit) //{ // if (L2.x < B1.x && L1.x < B1.x) return false; // if (L2.x > B2.x && L1.x > B2.x) return false; // if (L2.y < B1.y && L1.y < B1.y) return false; // if (L2.y > B2.y && L1.y > B2.y) return false; // if (L2.z < B1.z && L1.z < B1.z) return false; // if (L2.z > B2.z && L1.z > B2.z) return false; // if (L1.x > B1.x && L1.x < B2.x && // L1.y > B1.y && L1.y < B2.y && // L1.z > B1.z && L1.z < B2.z) // { // Hit = L1; // return true; // } // // if ( (GetIntersection( L1.x-B1.x, L2.x-B1.x, L1, L2, Hit) && InBox( Hit, B1, B2, 1 )) // || (GetIntersection( L1.y-B1.y, L2.y-B1.y, L1, L2, Hit) && InBox( Hit, B1, B2, 2 )) // || (GetIntersection( L1.z-B1.z, L2.z-B1.z, L1, L2, Hit) && InBox( Hit, B1, B2, 3 )) // || (GetIntersection( L1.x-B2.x, L2.x-B2.x, L1, L2, Hit) && InBox( Hit, B1, B2, 1 )) // || (GetIntersection( L1.y-B2.y, L2.y-B2.y, L1, L2, Hit) && InBox( Hit, B1, B2, 2 )) // || (GetIntersection( L1.z-B2.z, L2.z-B2.z, L1, L2, Hit) && InBox( Hit, B1, B2, 3 ))) // { // return true; // } // // return false; //} // //bool RendererSeg::RaySphereCollision(glm::vec3 vSphereCenter, float fSphereRadius, glm::vec3 vA, glm::vec3 vB) //{ // // Create the vector from end point vA to center of sphere // glm::vec3 vDirToSphere = vSphereCenter - vA; // // // Create a normalized direction vector from end point vA to end point vB // glm::vec3 vLineDir = glm::normalize(vB-vA); // // // Find length of line segment // float fLineLength = glm::distance(vA, vB); // // // Using the dot product, we project the vDirToSphere onto the vector vLineDir // float t = glm::dot(vDirToSphere, vLineDir); // // glm::vec3 vClosestPoint; // // If our projected distance from vA is less than or equal to 0, the closest point is vA // if (t <= 0.0f) // vClosestPoint = vA; // // If our projected distance from vA is greater thatn line length, closest point is vB // else if (t >= fLineLength) // vClosestPoint = vB; // // Otherwise calculate the point on the line using t and return it // else // vClosestPoint = vA+vLineDir*t; // // // Now just check if closest point is within radius of sphere // return glm::distance(vSphereCenter, vClosestPoint) <= fSphereRadius; //} void RendererSeg::LButtonDown(UINT nFlags, CPoint point) { m_bStartToMove4 = TRUE; m_DownPoint4 = point; //if(!m_parent) // return; //HWND hWnd = m_parent->GetSafeHwnd(); // //POINT pt; //GetCursorPos(&pt); //ScreenToClient(hWnd, &pt); //RECT rect; //GetClientRect(hWnd, &rect); //pt.y = rect.bottom-pt.y; ////bool plane_hit[6]; //glm::vec3 v1; //glm::vec3 v2; //glm::vec3 hit; //Get3DRayUnderMouse(point.x,point.y,&v1,&v2); //glm::vec3 b1; //glm::vec3 b2; //if(CheckLineBox(b1,b2,v1,v2,hit)) //{ //} } void RendererSeg::LButtonUp(UINT nFlags, CPoint point) { if(m_bStartToMove4) { m_bStartToMove4 = FALSE; m_StartPoint4.x += m_MovePoint4.x; m_StartPoint4.y -= -m_MovePoint4.y; m_MovePoint4.x = 0; m_MovePoint4.y = 0; m_parent->Invalidate(FALSE); } } BOOL RendererSeg::MouseWheel(UINT nFlags, short zDelta, CPoint pt) { if(zDelta >= 0) { zoom -= 1; } else { zoom += 1; } m_parent->Invalidate(FALSE); return TRUE; } void RendererSeg::RButtonDown(UINT nFlags, CPoint point) { mouse_down = 1; prev_x = point.x; prev_y = point.y; //mRotReference = point; } void RendererSeg::RButtonUp(UINT nFlags, CPoint point) { mouse_down = 0; }
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
Camera.h
.h
1,576
68
//*************************************************************************** // // Advanced CodeColony Camera // Philipp Crocoll, 2003 // //*************************************************************************** #pragma once //#include <gl\glut.h> // Need to include it here because the GL* types are required #define PI 3.1415926535897932384626433832795 #define PIdiv180 (PI/180.0) ///////////////////////////////// //Note: All angles in degrees // ///////////////////////////////// struct SF3dVector //Float 3d-vect, normally used { GLfloat x,y,z; }; struct SF2dVector { GLfloat x,y; }; SF3dVector F3dVector ( GLfloat x, GLfloat y, GLfloat z ); class CCamera { private: SF3dVector ViewDir; SF3dVector RightVector; SF3dVector UpVector; SF3dVector Position; public: CCamera(); //inits the values (Position: (0|0|0) Target: (0|0|-1) ) void Render ( void ); //executes some glRotates and a glTranslate command //Note: You should call glLoadIdentity before using Render void Move ( SF3dVector Direction ); void RotateX ( GLfloat Angle ); void RotateY ( GLfloat Angle ); void RotateZ ( GLfloat Angle ); void MoveForward ( GLfloat Distance ); void MoveUpward ( GLfloat Distance ); void StrafeRight ( GLfloat Distance ); public: const double* GetMatrix() { return mdRotation; } // Call this only after the open gl is initialized. void Rotate(float fx_i, float fy_i, float fz_i ); void ResetRotation(); private: double mfRot[3]; double mdRotation[16]; };
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
RendererHelper.h
.h
1,233
57
#pragma once #include "DICOM ViewerView.h" #include "Camera.h" class CRawDataProcessor; class CTranformationMgr; class CRendererHelper { public: CRendererHelper(void); virtual ~CRendererHelper(void); bool Initialize( HDC hContext_i, CRawDataProcessor* pRawDataProc_i); void Resize( int nWidth_i, int nHeight_i ); void Render(); void setZoomDelta(double _delta) { m_zoom += _delta; if(m_zoom <= 0.1) { m_zoom = 0.1; } } void SetParent(CScrollView* _parent){ m_parent = _parent; } void MouseMove(UINT nFlags, CPoint point); void LButtonDown(UINT nFlags, CPoint point); void LButtonUp(UINT nFlags, CPoint point); BOOL MouseWheel(UINT nFlags, short zDelta, CPoint pt); void RButtonDown(UINT nFlags, CPoint point); void RButtonUp(UINT nFlags, CPoint point); private: void DrawBox(void); void DrawPolygon(void); double m_zoom; HGLRC m_hglContext; CRawDataProcessor* m_pRawDataProc; CTranformationMgr* m_pTransformMgr; double view_size; double AspectWidth; double AspectHeight; GLdouble AspectRatio; CScrollView* m_parent; CPoint mRotReference; float m_min_vector[3]; float m_max_vector[3]; CCamera m_camera; };
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
picking.cpp
.cpp
4,037
132
#include "StdAfx.h" #include "picking.h" //#include <glm/gtc/matrix_transform.hpp> // ///*----------------------------------------------- // //Name: GetColorByIndex // //Params: index - index of color you want to generate // //Result: Returns i-th RGB color. // ///*---------------------------------------------*/ // //glm::vec4 GetColorByIndex(int index) //{ // int r = index&0xFF; // int g = (index>>8)&0xFF; // int b = (index>>16)&0xFF; // // return glm::vec4(float(r)/255.0f, float(g)/255.0f, float(b)/255.0f, 1.0f); //} // ///*----------------------------------------------- // //Name: GetIndexByColor // //Params: r, g, b - RGB values of color // //Result: Kind of inverse to previous function, // gets index from selected color. // ///*---------------------------------------------*/ // //int GetIndexByColor(int r, int g, int b) //{ // return (r)|(g<<8)|(b<<16); //} // ///*----------------------------------------------- // //Name: GetColorByIndex // //Params: index - index of color you want to generate // //Result: Returns i-th RGB color. // ///*---------------------------------------------*/ // //int GetPickedColorIndexUnderMouse() //{ // HWND hWnd = AfxGetMainWnd()->GetSafeHwnd(); // POINT mp; GetCursorPos(&mp); // ScreenToClient(hWnd, &mp); // RECT rect; GetClientRect(appMain.hWnd, &rect); // mp.y = rect.bottom-mp.y; // BYTE bArray[4]; // glReadPixels(mp.x, mp.y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, bArray); // int iResult = GetIndexByColor(bArray[0], bArray[1], bArray[2]) - 1; // // return iResult; //} // //*----------------------------------------------- // //Name: Get3DRayUnderMouse // //Params: v1, v2 - results storage // //Result: Retrieves 3D ray under cursor from near // to far plane. // //*---------------------------------------------*/ //void Get3DRayUnderMouse(glm::vec3* v1, glm::vec3* v2) //{ // HWND hWnd = AfxGetMainWnd()->GetSafeHwnd(); // // POINT mp; GetCursorPos(&mp); // ScreenToClient(hWnd, &mp); // RECT rect; GetClientRect(hWnd, &rect); // mp.y = rect.bottom-mp.y; // // glm::vec4 viewport = glm::vec4(0.0f, 0.0f, appMain.oglControl.GetViewportWidth(), appMain.oglControl.GetViewportHeight()); // // *v1 = glm::unProject(glm::vec3(float(mp.x), float(mp.y), 0.0f), cCamera.Look(), *appMain.oglControl.GetProjectionMatrix(), viewport); // *v2 = glm::unProject(glm::vec3(float(mp.x), float(mp.y), 1.0f), cCamera.Look(), *appMain.oglControl.GetProjectionMatrix(), viewport); //} //*----------------------------------------------- // //Name: RaySphereCollision // //Params: vSphereCenter - guess what it is // fSphereRadius - guess what it is // vA, vB - two points of ray // //Result: Checks if a ray given by two points // collides with sphere. // //*---------------------------------------------*/ //bool RaySphereCollision(glm::vec3 vSphereCenter, float fSphereRadius, glm::vec3 vA, glm::vec3 vB) //{ // // Create the vector from end point vA to center of sphere // glm::vec3 vDirToSphere = vSphereCenter - vA; // // // Create a normalized direction vector from end point vA to end point vB // glm::vec3 vLineDir = glm::normalize(vB-vA); // // // Find length of line segment // float fLineLength = glm::distance(vA, vB); // // // Using the dot product, we project the vDirToSphere onto the vector vLineDir // float t = glm::dot(vDirToSphere, vLineDir); // // glm::vec3 vClosestPoint; // // If our projected distance from vA is less than or equal to 0, the closest point is vA // if (t <= 0.0f) // vClosestPoint = vA; // // If our projected distance from vA is greater thatn line length, closest point is vB // else if (t >= fLineLength) // vClosestPoint = vB; // // Otherwise calculate the point on the line using t and return it // else // vClosestPoint = vA+vLineDir*t; // // // Now just check if closest point is within radius of sphere // return glm::distance(vSphereCenter, vClosestPoint) <= fSphereRadius; //}
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
graph.cpp
.cpp
2,935
116
/* graph.cpp */ #include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include "graph.h" template <typename captype, typename tcaptype, typename flowtype> Graph<captype, tcaptype, flowtype>::Graph(int node_num_max, int edge_num_max, void (*err_function)(char *)) : node_num(0), nodeptr_block(NULL), error_function(err_function) { if (node_num_max < 16) node_num_max = 16; if (edge_num_max < 16) edge_num_max = 16; nodes = (node*) malloc(node_num_max*sizeof(node)); arcs = (arc*) malloc(2*edge_num_max*sizeof(arc)); if (!nodes || !arcs) { if (error_function) (*error_function)("Not enough memory!"); exit(1); } node_last = nodes; node_max = nodes + node_num_max; arc_last = arcs; arc_max = arcs + 2*edge_num_max; maxflow_iteration = 0; flow = 0; } template <typename captype, typename tcaptype, typename flowtype> Graph<captype,tcaptype,flowtype>::~Graph() { if (nodeptr_block) { delete nodeptr_block; nodeptr_block = NULL; } free(nodes); free(arcs); } template <typename captype, typename tcaptype, typename flowtype> void Graph<captype,tcaptype,flowtype>::reset() { node_last = nodes; arc_last = arcs; node_num = 0; if (nodeptr_block) { delete nodeptr_block; nodeptr_block = NULL; } maxflow_iteration = 0; flow = 0; } template <typename captype, typename tcaptype, typename flowtype> void Graph<captype,tcaptype,flowtype>::reallocate_nodes(int num) { int node_num_max = (int)(node_max - nodes); node* nodes_old = nodes; node_num_max += node_num_max / 2; if (node_num_max < node_num + num) node_num_max = node_num + num; nodes = (node*) realloc(nodes_old, node_num_max*sizeof(node)); if (!nodes) { if (error_function) (*error_function)("Not enough memory!"); exit(1); } node_last = nodes + node_num; node_max = nodes + node_num_max; if (nodes != nodes_old) { arc* a; for (a=arcs; a<arc_last; a++) { a->head = (node*) ((char*)a->head + (((char*) nodes) - ((char*) nodes_old))); } } } template <typename captype, typename tcaptype, typename flowtype> void Graph<captype,tcaptype,flowtype>::reallocate_arcs() { int arc_num_max = (int)(arc_max - arcs); int arc_num = (int)(arc_last - arcs); arc* arcs_old = arcs; arc_num_max += arc_num_max / 2; if (arc_num_max & 1) arc_num_max ++; arcs = (arc*) realloc(arcs_old, arc_num_max*sizeof(arc)); if (!arcs) { if (error_function) (*error_function)("Not enough memory!"); exit(1); } arc_last = arcs + arc_num; arc_max = arcs + arc_num_max; if (arcs != arcs_old) { node* i; arc* a; for (i=nodes; i<node_last; i++) { if (i->first) i->first = (arc*) ((char*)i->first + (((char*) arcs) - ((char*) arcs_old))); } for (a=arcs; a<arc_last; a++) { if (a->next) a->next = (arc*) ((char*)a->next + (((char*) arcs) - ((char*) arcs_old))); a->sister = (arc*) ((char*)a->sister + (((char*) arcs) - ((char*) arcs_old))); } } } #include "instances.inc"
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
block.h
.h
7,220
269
/* block.h */ /* Template classes Block and DBlock Implement adding and deleting items of the same type in blocks. If there there are many items then using Block or DBlock is more efficient than using 'new' and 'delete' both in terms of memory and time since (1) On some systems there is some minimum amount of memory that 'new' can allocate (e.g., 64), so if items are small that a lot of memory is wasted. (2) 'new' and 'delete' are designed for items of varying size. If all items has the same size, then an algorithm for adding and deleting can be made more efficient. (3) All Block and DBlock functions are inline, so there are no extra function calls. Differences between Block and DBlock: (1) DBlock allows both adding and deleting items, whereas Block allows only adding items. (2) Block has an additional operation of scanning items added so far (in the order in which they were added). (3) Block allows to allocate several consecutive items at a time, whereas DBlock can add only a single item. Note that no constructors or destructors are called for items. Example usage for items of type 'MyType': /////////////////////////////////////////////////// #include "block.h" #define BLOCK_SIZE 1024 typedef struct { int a, b; } MyType; MyType *ptr, *array[10000]; ... Block<MyType> *block = new Block<MyType>(BLOCK_SIZE); // adding items for (int i=0; i<sizeof(array); i++) { ptr = block -> New(); ptr -> a = ptr -> b = rand(); } // reading items for (ptr=block->ScanFirst(); ptr; ptr=block->ScanNext()) { printf("%d %d\n", ptr->a, ptr->b); } delete block; ... DBlock<MyType> *dblock = new DBlock<MyType>(BLOCK_SIZE); // adding items for (int i=0; i<sizeof(array); i++) { array[i] = dblock -> New(); } // deleting items for (int i=0; i<sizeof(array); i+=2) { dblock -> Delete(array[i]); } // adding items for (int i=0; i<sizeof(array); i++) { array[i] = dblock -> New(); } delete dblock; /////////////////////////////////////////////////// Note that DBlock deletes items by marking them as empty (i.e., by adding them to the list of free items), so that this memory could be used for subsequently added items. Thus, at each moment the memory allocated is determined by the maximum number of items allocated simultaneously at earlier moments. All memory is deallocated only when the destructor is called. */ #ifndef __BLOCK_H__ #define __BLOCK_H__ #include <stdlib.h> /***********************************************************************/ /***********************************************************************/ /***********************************************************************/ template <class Type> class Block { public: /* Constructor. Arguments are the block size and (optionally) the pointer to the function which will be called if allocation failed; the message passed to this function is "Not enough memory!" */ Block(int size, void (*err_function)(char *) = NULL) { first = last = NULL; block_size = size; error_function = err_function; } /* Destructor. Deallocates all items added so far */ ~Block() { while (first) { block *next = first -> next; delete[] ((char*)first); first = next; } } /* Allocates 'num' consecutive items; returns pointer to the first item. 'num' cannot be greater than the block size since items must fit in one block */ Type *New(int num = 1) { Type *t; if (!last || last->current + num > last->last) { if (last && last->next) last = last -> next; else { block *next = (block *) new char [sizeof(block) + (block_size-1)*sizeof(Type)]; if (!next) { if (error_function) (*error_function)("Not enough memory!"); exit(1); } if (last) last -> next = next; else first = next; last = next; last -> current = & ( last -> data[0] ); last -> last = last -> current + block_size; last -> next = NULL; } } t = last -> current; last -> current += num; return t; } /* Returns the first item (or NULL, if no items were added) */ Type *ScanFirst() { for (scan_current_block=first; scan_current_block; scan_current_block = scan_current_block->next) { scan_current_data = & ( scan_current_block -> data[0] ); if (scan_current_data < scan_current_block -> current) return scan_current_data ++; } return NULL; } /* Returns the next item (or NULL, if all items have been read) Can be called only if previous ScanFirst() or ScanNext() call returned not NULL. */ Type *ScanNext() { while (scan_current_data >= scan_current_block -> current) { scan_current_block = scan_current_block -> next; if (!scan_current_block) return NULL; scan_current_data = & ( scan_current_block -> data[0] ); } return scan_current_data ++; } /* Marks all elements as empty */ void Reset() { block *b; if (!first) return; for (b=first; ; b=b->next) { b -> current = & ( b -> data[0] ); if (b == last) break; } last = first; } /***********************************************************************/ private: typedef struct block_st { Type *current, *last; struct block_st *next; Type data[1]; } block; int block_size; block *first; block *last; block *scan_current_block; Type *scan_current_data; void (*error_function)(char *); }; /***********************************************************************/ /***********************************************************************/ /***********************************************************************/ template <class Type> class DBlock { public: /* Constructor. Arguments are the block size and (optionally) the pointer to the function which will be called if allocation failed; the message passed to this function is "Not enough memory!" */ DBlock(int size, void (*err_function)(char *) = NULL) { first = NULL; first_free = NULL; block_size = size; error_function = err_function; } /* Destructor. Deallocates all items added so far */ ~DBlock() { while (first) { block *next = first -> next; delete[] ((char*)first); first = next; } } /* Allocates one item */ Type *New() { block_item *item; if (!first_free) { block *next = first; first = (block *) new char [sizeof(block) + (block_size-1)*sizeof(block_item)]; if (!first) { if (error_function) (*error_function)("Not enough memory!"); exit(1); } first_free = & (first -> data[0] ); for (item=first_free; item<first_free+block_size-1; item++) item -> next_free = item + 1; item -> next_free = NULL; first -> next = next; } item = first_free; first_free = item -> next_free; return (Type *) item; } /* Deletes an item allocated previously */ void Delete(Type *t) { ((block_item *) t) -> next_free = first_free; first_free = (block_item *) t; } /***********************************************************************/ private: typedef union block_item_st { Type t; block_item_st *next_free; } block_item; typedef struct block_st { struct block_st *next; block_item data[1]; } block; int block_size; block *first; block_item *first_free; void (*error_function)(char *); }; #endif
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
Panel.h
.h
1,165
52
#pragma once #include "afxdockablepane.h" #include "Histogram.h" #include "Spectrum.h" enum PANEL_MODE { PANEL_NONE, PANEL_THRES, PANEL_A_THRES, PANEL_GRAPH_CUT, PANEL_LEVEL_SET }; class CPanel : public CDockablePane { public: afx_msg void OnThreshold(); afx_msg void OnAThreshold(); afx_msg void OnGraphCut(); afx_msg void OnLevelSet2D(); afx_msg void OnLevelSet3D(); afx_msg void OnDynamicRegionGrowing(); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); inline void SetMode(PANEL_MODE _panel_mode){ m_pannel_mode = _panel_mode; } Histogram m_HistoDlg; Spectrum m_SpectDlg; CButton btn_seg; CButton btn_reset; private: PANEL_MODE m_pannel_mode; public: CPanel(void); ~CPanel(void); DECLARE_MESSAGE_MAP() afx_msg void OnPaint(); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnDestroy(); afx_msg void OnBnClickedSeg(); afx_msg void OnBnClickedReset(); };
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
FilterLevelSet.h
.h
103
9
#pragma once class FilterLevelSet { public: FilterLevelSet(void); ~FilterLevelSet(void); };
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
Camera.cpp
.cpp
4,467
195
#include "StdAfx.h" #include "camera.h" #include "math.h" #include <iostream> #include "windows.h" #define SQR(x) (x*x) #define NULL_VECTOR F3dVector(0.0f,0.0f,0.0f) SF3dVector F3dVector ( GLfloat x, GLfloat y, GLfloat z ) { SF3dVector tmp; tmp.x = x; tmp.y = y; tmp.z = z; return tmp; } GLfloat GetF3dVectorLength( SF3dVector * v) { return (GLfloat)(sqrt(SQR(v->x)+SQR(v->y)+SQR(v->z))); } SF3dVector Normalize3dVector( SF3dVector v) { SF3dVector res; float l = GetF3dVectorLength(&v); if (l == 0.0f) return NULL_VECTOR; res.x = v.x / l; res.y = v.y / l; res.z = v.z / l; return res; } SF3dVector operator+ (SF3dVector v, SF3dVector u) { SF3dVector res; res.x = v.x+u.x; res.y = v.y+u.y; res.z = v.z+u.z; return res; } SF3dVector operator- (SF3dVector v, SF3dVector u) { SF3dVector res; res.x = v.x-u.x; res.y = v.y-u.y; res.z = v.z-u.z; return res; } SF3dVector operator* (SF3dVector v, float r) { SF3dVector res; res.x = v.x*r; res.y = v.y*r; res.z = v.z*r; return res; } SF3dVector CrossProduct (SF3dVector * u, SF3dVector * v) { SF3dVector resVector; resVector.x = u->y*v->z - u->z*v->y; resVector.y = u->z*v->x - u->x*v->z; resVector.z = u->x*v->y - u->y*v->x; return resVector; } float operator* (SF3dVector v, SF3dVector u) //dot product { return v.x*u.x+v.y*u.y+v.z*u.z; } /***************************************************************************************/ CCamera::CCamera() { //Init with standard OGL values: Position = F3dVector (0.0, 0.0, 0.0); ViewDir = F3dVector( 0.0, 0.0, -1.0); RightVector = F3dVector (1.0, 0.0, 0.0); UpVector = F3dVector (0.0, 1.0, 0.0); //Only to be sure: //RotatedX = RotatedY = RotatedZ = 0.0; mdRotation[0]=mdRotation[5]=mdRotation[10]=mdRotation[15] = 1.0f; mdRotation[1]=mdRotation[2]=mdRotation[3]=mdRotation[4] = 0.0f; mdRotation[6]=mdRotation[7]=mdRotation[8]=mdRotation[9] = 0.0f; mdRotation[11]=mdRotation[12]=mdRotation[13]=mdRotation[14] = 0.0f; mfRot[0]=mfRot[1]=mfRot[2]=0.0f; } void CCamera::Move (SF3dVector Direction) { Position = Position + Direction; } void CCamera::RotateX (GLfloat Angle) { mfRot[0] += Angle; //Rotate viewdir around the right vector: ViewDir = Normalize3dVector(ViewDir*cos(Angle*PIdiv180) + UpVector*sin(Angle*PIdiv180)); //now compute the new UpVector (by cross product) UpVector = CrossProduct(&ViewDir, &RightVector)*-1; } void CCamera::RotateY (GLfloat Angle) { mfRot[1] += Angle; //Rotate viewdir around the up vector: ViewDir = Normalize3dVector(ViewDir*cos(Angle*PIdiv180) - RightVector*sin(Angle*PIdiv180)); //now compute the new RightVector (by cross product) RightVector = CrossProduct(&ViewDir, &UpVector); } void CCamera::RotateZ (GLfloat Angle) { mfRot[2] += Angle; //Rotate viewdir around the right vector: RightVector = Normalize3dVector(RightVector*cos(Angle*PIdiv180) + UpVector*sin(Angle*PIdiv180)); //now compute the new UpVector (by cross product) UpVector = CrossProduct(&ViewDir, &RightVector)*-1; } void CCamera::Render( void ) { //The point at which the camera looks: SF3dVector ViewPoint = Position+ViewDir; //as we know the up vector, we can easily use gluLookAt: gluLookAt( Position.x,Position.y,Position.z, ViewPoint.x,ViewPoint.y,ViewPoint.z, UpVector.x,UpVector.y,UpVector.z); } void CCamera::MoveForward( GLfloat Distance ) { Position = Position + (ViewDir*-Distance); } void CCamera::StrafeRight ( GLfloat Distance ) { Position = Position + (RightVector*Distance); } void CCamera::MoveUpward( GLfloat Distance ) { Position = Position + (UpVector*Distance); } void CCamera::Rotate(float fx_i, float fy_i, float fz_i ) { mfRot[0] = fx_i; mfRot[1] = fy_i; mfRot[2] = fz_i; glMatrixMode( GL_MODELVIEW ); glLoadMatrixd( mdRotation ); glRotated( mfRot[0], 1.0f, 0,0 ); glRotated( mfRot[1], 0, 1.0f,0 ); glRotated( mfRot[2], 0, 0,1.0f ); glGetDoublev( GL_MODELVIEW_MATRIX, mdRotation ); glLoadIdentity(); } void CCamera::ResetRotation() { mdRotation[0]=mdRotation[5]=mdRotation[10]=mdRotation[15] = 1.0f; mdRotation[1]=mdRotation[2]=mdRotation[3]=mdRotation[4] = 0.0f; mdRotation[6]=mdRotation[7]=mdRotation[8]=mdRotation[9] = 0.0f; mdRotation[11]=mdRotation[12]=mdRotation[13]=mdRotation[14] = 0.0f; }
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
segmentation.cpp
.cpp
46,760
1,929
#include "stdafx.h" #include "segmentation.h" #include "Scale.h" #include "graph.h" #include "block.h" #include "itkCurvatureAnisotropicDiffusionImageFilter.h" #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h" #include "itkSigmoidImageFilter.h" #include "itkFastMarchingImageFilter.h" #include "itkShapeDetectionLevelSetImageFilter.h" #include "itkBinaryThresholdImageFilter.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkImageSeriesWriter.h" #include "itkNumericSeriesFileNames.h" #include "itkRescaleIntensityImageFilter.h" #include "DICOM ViewerDoc.h" #include <windows.h> //#define _MY_DEBUG using namespace Concurrency; unsigned char m_Thres[512][512][512]; vector<vPoint> m_CurrentBoundary, m_NextBoundary; vector<vPoint> m_CurBound[NoOfVector], m_NextBound[NoOfVector]; unsigned int m_CurBoundNo, m_NextBoundNo; unsigned int m_CurBoundMax, m_NextBoundMax; double m_Gauss[WinSize][WinSize][WinSize]; double m_Gauss2D[WinSize][WinSize]; int m_IterationCnt; int m_HistoMin, m_HistoMax; int m_CheckRange; int m_TargetValue; int m_TargetValueMin; int m_TargetValueMax; int m_MinThres, m_MaxThres; int m_MaxIterationNo; int m_BgThres; int m_sizez; int m_HUmin; int m_HUmax; int m_HWinSizeZ; double m_ObjectMean; double m_ObjectVariable; SEG_MODE m_SegMode; int m_currentZ; void myOutputDebugString(LPCTSTR pszStr, ...) { #ifdef _MY_DEBUG TCHAR szMsg[256]; va_list args; va_start(args, pszStr); _vstprintf_s(szMsg, 256, pszStr, args); OutputDebugString(szMsg); #endif } #if 0 CSegmentation::CSegmentation() { // TODO: ¿©±â¿¡ »ý¼º Äڵ带 Ãß°¡ÇÕ´Ï´Ù. // VectorInit(); // m_Voxel = NULL; // m_InputImg = NULL; // m_Thres = NULL; // m_Index = NULL; } CSegmentation::~CSegmentation() { Destroy(); } void CSegmentation::Destroy() { /* int y, z; if(m_Voxel != NULL) { for(z = 0; z < m_sizez; z++) { for(int y = 0; y < 512; y++) delete [] m_Voxel[z][y]; delete [] m_Voxel[z] ; } delete [] m_Voxel; m_Voxel = NULL; } if(m_InputImg != NULL) { for(z = 0; z < m_sizez; z++) { for(int y = 0; y < 512; y++) delete [] m_InputImg[z][y]; delete [] m_InputImg[z] ; } delete [] m_InputImg; m_InputImg = NULL; } if(m_Thres != NULL) { for(z = 0; z < m_sizez; z++) { for(int y = 0; y < 512; y++) delete [] m_Thres[z][y]; delete [] m_Thres[z] ; } delete [] m_Thres; m_Thres = NULL; } if(m_Index != NULL) { for(z = 0; z < m_sizez; z++) { for(int y = 0; y < 512; y++) delete [] m_Index[z][y]; delete [] m_Index[z] ; } delete [] m_Index; m_Index = NULL; } */ } #endif void currentBoundary_clear() { for (int k=0; k<NoOfVector; k++) m_CurBound[k].clear(); m_CurBoundNo = 0; } void nextBoundary_clear() { for (int k=0; k<NoOfVector; k++) m_NextBound[k].clear(); m_NextBoundNo = 0; } void currentBoundary_reserve() { for (int k=0; k<NoOfVector; k++) m_CurBound[k].reserve(1000000); } void nextBoundary_reserve() { for (int k=0; k<NoOfVector; k++) m_NextBound[k].reserve(1000000); } void currentBoundary_push_back(vPoint point) { int index = (int)(m_CurBoundNo / 1000000); m_CurBound[index].push_back(point); m_CurBoundNo ++; } void nextBoundary_push_back(vPoint point) { int index = (int)(m_NextBoundNo / 1000000); m_NextBound[index].push_back(point); m_NextBoundNo ++; } bool GetCur_IsInside(int vIndex) { int index1 = (int)(vIndex / 1000000); int index2 = (int)(vIndex % 1000000); return (m_CurBound[index1][index2].IsInside); } int GetCur_x(int vIndex) { int index1 = (int)(vIndex / 1000000); int index2 = (int)(vIndex % 1000000); return (m_CurBound[index1][index2].x); } int GetCur_y(int vIndex) { int index1 = (int)(vIndex / 1000000); int index2 = (int)(vIndex % 1000000); return (m_CurBound[index1][index2].y); } int GetCur_z(int vIndex) { int index1 = (int)(vIndex / 1000000); int index2 = (int)(vIndex % 1000000); return (m_CurBound[index1][index2].z); } bool GetNext_IsInside(int vIndex) { int index1 = (int)(vIndex / 1000000); int index2 = (int)(vIndex % 1000000); return (m_NextBound[index1][index2].IsInside); } int GetNext_x(int vIndex) { int index1 = (int)(vIndex / 1000000); int index2 = (int)(vIndex % 1000000); return (m_NextBound[index1][index2].x); } int GetNext_y(int vIndex) { int index1 = (int)(vIndex / 1000000); int index2 = (int)(vIndex % 1000000); return (m_NextBound[index1][index2].y); } int GetNext_z(int vIndex) { int index1 = (int)(vIndex / 1000000); int index2 = (int)(vIndex % 1000000); return (m_NextBound[index1][index2].z); } void VectorInit() { currentBoundary_clear(); nextBoundary_clear(); currentBoundary_reserve(); nextBoundary_reserve(); } bool checkUnimodal(double* histogram, int thres) { int val = 0; int maxP1 = 0; int maxP2 = 0; int sigmaL = 0; int sigmaH = 0; int maximum = 0; double max1 = -1.0; double max2 = -1.0; double histogram1[256] = {0.0}; double Gaussian1[256] = {0.0}; double sigma1 = 0.0; double sigma2 = 0.0; double B = 0.0; double D = 0.0; double level = (double)((sigmalevel)/100.0); bool result; for (val = 2; val <= 253; val++) histogram1[val] = (histogram[val-2] + histogram[val-1] + histogram[val] + histogram[val+1] + histogram[val+2])/5; for (val = 2; val <= 253; val++) histogram[val] = histogram1[val]; for (val = m_HistoMin; val <= 255; val++) if (histogram[val] > max1) { max1 = histogram[val]; maxP1 = val; } // Estimate Mean and Sigma of Gaussian distribution int sigma = 0; int minsigma = 0; double error = 0.0; double minError = 10000000000000.0; for (sigma = 0; sigma <= 20; sigma++) { error = 0.0; B = 1.0 / (2 * sigma * sigma); for (val = maxP1-10; val <= maxP1+10; val++) { if (val < 0 || val > 255) continue; error += abs(histogram[val] - max1 * exp(-B * (val - maxP1)*(val - maxP1))); } if (error < minError) { minError = error; minsigma = sigma; } } sigma1 = minsigma; B = 1.0 / (2 * sigma1 * sigma1); for (val = 0; val <= 255; val++) { histogram1[val] = (int)(histogram[val] - max1 * exp(-B * (val - maxP1)*(val - maxP1))); if (val >= (maxP1 - 3*sigma1) && val <= (maxP1 + 3*sigma1)) histogram1[val] = 0; } for (val = m_HistoMin; val <= 255; val++) if (histogram1[val] > max2) { max2 = histogram1[val]; maxP2 = val; } for (val = maxP2; val >= max(maxP2 - m_CheckRange,0); val --) { if (histogram1[val] <= (max2*level)){ sigmaL = maxP2 - val; break; } } for (val = maxP2; val <= (maxP2 + m_CheckRange); val ++) { if (histogram1[val] <= (max2*level)){ sigmaH = val - maxP2; break; } } sigma2 = min(sigmaL, sigmaH); if ((sigma1*sigma2) == 0) result = true; else { D = abs(maxP1 - maxP2) / (2 * sqrt(sigma1 * sigma2)); if ((D <= 1.0) || (max2 *10 < max1)) result = true; else result = false; } return result; } int OtsuThreshold(double* histogram, double total) { double sum = 0.0; for (int i = 1; i < 256; i++) { sum += i * histogram[i]; } double sumB = 0.0; double wB = 0.0; double wF = 0.0; double mB = 0.0; double mF = 0.0; double between = 0.0; double maxvalue = 0; double max = 0.0; int threshold1 = 0.0; int threshold2 = 0.0; int result = 0; for (int i = 0; i < 256; ++i) { wB += histogram[i]; if (wB == 0) continue; wF = total - wB; if (wF == 0) break; sumB += i * histogram[i]; mB = sumB / wB; mF = (sum - sumB) / wF; between = wB * wF * (mB - mF) * (mB - mF); if ( between >= max ) { threshold1 = i; if ( between > max ) { threshold2 = i; } max = between; } } result = (int)(( threshold1 + threshold2 ) / 2 + 0.5); if (checkUnimodal(histogram, result) == true) { result = m_TargetValue; } return result; } void MakeGaussianKernel() { int x, y, z; for (z=0; z<WinSize; z++) { for (y=0; y<WinSize; y++) for (x=0; x<WinSize; x++) { double dist = sqrt((double)((x-HWinSize)*(x-HWinSize)+(y-HWinSize)*(y-HWinSize)+(z-HWinSize)*(z-HWinSize))); m_Gauss[z][y][x] = exp(-dist*dist/30); } } } void MakeGaussianKernel2D() { int x, y; for (y=0; y<WinSize; y++) for (x=0; x<WinSize; x++) { double dist = sqrt((double)((x-HWinSize)*(x-HWinSize)+(y-HWinSize)*(y-HWinSize))); m_Gauss2D[y][x] = exp(-dist*dist/30); } } int GetThreshold2D(int x, int y) { double histogram[256] = {0.0f}; double total = 0.0; double weight = 0.0; int xx, yy, zz; for (yy = (y-HWinSize); yy <= (y+HWinSize); yy++) { if (yy < 0 || yy > sizey-1) continue; for (xx = x-HWinSize; xx <= (x+HWinSize); xx++) { if (xx < 0 || xx > sizex-1) continue; int value = m_Volume[m_currentZ][yy][xx]; if (value < m_HistoMin || value > m_HistoMax) continue; weight = m_Gauss2D[yy-y+HWinSize][xx-x+HWinSize]; histogram[value] += weight; total += weight; } } int threshold = OtsuThreshold(histogram, total); return threshold; } int GetThreshold3D(int x, int y, int z) { double histogram[256] = {0.0f}; double total = 0.0; double weight = 0.0; int xx, yy, zz; for (int value = 0; value <= 255; value++) histogram[value] = 0.0f; for (zz = (z-m_HWinSizeZ); zz <= (z+m_HWinSizeZ); zz++) { if (zz < 0 || zz > m_sizez-1) continue; for (yy = (y-HWinSize); yy <= (y+HWinSize); yy++) { if (yy < 0 || yy > sizey-1) continue; for (xx = x-HWinSize; xx <= (x+HWinSize); xx++) { if (xx < 0 || xx > sizex-1) continue; int value = m_Volume[zz][yy][xx]; if (value < m_HistoMin || value > m_HistoMax) continue; weight = m_Gauss[zz-z+HWinSize][yy-y+HWinSize][xx-x+HWinSize]; histogram[value] += weight; total += weight; } } } int threshold = OtsuThreshold(histogram, total); return threshold; } int GetObjectMean(int x, int y, int z) { double histogram[256] = {0.0f}; double total = 0.0; double weight = 0.0; double sum; int xx, yy, zz; int mean; for (zz = (z-m_HWinSizeZ); zz <= (z+m_HWinSizeZ); zz++) { if (zz < 0 || zz > m_sizez-1) continue; for (yy = (y-HWinSize); yy <= (y+HWinSize); yy++) { if (yy < 0 || yy > sizey-1) continue; for (xx = x-HWinSize; xx <= (x+HWinSize); xx++) { if (xx < 0 || xx > sizex-1) continue; int value = m_Volume[zz][yy][xx]; if (value < m_HistoMin || value > m_HistoMax) continue; if (m_TempObject[zz][yy][xx] == 0) continue; weight = m_Gauss[zz-z+HWinSize][yy-y+HWinSize][xx-x+HWinSize]; histogram[value] += weight; total += weight; } } } sum = 0.0; for (int i=0; i<256; i++) { sum += histogram[i]; } mean = sum / total; return mean; } void MakeVoxelThreshold1() { int x, y, z, thres, t1, t2, p1, p2; for(z=0; z<m_sizez; z+= BlockSize){ for(y=0; y<sizey; y+= BlockSize){ for(x=0; x<sizex; x+= BlockSize){ thres = GetThreshold3D(x, y, z); if (thres < m_MinThres) thres = m_MinThres; if (thres > m_MaxThres) thres= m_MaxThres; m_Thres[z][y][x] = thres; } } } for(z=0; z<m_sizez; z+= BlockSize) for(y=0; y<sizey; y+= BlockSize) for(x=0; x<sizex; x++){ p1 = (int)(x/BlockSize) * BlockSize; p2 = ((int)(x/BlockSize) + 1) * BlockSize; if (p2 >= sizex) p2 = sizex-1; t1 = m_Thres[z][y][p1]; t2 = m_Thres[z][y][p2]; m_Thres[z][y][x] = (int)((t1*(p2-x) + t2*(x-p1))/(p2-p1)); } for(z=0; z<m_sizez; z+= BlockSize) for(y=0; y<sizey; y++) for(x=0; x<sizex; x++){ p1 = (int)(y/BlockSize) * BlockSize; p2 = ((int)(y/BlockSize) + 1) * BlockSize; if (p2 >= sizey) p2 = sizey-1; t1 = m_Thres[z][p1][x]; t2 = m_Thres[z][p2][x]; m_Thres[z][y][x] = (int)((t1*(p2-y) + t2*(y-p1))/(p2-p1)); } for(z=0; z<m_sizez; z++) for(y=0; y<sizey; y++) for(x=0; x<sizex; x++){ p1 = (int)(z/BlockSize) * BlockSize; p2 = ((int)(z/BlockSize) + 1) * BlockSize; if (p2 >= m_sizez) p2 = m_sizez-1; t1 = m_Thres[p1][y][x]; t2 = m_Thres[p2][y][x]; m_Thres[z][y][x] = (int)((t1*(p2-z) + t2*(z-p1))/(p2-p1)); } } void FindInitialArea() { int x, y, z; for(z=0; z<m_sizez; z++){ for(y=0; y<sizey; y++) for(x=0; x<sizex; x++){ #if 1//def __ITERATION__ if (m_Volume[z][y][x] > (m_TargetValue)) #else // m_Voxel[z][y][x] = m_InputImg[z][y][x] + (m_TargetValue - GetThreshold3D(x, y, z, 0)); m_Voxel[z][y][x] = m_InputImg[z][y][x] + (m_TargetValue - m_Thres[z][y][x]); if (m_InputImg[z][y][x] > m_Thres[z][y][x]) #endif m_Object[z][y][x] = 1; else m_Object[z][y][x] = 0; } } } #if 0 void CSegmentation::SetInitialBG() { int x, y, z; currentBoundary_clear(); vPoint a[8]; a[0].x = 0; a[0].y = 0; a[0].z = 0; a[1].x = 0; a[1].y = 511; a[1].z = 0; a[2].x = 511; a[2].y = 0; a[2].z = 0; a[3].x = 511; a[3].y = 511; a[3].z = 0; for(int i=0; i<4; i++) { x = a[i].x; y = a[i].y; z = a[i].z; if ((m_Index[z][y][x].IsObject == false) && (m_InputImg[z][y][x] < m_BgThres)) { vPoint currentPoint; currentPoint.x = x; currentPoint.y = y; currentPoint.z = z; m_Index[z][y][x].IsBackground = true; currentBoundary_push_back(currentPoint); } } } bool CSegmentation::FindNextBG() { int vIndex; int x, y, z; bool IsChanged = false; nextBoundary_clear(); for (vIndex = 0; vIndex < m_CurBoundNo; vIndex ++) { x = GetCur_x(vIndex); y = GetCur_y(vIndex); z = GetCur_z(vIndex); if ((x > 0) && (m_Index[z][y][x-1].IsBackground == false) && (m_Index[z][y][x-1].IsObject == false)) { vPoint cP; cP.x = x - 1; cP.y = y; cP.z = z; nextBoundary_push_back(cP); m_Index[z][y][x-1].IsBackground = true; IsChanged = true; } if ((x < (sizex-1)) && (m_Index[z][y][x+1].IsBackground == false) && (m_Index[z][y][x+1].IsObject == false)) { vPoint cP; cP.x = x + 1; cP.y = y; cP.z = z; nextBoundary_push_back(cP); m_Index[z][y][x+1].IsBackground = true; IsChanged = true; } if ((y > 0) && (m_Index[z][y-1][x].IsBackground == false) && (m_Index[z][y-1][x].IsObject == false)) { vPoint cP; cP.x = x; cP.y = y - 1; cP.z = z; nextBoundary_push_back(cP); m_Index[z][y-1][x].IsBackground = true; IsChanged = true; } if ((y < (sizey-1)) && (m_Index[z][y+1][x].IsBackground == false) && (m_Index[z][y+1][x].IsObject == false)) { vPoint cP; cP.x = x; cP.y = y + 1; cP.z = z; nextBoundary_push_back(cP); m_Index[z][y+1][x].IsBackground = true; IsChanged = true; } if ((z > 0) && (m_Index[z-1][y][x].IsBackground == false) && (m_Index[z-1][y][x].IsObject == false)) { vPoint cP; cP.x = x; cP.y = y; cP.z = z - 1; nextBoundary_push_back(cP); m_Index[z-1][y][x].IsBackground = true; IsChanged = true; } if ((z < (m_sizez-1)) && (m_Index[z+1][y][x].IsBackground == false) && (m_Index[z+1][y][x].IsObject == false)) { vPoint cP; cP.x = x; cP.y = y; cP.z = z + 1; nextBoundary_push_back(cP); m_Index[z+1][y][x].IsBackground = true; IsChanged = true; } } return IsChanged; } void CSegmentation::FillInside() { int x, y, z; for(z=0; z<m_sizez; z++) for(y=0; y<sizey; y++) for(x=0; x<sizex; x++) if (m_Index[z][y][x].IsBackground) m_Index[z][y][x].IsObject = false; else m_Index[z][y][x].IsObject = true; } void CSegmentation::FloodFill() { bool IsChanged; int iterationCnt = 0; m_BgThres = m_HistoMin; SetInitialBG(); do{ IsChanged = FindNextBG(); ReadyForNextIteration(); iterationCnt ++; }while(iterationCnt < 5000 && IsChanged); FillInside(); currentBoundary_clear(); nextBoundary_clear(); } #endif void vFindBoundary() { int x, y, z; currentBoundary_clear(); for(z=0; z<m_sizez; z++) for(y=0; y<sizey; y++) for(x=0; x<sizex; x++) if (((y-1) >= 0 && (m_Object[z][y-1][x] != m_Object[z][y][x])) || ((y+1) < sizey && (m_Object[z][y+1][x] != m_Object[z][y][x])) || ((x-1) >= 0 && (m_Object[z][y][x-1] != m_Object[z][y][x])) || ((x+1) < sizex && (m_Object[z][y][x+1] != m_Object[z][y][x])) || ((z-1) >= 0 && (m_Object[z-1][y][x] != m_Object[z][y][x])) || ((z+1) < m_sizez && (m_Object[z+1][y][x] != m_Object[z][y][x]))) { vPoint currentPoint; currentPoint.x = x; currentPoint.y = y; currentPoint.z = z; // currentPoint.IsInside = m_Index[z][y][x].IsObject? true:false; currentBoundary_push_back(currentPoint); } } int vApplyThreshold1() { int IsInside, thres, thresdiff, IsChanged = 0; unsigned char maskBackup; int vIndex; int abn = 0; int xx, yy, zz; nextBoundary_clear(); myOutputDebugString(_T("\tm_CurBoundNo = %d\n"), m_CurBoundNo); for (vIndex = 0; vIndex < m_CurBoundNo; vIndex ++) { xx = GetCur_x(vIndex); yy = GetCur_y(vIndex); zz = GetCur_z(vIndex); // IsInside = (int)GetCur_IsInside(vIndex); maskBackup = m_Object[zz][yy][xx]; #ifdef __INTERPOLATION__ thres = m_Thres[zz][yy][xx]; #else thres = GetThreshold3D(xx, yy, zz); #endif if (thres < m_MinThres) thres = m_MinThres; if (thres > m_MaxThres) thres = m_MaxThres; thresdiff = m_TargetValue - thres; m_Voxel[zz][yy][xx] = m_Volume[zz][yy][xx] + thresdiff; if (m_Volume[zz][yy][xx] >= thres) m_Object[zz][yy][xx] = 1; else m_Object[zz][yy][xx] = 0; if (m_Object[zz][yy][xx] != maskBackup) { IsChanged = 1; vPoint currentPoint; currentPoint.x = xx; currentPoint.y = yy; currentPoint.z = zz; // currentPoint.IsInside = m_Index[zz][yy][xx].IsObject; if (currentPoint.x > 0 && m_Boundary[zz][yy][xx - 1] == 0){ currentPoint.x = xx - 1; // currentPoint.IsInside = m_Index[zz][yy][xx - 1].IsObject; nextBoundary_push_back(currentPoint); m_Boundary[zz][yy][xx - 1] = 1; } currentPoint.x = xx; if (currentPoint.x < sizex-1 && m_Boundary[zz][yy][xx + 1] == 0){ currentPoint.x = xx + 1; // currentPoint.IsInside = m_Index[zz][yy][xx + 1].IsObject; nextBoundary_push_back(currentPoint); m_Boundary[zz][yy][xx + 1] = 1; } currentPoint.x = xx; if (currentPoint.y > 0 && m_Boundary[zz][yy - 1][xx] == 0){ currentPoint.y = yy - 1; // currentPoint.IsInside = m_Index[zz][yy - 1][xx].IsObject; nextBoundary_push_back(currentPoint); m_Boundary[zz][yy - 1][xx] = true; } currentPoint.y = yy; if (currentPoint.y < sizey-1 && m_Boundary[zz][yy + 1][xx] == 0){ currentPoint.y = yy + 1; // currentPoint.IsInside = m_Index[zz][yy + 1][xx].IsObject; nextBoundary_push_back(currentPoint); m_Boundary[zz][yy + 1][xx] = true; } currentPoint.y = yy; if (currentPoint.z > 0 && m_Boundary[zz - 1][yy][xx] == 0){ currentPoint.z = zz - 1; // currentPoint.IsInside = m_Index[zz - 1][yy][xx].IsObject; nextBoundary_push_back(currentPoint); m_Boundary[zz - 1][yy][xx] = true; } currentPoint.z = zz; if (currentPoint.z < m_sizez-1 && m_Boundary[zz + 1][yy][xx] == 0){ currentPoint.z = zz + 1; // currentPoint.IsInside = m_Index[zz + 1][yy][xx].IsObject; nextBoundary_push_back(currentPoint); m_Boundary[zz + 1][yy][xx] = true; } } } return IsChanged; } void ReadyForNextIteration() { int vIndex; currentBoundary_clear(); for (vIndex = 0; vIndex < m_NextBoundNo; vIndex ++){ vPoint currentPoint; currentPoint.x = GetNext_x(vIndex); currentPoint.y = GetNext_y(vIndex); currentPoint.z = GetNext_z(vIndex); // currentPoint.IsInside = GetNext_IsInside(vIndex); currentBoundary_push_back(currentPoint); } } void IterationProcess() { int IsChanged; // cout << "Iteration ... " << endl; m_IterationCnt = 0; myOutputDebugString(_T("vFindBoundary().....................\n"), m_IterationCnt); vFindBoundary(); do{ myOutputDebugString(_T("m_IterationCnt = %d\n"), m_IterationCnt); IsChanged = vApplyThreshold1(); ReadyForNextIteration(); m_IterationCnt ++; }while(m_IterationCnt < m_MaxIterationNo && IsChanged); } void InitSegmentation() { // int x, y, z; VectorInit(); /* m_InputImg = new int ** [m_sizez]; for(z=0; z<m_sizez; z++) { m_InputImg[z] = new int * [sizey]; for (y=0; y<sizey; y++) m_InputImg[z][y] = new int [sizex]; } m_Voxel = new int ** [m_sizez]; for(z=0; z<m_sizez; z++) { m_Voxel[z] = new int * [sizey]; for (y=0; y<sizey; y++) m_Voxel[z][y] = new int [sizex]; } m_Thres = new int ** [m_sizez]; for(z=0; z<m_sizez; z++) { m_Thres[z] = new int * [sizey]; for (y=0; y<sizey; y++) m_Thres[z][y] = new int [sizex]; } m_Index = new tIndex ** [m_sizez]; for(z=0; z<m_sizez; z++) { m_Index[z] = new tIndex * [sizey]; for (y=0; y<sizey; y++) m_Index[z][y] = new tIndex [sizex]; } int value; for(z=0; z<m_sizez; z++) for(y=0; y<sizey; y++) for(x=0; x<sizex; x++) { value = DICOMtoImage(volume[z][y][x], m_HUmin, m_HUmax); m_InputImg[z][y][x] = value; m_Voxel[z][y][x] = Voxel[z][y][x]; m_Index[z][y][x].IsObject = Index[z][y][x].IsObject; m_Index[z][y][x].IsBoundary = false; m_Index[z][y][x].IsBackground = false; m_Index[z][y][x].Seed = Index[z][y][x].Seed; m_Index[z][y][x].TempObject = false; } */ } void StoreSegmentationResult() { /* int x, y, z; for(z=0; z<m_sizez; z++) for(y=0; y<sizey; y++) for(x=0; x<sizex; x++){ Index[z][y][x].IsObject = m_Index[z][y][x].IsObject; // Index[z][y][x].IsObject = m_Index[z][y][x].TempObject; Index[z][y][x].IsBackground = m_Index[z][y][x].IsBackground; Index[z][y][x].Seed = false; Voxel[z][y][x] = m_Voxel[z][y][x]; } */ } void DeleteMemory() { /* int y, z; if(m_Voxel != NULL) { for(z = 0; z < m_sizez; z++) { for(int y = 0; y < 512; y++) delete [] m_Voxel[z][y]; delete [] m_Voxel[z] ; } delete [] m_Voxel; m_Voxel = NULL; } if(m_InputImg != NULL) { for(z = 0; z < m_sizez; z++) { for(int y = 0; y < 512; y++) delete [] m_InputImg[z][y]; delete [] m_InputImg[z] ; } delete [] m_InputImg; m_InputImg = NULL; } if(m_Thres != NULL) { for(z = 0; z < m_sizez; z++) { for(int y = 0; y < 512; y++) delete [] m_Thres[z][y]; delete [] m_Thres[z] ; } delete [] m_Thres; m_Thres = NULL; } if(m_Index != NULL) { for(z = 0; z < m_sizez; z++) { for(int y = 0; y < 512; y++) delete [] m_Index[z][y]; delete [] m_Index[z] ; } delete [] m_Index; m_Index = NULL; } */ } void Thresholding() { int x, y, z, thresdiff; for(z=0; z<m_sizez; z++){ for(y=0; y<sizey; y++) for(x=0; x<sizex; x++){ if (m_Volume[z][y][x] > m_TargetValue) m_Object[z][y][x] = 1; else m_Object[z][y][x] = 0; m_Voxel[z][y][x] = m_Volume[z][y][x]; } } } void AdaptiveThreshold3D() { double t1; t1 = (double)GetTickCount(); myOutputDebugString(_T("MakeGaussianKernel().....................\n"), m_IterationCnt); MakeGaussianKernel(); #ifdef __INTERPOLATION__ MakeVoxelThreshold1(); #endif myOutputDebugString(_T("FindInitialArea().....................\n"), m_IterationCnt); FindInitialArea(); #ifdef __ITERATION__ myOutputDebugString(_T("IterationProcess().....................\n"), m_IterationCnt); IterationProcess(); #endif t1 = (double)GetTickCount() - t1; myOutputDebugString(_T("total time = %f\n"), t1/1000); } int Lamda1 = 1; int Lamda2 = 31; int sigma = 10; //51; int edge_th = 35; int number = 170; int maxdiff = 60; //int center = 180; int centerBackup; int probmax = 200; double DifferenceFunction(int input) { double result; // double sigma2 = (double)(sigma*sigma); double sigma2 = (double)(sigma); #if 1 result = exp(-(double)(input*input)/sigma2); #else if (input < 0) input = input * (-1); if (input < 10) result = 1.0; else if (input < 30) result = 1.0 - ((double)input - 10.0)/20.0; else result = 0.0; #endif return result; } /* void CSegmentation::MakeVoxel2D() { int x, y, z; int vIndex, diff; z = m_currentZ; for(y=0; y<sizey; y++) for(x=0; x<sizex; x++) { if (m_Index[z][y][x].IsObject == true) m_Voxel[z][y][x] = m_TargetValue+1; else m_Voxel[z][y][x] = 0; } bool IsBoundary; int x1, y1; for(y=0; y<sizey; y++) for(x=0; x<sizex; x++) { IsBoundary = false; for (y1=y-1; y1<=y+1; y1++) for (x1=x-1; x1<=x+1; x1++) { if (y1>=0 && y1<sizey && x1>=0 && x1<sizex) { if (m_Index[z][y][x].IsObject!= m_Index[z][y1][x1].IsObject) { IsBoundary = true; goto Next; } } } Next : if (IsBoundary) m_Voxel[z][y][x] = m_TargetValue + (m_InputImg[z][y][x] - GetThreshold3D(x, y, z)); } } */ void MakeVoxel3D() { int x, y, z; int vIndex, diff; for(z=0; z<m_sizez; z++) for(y=0; y<sizey; y++) for(x=0; x<sizex; x++) { if (m_Object[z][y][x] == 1) m_Voxel[z][y][x] = m_TargetValue+1; else m_Voxel[z][y][x] = 0; } bool IsBoundary; int x1, y1, z1; for(z=0; z<m_sizez; z++) for(y=0; y<sizey; y++) for(x=0; x<sizex; x++) { IsBoundary = false; for (z1=z-1; z1<= z+1; z1++) for (y1=y-1; y1<=y+1; y1++) for (x1=x-1; x1<=x+1; x1++) { if (z1>=0 && z1<m_sizez && y1>=0 && y1<sizey && x1>=0 && x1<sizex) { if (m_Object[z][y][x]!= m_Object[z1][y1][x1]) { IsBoundary = true; goto Next; } } } Next : if (IsBoundary) m_Voxel[z][y][x] = m_TargetValue + (m_Volume[z][y][x] - GetThreshold3D(x, y, z)); } } void GraphCutSegmentation() { typedef Graph<int,int,int> GraphType; // GraphType *g = new GraphType(262144, 523264); //estimated # of nodes, estimated # of edges GraphType *g = new GraphType(140000000, 512*512*300*3); //estimated # of nodes, estimated # of edges int x, y, z; int node1, node2; double cap1, cap2, cap, I1, I2, P1, P2; double Lamda_1 = (double)(Lamda1); //1;//pow(10.0, (double)(Lamda1 - 5)); double Lamda_2 = (double)(Lamda2); //31;//(double)(Lamda2 - 50); // double sigma1 = pow(10.0, (double)(sigma - 50)); //10;//pow(10.0, (double)(sigma - 50)); double sigma1 = sigma; double sigma2 = sigma1*sigma1; int edgeValue; for(z=0; z<m_sizez; z++) for(y=0; y<sizey; y++) for(x=0; x<sizex; x++) g -> add_node(); int max = maxdiff; double BigProbability = 0.99999; cout << "Add Tweight" << endl; for(z=0; z<m_sizez; z++) for(y=0; y<sizey; y++) for(x=0; x<sizex; x++) { I1 = m_Volume[z][y][x] - m_TargetValue; if (I1 > max) { P1 = 0.5 + ((double)max/probmax); P2 = 1 - P1; } else if (I1 < -max) { P1 = 0.5 - ((double)max/probmax); P2 = 1 - P1; } else { P1 = 0.5 + I1/probmax; P2 = 0.5 - I1/probmax; } /* if (User[z][y][x] == OBJECT) // if (UserOB[z][y][x]) { P1 = BigProbability; P2 = 1.0 - P1; } if (User[z][y][x] == BACKGROUND) { P2 = BigProbability; P1 = 1.0 - P2; }*/ cap1 = -Lamda_1 * log(P2); // source cap cap2 = -Lamda_1 * log(P1); // sink cap // cap1 = - log(P2); // source cap // cap2 = - log(P1); // sink cap g -> add_tweights(z*sizexy + y*sizex + x, cap1, cap2); } cout << "Add Edge" << endl; for(z=0; z<m_sizez; z++) for(y=0; y<(sizey-1); y++) for(x=0; x<sizex; x++){ node1 = z*sizexy + y*sizex + x; node2 = z*sizexy + (y+1)*sizex + x; I1 = m_Volume[z][y][x]; I2 = m_Volume[z][y+1][x]; // cap = Lamda_2 * exp(-(I1-I2)*(I1-I2)/sigma1); // cap = Lamda_2 * exp(-(I1-I2)*(I1-I2)/sigma2); cap = Lamda_2 * DifferenceFunction(I1-I2); // edgeValue = Edge[z][y][x]; // cap = Lamda_2 * exp(-(double)(edgeValue * edgeValue / 10)); if (I1 > I2){ cap1 = cap; // forward direction cap cap2 = cap; // reverse direction cap } else{ cap1 = cap; // forward direction cap cap2 = cap; // reverse direction cap } g -> add_edge(node1, node2, cap1, cap2); } for(z=0; z<m_sizez; z++) for(y=0; y<sizey; y++) for(x=0; x<(sizex-1); x++){ node1 = z*sizexy + y*sizex + x; node2 = z*sizexy + y*sizex + (x+1); I1 = m_Volume[z][y][x]; I2 = m_Volume[z][y][x+1]; // cap = Lamda_2 * exp(-(I1-I2)*(I1-I2)/sigma1); // cap = Lamda_2 * exp(-(I1-I2)*(I1-I2)/sigma2); cap = Lamda_2 * DifferenceFunction(I1-I2); // edgeValue = Edge[z][y][x]; // cap = Lamda_2 * exp(-(double)(edgeValue * edgeValue / 10)); if (I1 > I2){ cap1 = cap; // forward direction cap cap2 = cap; // reverse direction cap } else{ cap1 = cap; // forward direction cap cap2 = cap; // reverse direction cap } g -> add_edge(node1, node2, cap1, cap2); } for(z=0; z<(m_sizez-1); z++) for(y=0; y<sizey; y++) for(x=0; x<sizex; x++){ node1 = z*sizexy + y*sizex + x; node2 = (z+1)*sizexy + y*sizex + x; I1 = m_Volume[z][y][x]; I2 = m_Volume[z+1][y][x]; // cap = Lamda_2 * exp(-(I1-I2)*(I1-I2)/sigma1); // cap = Lamda_2 * exp(-(I1-I2)*(I1-I2)/sigma2); cap = Lamda_2 * DifferenceFunction(I1-I2); // edgeValue = Edge[z][y][x]; // cap = Lamda_2 * exp(-(double)(edgeValue * edgeValue / 10)); if (I1 > I2){ cap1 = cap; // forward direction cap cap2 = cap; // reverse direction cap } else{ cap1 = cap; // forward direction cap cap2 = cap; // reverse direction cap } g -> add_edge(node1, node2, cap1, cap2); } cout << "Max Flow" << endl; int flow = g -> maxflow(); for(z=0; z<m_sizez; z++) for(y=0; y<sizey; y++) for(x=0; x<sizex; x++){ node1 = z*sizexy + y*sizex + x; if (g->what_segment(node1) == GraphType::SOURCE) m_Object[z][y][x] = 1; else m_Object[z][y][x] = 0; } delete g; cout << "Finished" << endl; } void InitDynamicRegionGrowing() { int x, y; for (y=0; y<sizey; y++) for (x=0; x<sizex; x++) { m_TempObject[m_currentZ][y][x] = m_Seed[m_currentZ][y][x]; } int histo[256], i, sum, num; for (i=0; i<256; i++) histo[i] = 0; for (y=0; y<sizey; y++) for (x=0; x<sizex; x++) { if (m_TempObject[m_currentZ][y][x]) histo[m_Volume[m_currentZ][y][x]] ++; } sum = 0; num = 0; for (i=0; i<256; i++) { num += histo[i]; sum += histo[i] * i; } m_ObjectMean= sum / num; sum = 0; for (i=0; i<256; i++) { sum += histo[i] * histo[i] * i; } m_ObjectVariable = sum / num - m_ObjectMean * m_ObjectMean; m_MaxIterationNo = 500; } void vFindBoundaryDRG() { int x, y; currentBoundary_clear(); for(y=0; y<sizey; y++) for(x=0; x<sizex; x++) if (((y-1) >= 0 && (m_TempObject[m_currentZ][y-1][x] != m_TempObject[m_currentZ][y][x])) || ((y+1) < sizey && (m_TempObject[m_currentZ][y+1][x] != m_TempObject[m_currentZ][y][x])) || ((x-1) >= 0 && (m_TempObject[m_currentZ][y][x-1] != m_TempObject[m_currentZ][y][x])) || ((x+1) < sizex && (m_TempObject[m_currentZ][y][x+1] != m_TempObject[m_currentZ][y][x])) ) { vPoint currentPoint; currentPoint.x = x; currentPoint.y = y; currentPoint.z = m_currentZ; currentBoundary_push_back(currentPoint); } } int vApplyThresholdDRG() { int IsInside, thres, thresdiff, IsChanged = 0; unsigned char maskBackup; int vIndex; int abn = 0; int xx, yy, zz; int oMean; nextBoundary_clear(); for (vIndex = 0; vIndex < m_CurBoundNo; vIndex ++) { xx = GetCur_x(vIndex); yy = GetCur_y(vIndex); zz = GetCur_z(vIndex); maskBackup = m_TempObject[zz][yy][xx]; thres = GetThreshold2D(xx, yy); // oMean = GetObjectMean(xx, yy, zz); if (thres < m_MinThres) thres = m_MinThres; if (thres > m_MaxThres) thres = m_MaxThres; thresdiff = m_TargetValue - thres; m_Voxel[zz][yy][xx] = m_Volume[zz][yy][xx] + thresdiff; if (m_Volume[zz][yy][xx] >= thres) m_TempObject[zz][yy][xx] = 1; else m_TempObject[zz][yy][xx] = 0; if (m_TempObject[zz][yy][xx] != maskBackup) { IsChanged = 1; vPoint currentPoint; currentPoint.x = xx; currentPoint.y = yy; currentPoint.z = zz; if (currentPoint.x > 0 && m_Boundary[zz][yy][xx - 1] == 0){ currentPoint.x = xx - 1; // currentPoint.IsInside = m_Index[zz][yy][xx - 1].TempObject; nextBoundary_push_back(currentPoint); } currentPoint.x = xx; if (currentPoint.x < sizex-1 && m_Boundary[zz][yy][xx + 1] == 0){ currentPoint.x = xx + 1; // currentPoint.IsInside = m_Index[zz][yy][xx + 1].TempObject; nextBoundary_push_back(currentPoint); } currentPoint.x = xx; if (currentPoint.y > 0 && m_Boundary[zz][yy - 1][xx] == 0){ currentPoint.y = yy - 1; // currentPoint.IsInside = m_Index[zz][yy - 1][xx].TempObject; nextBoundary_push_back(currentPoint); } currentPoint.y = yy; if (currentPoint.y < sizey-1 && m_Boundary[zz][yy + 1][xx] == 0){ currentPoint.y = yy + 1; // currentPoint.IsInside = m_Index[zz][yy + 1][xx].TempObject; nextBoundary_push_back(currentPoint); } currentPoint.y = yy; } } return IsChanged; } void IterationProcessDRG() { int IsChanged; m_IterationCnt = 0; vFindBoundaryDRG(); do{ IsChanged = vApplyThresholdDRG(); ReadyForNextIteration(); m_IterationCnt ++; }while(m_IterationCnt < m_MaxIterationNo && IsChanged); } void DynamicRegionGrowing() { MakeGaussianKernel2D(); InitDynamicRegionGrowing(); IterationProcessDRG(); int x, y, value; for (y=0; y<512; y++) for (x=0; x<512; x++) { if (m_TempObject[m_currentZ][y][x]) { m_Object[m_currentZ][y][x] = 1; m_Voxel[m_currentZ][y][x] = m_TargetValue + 1; } else { m_Object[m_currentZ][y][x] = 0; m_Voxel[m_currentZ][y][x] = m_TargetValue; } } } void LevelSet2D() { typedef float InternalPixelType; typedef itk::Image< InternalPixelType, 2 > InternalImageType; typedef itk::Image< unsigned char, 2 > OutputImageType; typedef itk::BinaryThresholdImageFilter< InternalImageType, OutputImageType > ThresholdingFilterType; typedef itk::CurvatureAnisotropicDiffusionImageFilter< InternalImageType, InternalImageType > SmoothingFilterType; typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< InternalImageType, InternalImageType > GradientFilterType; typedef itk::SigmoidImageFilter< InternalImageType, InternalImageType > SigmoidFilterType; typedef itk::FastMarchingImageFilter< InternalImageType, InternalImageType > FastMarchingFilterType; typedef itk::ShapeDetectionLevelSetImageFilter< InternalImageType, InternalImageType > ShapeDetectionFilterType; typedef FastMarchingFilterType::NodeContainer NodeContainer; typedef FastMarchingFilterType::NodeType NodeType; InternalImageType::Pointer image = InternalImageType::New(); ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New(); SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New(); GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New(); SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New(); FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();; ShapeDetectionFilterType::Pointer shapeDetection = ShapeDetectionFilterType::New(); InternalImageType::IndexType start; start[0] = 0; // first index on X start[1] = 0; // first index on Y InternalImageType::SizeType size; size[0] = sizex; // size along X size[1] = sizey; // size along Y InternalImageType::RegionType region; region.SetSize( size ); region.SetIndex( start ); image->SetRegions( region ); image->Allocate(); itk::ImageRegionIterator<InternalImageType> imageIterator1(image,image->GetRequestedRegion()); imageIterator1 = imageIterator1.Begin(); int x, y, z; for (y=0; y<512; y++) for (x=0; x<512; x++) { imageIterator1.Set((float)m_Volume[m_currentZ][y][x]); imageIterator1++; } thresholder->SetLowerThreshold( -1000.0 ); thresholder->SetUpperThreshold( 0.0 ); thresholder->SetOutsideValue( 0 ); thresholder->SetInsideValue( 255 ); sigmoid->SetOutputMinimum( 0.0 ); sigmoid->SetOutputMaximum( 1.0 ); smoothing->SetInput( image ); gradientMagnitude->SetInput( smoothing->GetOutput() ); sigmoid->SetInput( gradientMagnitude->GetOutput() ); smoothing->SetTimeStep( 0.125 ); smoothing->SetNumberOfIterations( 5 ); smoothing->SetConductanceParameter( 9.0 ); const double sigma = 1.0; gradientMagnitude->SetSigma( sigma ); const double alpha = -0.5; const double beta = 3.0; //3.0; sigmoid->SetAlpha( alpha ); sigmoid->SetBeta( beta ); NodeContainer::Pointer seeds = NodeContainer::New(); const double initialDistance = 5; const double seedValue = - initialDistance; seeds->Initialize(); int cnt = 0; for (y=0; y<512; y++) for (x=0; x<512; x++) { if (m_Seed[m_currentZ][y][x]) { InternalImageType::IndexType seedPosition; seedPosition[0] = x; seedPosition[1] = y; NodeType node; node.SetValue( seedValue ); node.SetIndex( seedPosition ); seeds->InsertElement( cnt++, node ); } } fastMarching->SetTrialPoints( seeds ); fastMarching->SetSpeedConstant( 1.0 ); fastMarching->SetOutputSize(image->GetBufferedRegion().GetSize() ); const double curvatureScaling = 0.05; const double propagationScaling = 1; shapeDetection->SetPropagationScaling( propagationScaling ); shapeDetection->SetCurvatureScaling( curvatureScaling ); shapeDetection->SetMaximumRMSError( 0.02 ); shapeDetection->SetNumberOfIterations( 800 ); fastMarching->Update(); InternalImageType::Pointer fastMarchingResult = InternalImageType::New(); fastMarchingResult = fastMarching->GetOutput(); shapeDetection->SetInput( fastMarchingResult ); shapeDetection->SetFeatureImage( sigmoid->GetOutput() ); thresholder->SetInput( shapeDetection->GetOutput() ); try { thresholder->Update(); } catch( itk::ExceptionObject & excep ) { std::cerr << "Exception caught !" << std::endl; std::cerr << excep << std::endl; } OutputImageType::Pointer outimage = thresholder->GetOutput(); itk::ImageRegionConstIterator<OutputImageType> imageIterator2(outimage,outimage->GetRequestedRegion()); imageIterator2 = imageIterator2.Begin(); int value; for (y=0; y<512; y++) for (x=0; x<512; x++) { value = imageIterator2.Get(); if (value > 128) { m_Object[m_currentZ][y][x] = 1; m_Voxel[m_currentZ][y][x] = m_TargetValue + 1; } else { m_Object[m_currentZ][y][x] = 0; m_Voxel[m_currentZ][y][x] = m_TargetValue; } imageIterator2++; } } void LevelSet3D() { typedef float InternalPixelType; typedef itk::Image< InternalPixelType, 3 > InternalImageType; typedef itk::Image< unsigned char, 3 > OutputImageType; typedef itk::BinaryThresholdImageFilter< InternalImageType, OutputImageType > ThresholdingFilterType; typedef itk::RescaleIntensityImageFilter<InternalImageType, OutputImageType> CastFilterType; typedef itk::CurvatureAnisotropicDiffusionImageFilter< InternalImageType, InternalImageType > SmoothingFilterType; typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< InternalImageType, InternalImageType > GradientFilterType; typedef itk::SigmoidImageFilter< InternalImageType, InternalImageType > SigmoidFilterType; typedef itk::FastMarchingImageFilter< InternalImageType, InternalImageType > FastMarchingFilterType; typedef itk::ShapeDetectionLevelSetImageFilter< InternalImageType, InternalImageType > ShapeDetectionFilterType; typedef itk::NumericSeriesFileNames NameGeneratorType; typedef FastMarchingFilterType::NodeContainer NodeContainer; typedef FastMarchingFilterType::NodeType NodeType; InternalImageType::Pointer image = InternalImageType::New(); ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New(); SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New(); GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New(); SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New(); FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();; ShapeDetectionFilterType::Pointer shapeDetection = ShapeDetectionFilterType::New(); NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New(); InternalImageType::IndexType start; start[0] = 0; // first index on X start[1] = 0; // first index on Y start[2] = 0; // first index on Z InternalImageType::SizeType size; size[0] = sizex; // size along X size[1] = sizey; // size along Y size[2] = m_sizez; // size along Z InternalImageType::RegionType region; region.SetSize( size ); region.SetIndex( start ); InternalImageType::SpacingType spacing; spacing[0] = 1; //0.33; // spacing along X spacing[1] = 1; //0.33; // spacing along Y spacing[2] = 4; //1.20; // spacing along Z image->SetRegions( region ); image->SetSpacing( spacing ); image->Allocate(); itk::ImageRegionIterator<InternalImageType> imageIterator1(image,image->GetRequestedRegion()); imageIterator1 = imageIterator1.Begin(); int x, y, z; for (z=0; z<m_sizez; z++) for (y=0; y<512; y++) for (x=0; x<512; x++) { imageIterator1.Set((float)m_Volume[z][y][x]); imageIterator1++; } thresholder->SetLowerThreshold( -1000.0 ); thresholder->SetUpperThreshold( 0.0 ); thresholder->SetOutsideValue( 0 ); thresholder->SetInsideValue( 255 ); sigmoid->SetOutputMinimum( 0.0 ); sigmoid->SetOutputMaximum( 1.0 ); smoothing->SetInput( image ); gradientMagnitude->SetInput( smoothing->GetOutput() ); sigmoid->SetInput( gradientMagnitude->GetOutput() ); smoothing->SetTimeStep( 0.0625 ); smoothing->SetNumberOfIterations( 5 ); smoothing->SetConductanceParameter( 9.0 ); const double sigma = 1.0; gradientMagnitude->SetSigma( sigma ); const double alpha = -0.5; const double beta = 6; //3.0; sigmoid->SetAlpha( alpha ); sigmoid->SetBeta( beta ); NodeContainer::Pointer seeds = NodeContainer::New(); const double initialDistance = 5; const double seedValue = - initialDistance; seeds->Initialize(); int cnt = 0; for (z=0; z<m_sizez; z++) for (y=0; y<512; y++) for (x=0; x<512; x++) { if (m_Seed[z][y][x]) { InternalImageType::IndexType seedPosition; seedPosition[0] = x; seedPosition[1] = y; seedPosition[2] = z; NodeType node; node.SetValue( seedValue ); node.SetIndex( seedPosition ); seeds->InsertElement( cnt++, node ); } } fastMarching->SetTrialPoints( seeds ); fastMarching->SetSpeedConstant( 1.0 ); fastMarching->SetOutputSize(image->GetBufferedRegion().GetSize() ); const double curvatureScaling = 0.5; //0.05; const double propagationScaling = 1; shapeDetection->SetPropagationScaling( propagationScaling ); shapeDetection->SetCurvatureScaling( curvatureScaling ); shapeDetection->SetMaximumRMSError( 0.02 ); shapeDetection->SetNumberOfIterations( 800 ); fastMarching->Update(); InternalImageType::Pointer fastMarchingResult = InternalImageType::New(); fastMarchingResult = fastMarching->GetOutput(); fastMarchingResult->SetSpacing( spacing ); shapeDetection->SetInput( fastMarchingResult ); shapeDetection->SetFeatureImage( sigmoid->GetOutput() ); thresholder->SetInput( shapeDetection->GetOutput() ); try { thresholder->Update(); } catch( itk::ExceptionObject & excep ) { std::cerr << "Exception caught !" << std::endl; std::cerr << excep << std::endl; } OutputImageType::Pointer outimage = thresholder->GetOutput(); itk::ImageRegionConstIterator<OutputImageType> imageIterator2(outimage,outimage->GetRequestedRegion()); imageIterator2 = imageIterator2.Begin(); int value; for (z=0; z<m_sizez; z++) for (y=0; y<512; y++) for (x=0; x<512; x++) { value = imageIterator2.Get(); if (value > 128) { m_Object[z][y][x] = 1; m_Voxel[z][y][x] = m_TargetValue + 1; } else { m_Object[z][y][x] = 0; m_Voxel[z][y][x] = 0; } imageIterator2++; } } void Segmentation(SEG_MODE SegMode, int StartLevel, int Zsize, vector<tTri> *triangles, int min, int max, int currentZ) { m_sizez = Zsize; m_HWinSizeZ = (int)(HWinSize / (sizex/Zsize) + 0.5); m_IterationCnt = 0; m_SegMode = SegMode; m_currentZ = currentZ; m_IterationCnt = 0; m_HistoMin = StartLevel - 30; m_HistoMax = 255; m_CheckRange = 50; m_MinThres = m_HistoMin; m_MaxThres = m_HistoMax; m_MaxIterationNo = 50; m_TargetValue = StartLevel; m_HUmin = min; m_HUmax = max; myOutputDebugString(_T("m_sizez : %d\n"), m_sizez); myOutputDebugString(_T("m_HWinSizeZ : %d\n"), m_HWinSizeZ); InitSegmentation(); switch(m_SegMode) { case THRESHOLD: Thresholding(); break; case ATHRESHOLD: AdaptiveThreshold3D(); break; case GRAPHCUT: GraphCutSegmentation(); MakeVoxel3D(); break; case DYNAMICREGIONGROWING: DynamicRegionGrowing(); // MakeVoxel2D(); break; case LEVELSET_2D: LevelSet2D(); // MakeVoxel2D(); break; case LEVELSET_3D: LevelSet3D(); // MakeVoxel3D(); break; } StoreSegmentationResult(); #if 0 triangles->clear(); CMarchingCube model; model.Start(m_Voxel, m_TargetValue, triangles, m_sizez); #endif DeleteMemory(); }
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
MarchingCube.cpp
.cpp
28,187
535
#include "stdafx.h" #include "MarchingCube.h" #include "Scale.h" #include "DICOM ViewerDoc.h" #include "MainFrm.h" //a2fVertexOffset lists the positions, relative to vertex0, of each of the 8 vertices of a cube static const float a2fVertexOffset[8][3] = { {0.0, 0.0, 0.0},{1.0, 0.0, 0.0},{1.0, 1.0, 0.0},{0.0, 1.0, 0.0}, {0.0, 0.0, 1.0},{1.0, 0.0, 1.0},{1.0, 1.0, 1.0},{0.0, 1.0, 1.0} }; //a2iEdgeConnection lists the index of the endpoint vertices for each of the 12 edges of the cube static const int a2iEdgeConnection[12][2] = { {0,1}, {1,2}, {2,3}, {3,0}, {4,5}, {5,6}, {6,7}, {7,4}, {0,4}, {1,5}, {2,6}, {3,7} }; //a2fEdgeDirection lists the direction vector (vertex1-vertex0) for each edge in the cube static const float a2fEdgeDirection[12][3] = { {1.0, 0.0, 0.0},{0.0, 1.0, 0.0},{-1.0, 0.0, 0.0},{0.0, -1.0, 0.0}, {1.0, 0.0, 0.0},{0.0, 1.0, 0.0},{-1.0, 0.0, 0.0},{0.0, -1.0, 0.0}, {0.0, 0.0, 1.0},{0.0, 0.0, 1.0},{ 0.0, 0.0, 1.0},{0.0, 0.0, 1.0} }; // For any edge, if one vertex is inside of the surface and the other is outside of the surface // then the edge intersects the surface // For each of the 4 vertices of the tetrahedron can be two possible states : either inside or outside of the surface // For any tetrahedron the are 2^4=16 possible sets of vertex states // This table lists the edges intersected by the surface for all 16 possible vertex states // There are 6 edges. For each entry in the table, if edge #n is intersected, then bit #n is set to 1 int aiTetrahedronEdgeFlags[16]= { 0x00, 0x0d, 0x13, 0x1e, 0x26, 0x2b, 0x35, 0x38, 0x38, 0x35, 0x2b, 0x26, 0x1e, 0x13, 0x0d, 0x00, }; // For each of the possible vertex states listed in aiTetrahedronEdgeFlags there is a specific triangulation // of the edge intersection points. a2iTetrahedronTriangles lists all of them in the form of // 0-2 edge triples with the list terminated by the invalid value -1. // // I generated this table by hand int a2iTetrahedronTriangles[16][7] = { {-1, -1, -1, -1, -1, -1, -1}, { 0, 3, 2, -1, -1, -1, -1}, { 0, 1, 4, -1, -1, -1, -1}, { 1, 4, 2, 2, 4, 3, -1}, { 1, 2, 5, -1, -1, -1, -1}, { 0, 3, 5, 0, 5, 1, -1}, { 0, 2, 5, 0, 5, 4, -1}, { 5, 4, 3, -1, -1, -1, -1}, { 3, 4, 5, -1, -1, -1, -1}, { 4, 5, 0, 5, 2, 0, -1}, { 1, 5, 0, 5, 3, 0, -1}, { 5, 2, 1, -1, -1, -1, -1}, { 3, 4, 2, 2, 4, 1, -1}, { 4, 1, 0, -1, -1, -1, -1}, { 2, 3, 0, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1}, }; // For any edge, if one vertex is inside of the surface and the other is outside of the surface // then the edge intersects the surface // For each of the 8 vertices of the cube can be two possible states : either inside or outside of the surface // For any cube the are 2^8=256 possible sets of vertex states // This table lists the edges intersected by the surface for all 256 possible vertex states // There are 12 edges. For each entry in the table, if edge #n is intersected, then bit #n is set to 1 int aiCubeEdgeFlags[256]= { 0x000, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, 0x190, 0x099, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, 0x230, 0x339, 0x033, 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30, 0x3a0, 0x2a9, 0x1a3, 0x0aa, 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0, 0x460, 0x569, 0x663, 0x76a, 0x066, 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60, 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0x0ff, 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x055, 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950, 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0x0cc, 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 0x0cc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0, 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x055, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650, 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0x0ff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0, 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x066, 0x76a, 0x663, 0x569, 0x460, 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0x0aa, 0x1a3, 0x2a9, 0x3a0, 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x033, 0x339, 0x230, 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x099, 0x190, 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x000 }; // For each of the possible vertex states listed in aiCubeEdgeFlags there is a specific triangulation // of the edge intersection points. a2iTriangleConnectionTable lists all of them in the form of // 0-5 edge triples with the list terminated by the invalid value -1. // For example: a2iTriangleConnectionTable[3] list the 2 triangles formed when corner[0] // and corner[1] are inside of the surface, but the rest of the cube is not. // // I found this table in an example program someone wrote long ago. It was probably generated by hand int a2iTriangleConnectionTable[256][16] = { {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1}, {3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1}, {3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1}, {3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1}, {9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1}, {9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1}, {2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1}, {8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1}, {9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1}, {4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1}, {3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1}, {1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1}, {4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1}, {4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1}, {5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1}, {2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1}, {9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1}, {0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1}, {2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1}, {10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1}, {5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1}, {5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1}, {9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1}, {0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1}, {1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1}, {10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1}, {8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1}, {2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1}, {7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1}, {2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1}, {11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1}, {5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1}, {11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1}, {11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1}, {1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1}, {9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1}, {5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1}, {2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1}, {5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1}, {6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1}, {3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1}, {6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1}, {5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1}, {1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1}, {10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1}, {6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1}, {8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1}, {7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1}, {3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1}, {5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1}, {0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1}, {9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1}, {8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1}, {5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1}, {0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1}, {6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1}, {10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1}, {10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1}, {8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1}, {1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1}, {0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1}, {10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1}, {3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1}, {6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1}, {9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1}, {8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1}, {3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1}, {6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1}, {0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1}, {10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1}, {10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1}, {2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1}, {7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1}, {7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1}, {2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1}, {1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1}, {11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1}, {8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1}, {0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1}, {7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1}, {10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1}, {2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1}, {6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1}, {7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1}, {2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1}, {1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1}, {10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1}, {10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1}, {0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1}, {7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1}, {6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1}, {8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1}, {9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1}, {6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1}, {4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1}, {10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1}, {8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1}, {0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1}, {1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1}, {8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1}, {10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1}, {4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1}, {10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1}, {5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1}, {11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1}, {9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1}, {6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1}, {7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1}, {3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1}, {7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1}, {3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1}, {6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1}, {9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1}, {1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1}, {4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1}, {7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1}, {6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1}, {3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1}, {0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1}, {6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1}, {0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1}, {11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1}, {6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1}, {5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1}, {9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1}, {1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1}, {1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1}, {10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1}, {0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1}, {5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1}, {10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1}, {11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1}, {9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1}, {7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1}, {2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1}, {8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1}, {9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1}, {9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1}, {1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1}, {9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1}, {9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1}, {5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1}, {0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1}, {10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1}, {2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1}, {0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1}, {0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1}, {9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1}, {5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1}, {3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1}, {5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1}, {8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1}, {0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1}, {9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1}, {1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1}, {3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1}, {4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1}, {9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1}, {11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1}, {11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1}, {2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1}, {9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1}, {3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1}, {1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1}, {4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1}, {3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1}, {0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1}, {9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1}, {1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1} }; CMarchingCube::CMarchingCube() { // TODO: ¿©±â¿¡ »ý¼º Äڵ带 Ãß°¡ÇÕ´Ï´Ù. } CMarchingCube::~CMarchingCube() { } float CMarchingCube::VoxelVal( float fX, float fY, float fZ) { int x, y, z; x = (int)fX; y = (int)fY; z = (int)fZ; if (x >= sizex || y >= sizey || z >= m_sizez) return 0; else return (float)(m_Volume[z][y][x]); } //fGetOffset finds the approximate point of intersection of the surface // between two points with the values fValue1 and fValue2 float CMarchingCube::fGetOffset(float fValue1, float fValue2, float fValueDesired) { float fDelta = fValue2 - fValue1; if(fDelta == 0.0) { return 0.5; } return (fValueDesired - fValue1)/fDelta; } void CMarchingCube::GetNormal(tVector &rfNormal, float *p1, float *p2, float *p3) { tVector v1, v2; v1.fX = p2[0] - p1[0]; v1.fY = p2[1] - p1[1]; v1.fZ = p2[2] - p1[2]; v2.fX = p3[0] - p1[0]; v2.fY = p3[1] - p1[1]; v2.fZ = p3[2] - p1[2]; rfNormal.fX = v1.fY*v2.fZ - v1.fZ*v2.fY; rfNormal.fY = v1.fZ*v2.fX - v1.fX*v2.fZ; rfNormal.fZ = v1.fX*v2.fY - v1.fY*v2.fX; float size = sqrt(rfNormal.fX*rfNormal.fX + rfNormal.fY*rfNormal.fY + rfNormal.fZ*rfNormal.fZ); rfNormal.fX /= size; rfNormal.fY /= size; rfNormal.fZ /= size; } //vMarchCube1 performs the Marching Cubes algorithm on a single cube void CMarchingCube::MarchingCube(float fX, float fY, float fZ, vector<tTri> *triangles, COLORREF _color) { extern int aiCubeEdgeFlags[256]; extern int a2iTriangleConnectionTable[256][16]; int iCorner, iVertex, iVertexTest, iEdge, iTriangle, iFlagIndex, iEdgeFlags; float fOffset; tVector sColor; float afCubeValue[8]; tVector asEdgeVertex[12]; tVector asEdgeNorm[12]; //Make a local copy of the values at the cube's corners for(iVertex = 0; iVertex < 8; iVertex++) { afCubeValue[iVertex] = VoxelVal(fX + a2fVertexOffset[iVertex][0], fY + a2fVertexOffset[iVertex][1], fZ + a2fVertexOffset[iVertex][2]); } //Find which vertices are inside of the surface and which are outside iFlagIndex = 0; for(iVertexTest = 0; iVertexTest < 8; iVertexTest++) { if(afCubeValue[iVertexTest] <= m_thres) iFlagIndex |= 1<<iVertexTest; } //Find which edges are intersected by the surface iEdgeFlags = aiCubeEdgeFlags[iFlagIndex]; //If the cube is entirely inside or outside of the surface, then there will be no intersections if(iEdgeFlags == 0) { return; } //Find the point of intersection of the surface with each edge //Then find the normal to the surface at those points for(iEdge = 0; iEdge < 12; iEdge++) { //if there is an intersection on this edge if(iEdgeFlags & (1<<iEdge)) { fOffset = fGetOffset(afCubeValue[ a2iEdgeConnection[iEdge][0] ], afCubeValue[ a2iEdgeConnection[iEdge][1] ], m_thres); asEdgeVertex[iEdge].fX = fX + (a2fVertexOffset[ a2iEdgeConnection[iEdge][0] ][0] + fOffset * a2fEdgeDirection[iEdge][0]); asEdgeVertex[iEdge].fY = fY + (a2fVertexOffset[ a2iEdgeConnection[iEdge][0] ][1] + fOffset * a2fEdgeDirection[iEdge][1]); asEdgeVertex[iEdge].fZ = fZ + (a2fVertexOffset[ a2iEdgeConnection[iEdge][0] ][2] + fOffset * a2fEdgeDirection[iEdge][2]); // vGetNormal(asEdgeNorm[iEdge], asEdgeVertex[iEdge].fX, asEdgeVertex[iEdge].fY, asEdgeVertex[iEdge].fZ); } } //Draw the triangles that were found. There can be up to five per cube for(iTriangle = 0; iTriangle < 5; iTriangle++) { if(a2iTriangleConnectionTable[iFlagIndex][3*iTriangle] < 0) break; tTri tri; tri.normal[0] = 0.0; tri.normal[1] = 0.0; tri.normal[2] = 0.0; for(iCorner = 0; iCorner < 3; iCorner++) { iVertex = a2iTriangleConnectionTable[iFlagIndex][3*iTriangle+iCorner]; tri.vertex[iCorner][0] = asEdgeVertex[iVertex].fX * 0.04 - 10; tri.vertex[iCorner][1] = asEdgeVertex[iVertex].fY * 0.04 - 10; tri.vertex[iCorner][2] = asEdgeVertex[iVertex].fZ * 0.04 - 3; tri.vertex[iCorner][2] *= m_Vfactor; } tVector vNormal; GetNormal(vNormal, tri.vertex[0], tri.vertex[1], tri.vertex[2]); tri.normal[0] = vNormal.fX; tri.normal[1] = vNormal.fY; tri.normal[2] = vNormal.fZ; tri.Attr = 0; tri.color = _color; triangles->push_back(tri); } } //vMarchingCubes iterates over the entire dataset, calling vMarchCube on each cube void CMarchingCube::Start(int threshold, vector<tTri> *triangles, int sizez) { CDICOMViewerDoc* pDoc = (CDICOMViewerDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument(); if(!pDoc) return; int x, y, z; m_thres = (float)threshold; m_sizez = sizez; m_Vfactor = sizex / m_sizez; for(z = 0; z < m_sizez-1; z++) for(y = 0; y < sizey-1; y++) for(x = 0; x < sizex-1; x++) { int lux = m_Volume[z][y][x]; // int lux_d = DICOMtoImage(lux, pDoc->m_HUmin, pDoc->m_HUmax); // if (lux_d < 0) lux_d = 0; // if (lux_d > 255) lux_d = 255; COLORREF c = GetKeyColor(lux); MarchingCube(x, y, z, triangles, c); } }
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
glsl.cpp
.cpp
50,247
1,971
/******************************************************************** glsl.cpp Version: 1.0.0_rc5 Last update: 2006/11/12 (Geometry Shader Support) (c) 2003-2006 by Martin Christen. All Rights reserved. *********************************************************************/ #include "stdAfx.h" #include "glsl.h" #include <stdlib.h> #include <stdio.h> #include <iostream> #include <fstream> #include <algorithm> #include <math.h> using namespace std; using namespace cwc; bool useGLSL = false; bool extensions_init = false; bool bGeometryShader = false; bool bGPUShader4 = false; //----------------------------------------------------------------------------- /*! \mainpage \section s_intro Introduction This is libglsl - a collection of helper classes to load, compile, link and activate shaders written in the OpenGL Shading language. Vertex Shaders, Geometry Shaders and Fragment shaders are supported (if the hardware is capable of supporting them, of course). Version info: \ref s_libglslnews \section s_examples Examples \subsection Loading Vertex and Fragment Shader using Shader Manager. \verbatim Initialization: glShaderManager SM; glShader *shader = SM.loadfromFile("test.vert","test.frag"); if (shader==0) cout << "Error Loading, compiling or linking shader\n"; Render: shader->begin(); shader->setUniform1f("MyFloat", 1.123); glutDrawSolidSphere(1.0); shader->end(); \endverbatim \subsection geom_shader Geometry Shader The easiest way to use Geometry Shaders is through the Shadermanager. Initialization: \verbatim SM.SetInputPrimitiveType(GL_TRIANGLES); SM.SetOutputPrimitiveType(GL_TRIANGLE_STRIP); SM.SetVerticesOut(3); glShader *shader = SM.loadfromFile("test.vert","test.geom","test.frag"); \endverbatim */ namespace cwc { //----------------------------------------------------------------------------- // Error, Warning and Info Strings char* aGLSLStrings[] = { "[e00] GLSL is not available!", "[e01] Not a valid program object!", "[e02] Not a valid object!", "[e03] Out of memory!", "[e04] Unknown compiler error!", "[e05] Linker log is not available!", "[e06] Compiler log is not available!", "[Empty]" }; //----------------------------------------------------------------------------- // GL ERROR CHECK int CheckGLError(char *file, int line) { GLenum glErr; int retCode = 0; glErr = glGetError(); while (glErr != GL_NO_ERROR) { const GLubyte* sError = gluErrorString(glErr); if (sError) cout << "GL Error #" << glErr << "(" << gluErrorString(glErr) << ") " << " in File " << file << " at line: " << line << endl; else cout << "GL Error #" << glErr << " (no message available)" << " in File " << file << " at line: " << line << endl; retCode = 1; glErr = glGetError(); } return retCode; } #define CHECK_GL_ERROR() CheckGLError(__FILE__, __LINE__) //----------------------------------------------------------------------------- bool InitOpenGLExtensions(void) { if (extensions_init) return true; extensions_init = true; GLenum err = glewInit(); if (GLEW_OK != err) { cout << "Error:" << glewGetErrorString(err) << endl; extensions_init = false; return false; } cout << "OpenGL Vendor: " << (char*) glGetString(GL_VENDOR) << "\n"; cout << "OpenGL Renderer: " << (char*) glGetString(GL_RENDERER) << "\n"; cout << "OpenGL Version: " << (char*) glGetString(GL_VERSION) << "\n\n"; //cout << "OpenGL Extensions:\n" << (char*) glGetString(GL_EXTENSIONS) << "\n\n"; HasGLSLSupport(); return true; } bool HasGLSLSupport(void) { bGeometryShader = HasGeometryShaderSupport(); bGPUShader4 = HasShaderModel4(); if (useGLSL) return true; // already initialized and GLSL is available useGLSL = true; if (!extensions_init) InitOpenGLExtensions(); // extensions were not yet initialized!! if (GLEW_VERSION_2_0) { cout << "OpenGL 2.0 (or higher) is available!" << endl; } else if (GLEW_VERSION_1_5) { cout << "OpenGL 1.5 core functions are available" << endl; } else if (GLEW_VERSION_1_4) { cout << "OpenGL 1.4 core functions are available" << endl; } else if (GLEW_VERSION_1_3) { cout << "OpenGL 1.3 core functions are available" << endl; } else if (GLEW_VERSION_1_2) { cout << "OpenGL 1.2 core functions are available" << endl; } if (GL_TRUE != glewGetExtension("GL_ARB_fragment_shader")) { cout << "[WARNING] GL_ARB_fragment_shader extension is not available!\n"; useGLSL = false; } if (GL_TRUE != glewGetExtension("GL_ARB_vertex_shader")) { cout << "[WARNING] GL_ARB_vertex_shader extension is not available!\n"; useGLSL = false; } if (GL_TRUE != glewGetExtension("GL_ARB_shader_objects")) { cout << "[WARNING] GL_ARB_shader_objects extension is not available!\n"; useGLSL = false; } if (useGLSL) { cout << "[OK] OpenGL Shading Language is available!\n\n"; } else { cout << "[FAILED] OpenGL Shading Language is not available...\n\n"; } return useGLSL; } bool HasOpenGL2Support(void) { if (!extensions_init) InitOpenGLExtensions(); return (GLEW_VERSION_2_0 == GL_TRUE); } bool HasGeometryShaderSupport(void) { if (GL_TRUE != glewGetExtension("GL_EXT_geometry_shader4")) return false; return true; } bool HasShaderModel4(void) { if (GL_TRUE != glewGetExtension("GL_EXT_gpu_shader4")) return false; return true; } } //----------------------------------------------------------------------------- // ************************************************************************ // Implementation of glShader class // ************************************************************************ glShader::glShader() { InitOpenGLExtensions(); ProgramObject = 0; linker_log = 0; is_linked = false; _mM = false; _noshader = true; if (!useGLSL) { cout << "**ERROR: OpenGL Shading Language is NOT available!" << endl; } else { ProgramObject = glCreateProgram(); } } //----------------------------------------------------------------------------- glShader::~glShader() { if (linker_log!=0) free(linker_log); if (useGLSL) { for (unsigned int i=0;i<ShaderList.size();i++) { glDetachShader(ProgramObject, ShaderList[i]->ShaderObject); CHECK_GL_ERROR(); // if you get an error here, you deleted the Program object first and then // the ShaderObject! Always delete ShaderObjects last! if (_mM) delete ShaderList[i]; } glDeleteShader(ProgramObject); CHECK_GL_ERROR(); } } //----------------------------------------------------------------------------- void glShader::addShader(glShaderObject* ShaderProgram) { if (!useGLSL) return; if (ShaderProgram==0) return; if (!ShaderProgram->is_compiled) { cout << "**warning** please compile program before adding object! trying to compile now...\n"; if (!ShaderProgram->compile()) { cout << "...compile ERROR!\n"; return; } else { cout << "...ok!\n"; } } ShaderList.push_back(ShaderProgram); } //----------------------------------------------------------------------------- void glShader::SetInputPrimitiveType(int nInputPrimitiveType) { _nInputPrimitiveType = nInputPrimitiveType; } void glShader::SetOutputPrimitiveType(int nOutputPrimitiveType) { _nOutputPrimitiveType = nOutputPrimitiveType; } void glShader::SetVerticesOut(int nVerticesOut) { _nVerticesOut = nVerticesOut; } //----------------------------------------------------------------------------- bool glShader::link(void) { if (!useGLSL) return false; unsigned int i; if (_bUsesGeometryShader) { glProgramParameteriEXT(ProgramObject, GL_GEOMETRY_INPUT_TYPE_EXT, _nInputPrimitiveType); glProgramParameteriEXT(ProgramObject, GL_GEOMETRY_OUTPUT_TYPE_EXT, _nOutputPrimitiveType); glProgramParameteriEXT(ProgramObject, GL_GEOMETRY_VERTICES_OUT_EXT, _nVerticesOut); } if (is_linked) // already linked, detach everything first { cout << "**warning** Object is already linked, trying to link again" << endl; for (i=0;i<ShaderList.size();i++) { glDetachShader(ProgramObject, ShaderList[i]->ShaderObject); CHECK_GL_ERROR(); } } for (i=0;i<ShaderList.size();i++) { glAttachShader(ProgramObject, ShaderList[i]->ShaderObject); CHECK_GL_ERROR(); //cout << "attaching ProgramObj [" << i << "] @ 0x" << hex << ShaderList[i]->ProgramObject << " in ShaderObj @ 0x" << ShaderObject << endl; } GLint linked; // bugfix Oct-06-2006 glLinkProgram(ProgramObject); CHECK_GL_ERROR(); glGetProgramiv(ProgramObject, GL_LINK_STATUS, &linked); CHECK_GL_ERROR(); if (linked) { is_linked = true; return true; } else { cout << "**linker error**\n"; } return false; } //----------------------------------------------------------------------------- // Compiler Log: Ausgabe der Compiler Meldungen in String char* glShader::getLinkerLog(void) { if (!useGLSL) return aGLSLStrings[0]; GLint blen = 0; // bugfix Oct-06-2006 GLsizei slen = 0; // bugfix Oct-06-2006 if (ProgramObject==0) return aGLSLStrings[2]; glGetProgramiv(ProgramObject, GL_INFO_LOG_LENGTH , &blen); CHECK_GL_ERROR(); if (blen > 1) { if (linker_log!=0) { free(linker_log); linker_log =0; } if ((linker_log = (GLcharARB*)malloc(blen)) == NULL) { printf("ERROR: Could not allocate compiler_log buffer\n"); return aGLSLStrings[3]; } glGetProgramInfoLog(ProgramObject, blen, &slen, linker_log); CHECK_GL_ERROR(); } if (linker_log!=0) return (char*) linker_log; else return aGLSLStrings[5]; return aGLSLStrings[4]; } void glShader::begin(void) { if (!useGLSL) return; if (ProgramObject == 0) return; if (!_noshader) return; if (is_linked) { glUseProgram(ProgramObject); CHECK_GL_ERROR(); } } //----------------------------------------------------------------------------- void glShader::end(void) { if (!useGLSL) return; if (!_noshader) return; glUseProgram(0); CHECK_GL_ERROR(); } //----------------------------------------------------------------------------- bool glShader::setUniform1f(GLcharARB* varname, GLfloat v0, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform1f(loc, v0); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform2f(GLcharARB* varname, GLfloat v0, GLfloat v1, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform2f(loc, v0, v1); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform3f(GLcharARB* varname, GLfloat v0, GLfloat v1, GLfloat v2, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform3f(loc, v0, v1, v2); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform4f(GLcharARB* varname, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform4f(loc, v0, v1, v2, v3); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform1i(GLcharARB* varname, GLint v0, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform1i(loc, v0); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform2i(GLcharARB* varname, GLint v0, GLint v1, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform2i(loc, v0, v1); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform3i(GLcharARB* varname, GLint v0, GLint v1, GLint v2, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform3i(loc, v0, v1, v2); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform4i(GLcharARB* varname, GLint v0, GLint v1, GLint v2, GLint v3, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform4i(loc, v0, v1, v2, v3); return true; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- bool glShader::setUniform1ui(GLcharARB* varname, GLuint v0, GLint index) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform1uiEXT(loc, v0); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform2ui(GLcharARB* varname, GLuint v0, GLuint v1, GLint index) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform2uiEXT(loc, v0, v1); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform3ui(GLcharARB* varname, GLuint v0, GLuint v1, GLuint v2, GLint index) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform3uiEXT(loc, v0, v1, v2); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform4ui(GLcharARB* varname, GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLint index) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform4uiEXT(loc, v0, v1, v2, v3); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform1fv(GLcharARB* varname, GLsizei count, GLfloat *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform1fv(loc, count, value); return true; } bool glShader::setUniform2fv(GLcharARB* varname, GLsizei count, GLfloat *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform2fv(loc, count, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform3fv(GLcharARB* varname, GLsizei count, GLfloat *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform3fv(loc, count, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform4fv(GLcharARB* varname, GLsizei count, GLfloat *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform4fv(loc, count, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform1iv(GLcharARB* varname, GLsizei count, GLint *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform1iv(loc, count, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform2iv(GLcharARB* varname, GLsizei count, GLint *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform2iv(loc, count, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform3iv(GLcharARB* varname, GLsizei count, GLint *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform3iv(loc, count, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform4iv(GLcharARB* varname, GLsizei count, GLint *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform4iv(loc, count, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform1uiv(GLcharARB* varname, GLsizei count, GLuint *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform1uivEXT(loc, count, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform2uiv(GLcharARB* varname, GLsizei count, GLuint *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform2uivEXT(loc, count, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform3uiv(GLcharARB* varname, GLsizei count, GLuint *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform3uivEXT(loc, count, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniform4uiv(GLcharARB* varname, GLsizei count, GLuint *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniform4uivEXT(loc, count, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniformMatrix2fv(GLcharARB* varname, GLsizei count, GLboolean transpose, GLfloat *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniformMatrix2fv(loc, count, transpose, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniformMatrix3fv(GLcharARB* varname, GLsizei count, GLboolean transpose, GLfloat *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniformMatrix3fv(loc, count, transpose, value); return true; } //----------------------------------------------------------------------------- bool glShader::setUniformMatrix4fv(GLcharARB* varname, GLsizei count, GLboolean transpose, GLfloat *value, GLint index) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return false; // can't find variable / invalid index glUniformMatrix4fv(loc, count, transpose, value); return true; } //----------------------------------------------------------------------------- GLint glShader::GetUniformLocation(const GLcharARB *name) { GLint loc; loc = glGetUniformLocation(ProgramObject, name); if (loc == -1) { cout << "Error: can't find uniform variable \"" << name << "\"\n"; } CHECK_GL_ERROR(); return loc; } //----------------------------------------------------------------------------- void glShader::getUniformfv(GLcharARB* varname, GLfloat* values, GLint index) { if (!useGLSL) return; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return; // can't find variable / invalid index glGetUniformfv(ProgramObject, loc, values); } //----------------------------------------------------------------------------- void glShader::getUniformiv(GLcharARB* varname, GLint* values, GLint index) { if (!useGLSL) return; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return; // can't find variable / invalid index glGetUniformiv(ProgramObject, loc, values); } //----------------------------------------------------------------------------- void glShader::getUniformuiv(GLcharARB* varname, GLuint* values, GLint index) { if (!useGLSL) return; GLint loc; if (varname) loc = GetUniformLocation(varname); else loc = index; if (loc==-1) return; // can't find variable / invalid index glGetUniformuivEXT(ProgramObject, loc, values); } //----------------------------------------------------------------------------- void glShader::BindAttribLocation(GLint index, GLchar* name) { glBindAttribLocation(ProgramObject, index, name); } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib1f(GLuint index, GLfloat v0) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib1f(index, v0); return true; } bool glShader::setVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib2f(index, v0, v1); return true; } bool glShader::setVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib3f(index, v0, v1, v2); return true; } bool glShader::setVertexAttrib4f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib4f(index, v0, v1, v2, v3); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib1d(GLuint index, GLdouble v0) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib1d(index, v0); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib2d(GLuint index, GLdouble v0, GLdouble v1) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib2d(index, v0, v1); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib3d(GLuint index, GLdouble v0, GLdouble v1, GLdouble v2) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib3d(index, v0, v1, v2); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib4d(GLuint index, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib4d(index, v0, v1, v2, v3); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib1s(GLuint index, GLshort v0) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib1s(index, v0); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib2s(GLuint index, GLshort v0, GLshort v1) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib2s(index, v0, v1); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib3s(GLuint index, GLshort v0, GLshort v1, GLshort v2) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib3s(index, v0, v1, v2); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib4s(GLuint index, GLshort v0, GLshort v1, GLshort v2, GLshort v3) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib4s(index, v0, v1, v2, v3); return true; } //---------------------------------------------------------------------------- bool glShader::setVertexAttribNormalizedByte(GLuint index, GLbyte v0, GLbyte v1, GLbyte v2, GLbyte v3) { if (!useGLSL) return false; // GLSL not available if (!_noshader) return true; glVertexAttrib4Nub(index, v0, v1, v2, v3); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib1i(GLuint index, GLint v0) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; glVertexAttribI1iEXT(index, v0); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib2i(GLuint index, GLint v0, GLint v1) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; glVertexAttribI2iEXT(index, v0, v1); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib3i(GLuint index, GLint v0, GLint v1, GLint v2) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; glVertexAttribI3iEXT(index, v0, v1, v2); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib4i(GLuint index, GLint v0, GLint v1, GLint v2, GLint v3) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; glVertexAttribI4iEXT(index, v0, v1, v2, v3); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib1ui(GLuint index, GLuint v0) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; glVertexAttribI1uiEXT(index, v0); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib2ui(GLuint index, GLuint v0, GLuint v1) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; glVertexAttribI2uiEXT(index, v0, v1); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib3ui(GLuint index, GLuint v0, GLuint v1, GLuint v2) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; glVertexAttribI3uiEXT(index, v0, v1, v2); return true; } //----------------------------------------------------------------------------- bool glShader::setVertexAttrib4ui(GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3) { if (!useGLSL) return false; // GLSL not available if (!bGPUShader4) return false; if (!_noshader) return true; glVertexAttribI4uiEXT(index, v0, v1, v2, v3); return true; } //----------------------------------------------------------------------------- // ************************************************************************ // Shader Program : Manage Shader Programs (Vertex/Fragment) // ************************************************************************ glShaderObject::glShaderObject() { InitOpenGLExtensions(); compiler_log = 0; is_compiled = false; program_type = 0; ShaderObject = 0; ShaderSource = 0; _memalloc = false; } //----------------------------------------------------------------------------- glShaderObject::~glShaderObject() { if (compiler_log!=0) free(compiler_log); if (ShaderSource!=0) { if (_memalloc) delete[] ShaderSource; // free ASCII Source } if (is_compiled) { glDeleteObjectARB(ShaderObject); CHECK_GL_ERROR(); } } //----------------------------------------------------------------------------- unsigned long getFileLength(ifstream& file) { if(!file.good()) return 0; unsigned long pos=file.tellg(); file.seekg(0,ios::end); unsigned long len = file.tellg(); file.seekg(ios::beg); return len; } //----------------------------------------------------------------------------- int glShaderObject::load(char* filename) { ifstream file; file.open(filename, ios::in); if(!file) return -1; unsigned long len = getFileLength(file); if (len==0) return -2; // "Empty File" if (ShaderSource!=0) // there is already a source loaded, free it! { if (_memalloc) delete[] ShaderSource; } ShaderSource = (GLubyte*) new char[len+1]; if (ShaderSource == 0) return -3; // can't reserve memory _memalloc = true; ShaderSource[len] = 0; // len isn't always strlen cause some characters are stripped in ascii read... // it is important to 0-terminate the real length later, len is just max possible value... unsigned int i=0; while (file.good()) { ShaderSource[i] = file.get(); // get character from file. if (!file.eof()) i++; } ShaderSource[i] = 0; // 0 terminate it. file.close(); return 0; } //----------------------------------------------------------------------------- void glShaderObject::loadFromMemory(const char* program) { if (ShaderSource!=0) // there is already a source loaded, free it! { if (_memalloc) delete[] ShaderSource; } _memalloc = false; ShaderSource = (GLubyte*) program; } // ---------------------------------------------------------------------------- // Compiler Log: Ausgabe der Compiler Meldungen in String char* glShaderObject::getCompilerLog(void) { if (!useGLSL) return aGLSLStrings[0]; GLint blen = 0; GLsizei slen = 0; if (ShaderObject==0) return aGLSLStrings[1]; // not a valid program object glGetShaderiv(ShaderObject, GL_INFO_LOG_LENGTH , &blen); CHECK_GL_ERROR(); if (blen > 1) { if (compiler_log!=0) { free(compiler_log); compiler_log =0; } if ((compiler_log = (GLcharARB*)malloc(blen)) == NULL) { printf("ERROR: Could not allocate compiler_log buffer\n"); return aGLSLStrings[3]; } glGetInfoLogARB(ShaderObject, blen, &slen, compiler_log); CHECK_GL_ERROR(); //cout << "compiler_log: \n", compiler_log); } if (compiler_log!=0) return (char*) compiler_log; else return aGLSLStrings[6]; return aGLSLStrings[4]; } // ---------------------------------------------------------------------------- bool glShaderObject::compile(void) { if (!useGLSL) return false; is_compiled = false; GLint compiled = 0; if (ShaderSource==0) return false; GLint length = (GLint) strlen((const char*)ShaderSource); glShaderSourceARB(ShaderObject, 1, (const GLcharARB **)&ShaderSource, &length); CHECK_GL_ERROR(); glCompileShaderARB(ShaderObject); CHECK_GL_ERROR(); glGetObjectParameterivARB(ShaderObject, GL_COMPILE_STATUS, &compiled); CHECK_GL_ERROR(); if (compiled) is_compiled=true; return is_compiled; } // ---------------------------------------------------------------------------- GLint glShaderObject::getAttribLocation(char* attribName) { return glGetAttribLocationARB(ShaderObject, attribName); } // ---------------------------------------------------------------------------- aVertexShader::aVertexShader() { program_type = 1; if (useGLSL) { ShaderObject = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); CHECK_GL_ERROR(); } } // ---------------------------------------------------- aVertexShader::~aVertexShader() { } // ---------------------------------------------------- aFragmentShader::aFragmentShader() { program_type = 2; if (useGLSL) { ShaderObject = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); CHECK_GL_ERROR(); } } // ---------------------------------------------------- aFragmentShader::~aFragmentShader() { } // ---------------------------------------------------- aGeometryShader::aGeometryShader() { program_type = 3; if (useGLSL && bGeometryShader) { ShaderObject = glCreateShaderObjectARB(GL_GEOMETRY_SHADER_EXT); CHECK_GL_ERROR(); } } // ---------------------------------------------------- aGeometryShader::~aGeometryShader() { } // ---------------------------------------------------------------------------- // ShaderManager: Easy use of (multiple) Shaders glShaderManager::glShaderManager() { InitOpenGLExtensions(); _nInputPrimitiveType = GL_TRIANGLES; _nOutputPrimitiveType = GL_TRIANGLE_STRIP; _nVerticesOut = 3; } glShaderManager::~glShaderManager() { // free objects vector<glShader*>::iterator i=_shaderObjectList.begin(); while (i!=_shaderObjectList.end()) { //glShader* o = *i; i=_shaderObjectList.erase(i); //delete o; } } // ---------------------------------------------------------------------------- void glShaderManager::SetInputPrimitiveType(int nInputPrimitiveType) { _nInputPrimitiveType = nInputPrimitiveType; } void glShaderManager::SetOutputPrimitiveType(int nOutputPrimitiveType) { _nOutputPrimitiveType = nOutputPrimitiveType; } void glShaderManager::SetVerticesOut(int nVerticesOut) { _nVerticesOut = nVerticesOut; } // ---------------------------------------------------------------------------- glShader* glShaderManager::loadfromFile(char* vertexFile, char* fragmentFile) { glShader* o = new glShader(); o->UsesGeometryShader(false); aVertexShader* tVertexShader = new aVertexShader; aFragmentShader* tFragmentShader = new aFragmentShader; // load vertex program if (vertexFile!=0) if (tVertexShader->load(vertexFile) != 0) { cout << "error: can't load vertex shader!\n"; delete o; delete tVertexShader; delete tFragmentShader; return 0; } // Load fragment program if (fragmentFile!=0) if (tFragmentShader->load(fragmentFile) != 0) { cout << "error: can't load fragment shader!\n"; delete o; delete tVertexShader; delete tFragmentShader; return 0; } // Compile vertex program if (vertexFile!=0) if (!tVertexShader->compile()) { cout << "***COMPILER ERROR (Vertex Shader):\n"; cout << tVertexShader->getCompilerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; return 0; } cout << "***GLSL Compiler Log (Vertex Shader):\n"; cout << tVertexShader->getCompilerLog() << "\n"; // Compile fragment program if (fragmentFile!=0) if (!tFragmentShader->compile()) { cout << "***COMPILER ERROR (Fragment Shader):\n"; cout << tFragmentShader->getCompilerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; return 0; } cout << "***GLSL Compiler Log (Fragment Shader):\n"; cout << tFragmentShader->getCompilerLog() << "\n"; // Add to object if (vertexFile!=0) o->addShader(tVertexShader); if (fragmentFile!=0) o->addShader(tFragmentShader); // link if (!o->link()) { cout << "**LINKER ERROR\n"; cout << o->getLinkerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; return 0; } cout << "***GLSL Linker Log:\n"; cout << o->getLinkerLog() << endl; _shaderObjectList.push_back(o); o->manageMemory(); return o; } glShader* glShaderManager::loadfromFile(char* vertexFile, char* geometryFile, char* fragmentFile) { glShader* o = new glShader(); o->UsesGeometryShader(true); o->SetInputPrimitiveType(_nInputPrimitiveType); o->SetOutputPrimitiveType(_nOutputPrimitiveType); o->SetVerticesOut(_nVerticesOut); aVertexShader* tVertexShader = new aVertexShader; aFragmentShader* tFragmentShader = new aFragmentShader; aGeometryShader* tGeometryShader = new aGeometryShader; // load vertex program if (vertexFile!=0) if (tVertexShader->load(vertexFile) != 0) { cout << "error: can't load vertex shader!\n"; delete o; delete tVertexShader; delete tFragmentShader; delete tGeometryShader; return 0; } // Load geometry program if (geometryFile!=0) if (tGeometryShader->load(geometryFile) != 0) { cout << "error: can't load geometry shader!\n"; delete o; delete tVertexShader; delete tFragmentShader; delete tGeometryShader; return 0; } // Load fragment program if (fragmentFile!=0) if (tFragmentShader->load(fragmentFile) != 0) { cout << "error: can't load fragment shader!\n"; delete o; delete tVertexShader; delete tFragmentShader; delete tGeometryShader; return 0; } // Compile vertex program if (vertexFile!=0) if (!tVertexShader->compile()) { cout << "***COMPILER ERROR (Vertex Shader):\n"; cout << tVertexShader->getCompilerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; delete tGeometryShader; return 0; } cout << "***GLSL Compiler Log (Vertex Shader):\n"; cout << tVertexShader->getCompilerLog() << "\n"; // Compile geometry program if (geometryFile!=0) { if (!tGeometryShader->compile()) { cout << "***COMPILER ERROR (Geometry Shader):\n"; cout << tGeometryShader->getCompilerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; delete tGeometryShader; return 0; } } cout << "***GLSL Compiler Log (Geometry Shader):\n"; cout << tGeometryShader->getCompilerLog() << "\n"; // Compile fragment program if (fragmentFile!=0) if (!tFragmentShader->compile()) { cout << "***COMPILER ERROR (Fragment Shader):\n"; cout << tFragmentShader->getCompilerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; delete tGeometryShader; return 0; } cout << "***GLSL Compiler Log (Fragment Shader):\n"; cout << tFragmentShader->getCompilerLog() << "\n"; // Add to object if (vertexFile!=0) o->addShader(tVertexShader); if (geometryFile!=0) o->addShader(tGeometryShader); if (fragmentFile!=0) o->addShader(tFragmentShader); // link if (!o->link()) { cout << "**LINKER ERROR\n"; cout << o->getLinkerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; delete tGeometryShader; return 0; } cout << "***GLSL Linker Log:\n"; cout << o->getLinkerLog() << endl; _shaderObjectList.push_back(o); o->manageMemory(); return o; return 0; } // ---------------------------------------------------------------------------- glShader* glShaderManager::loadfromMemory(const char* vertexMem, const char* fragmentMem) { glShader* o = new glShader(); o->UsesGeometryShader(false); aVertexShader* tVertexShader = new aVertexShader; aFragmentShader* tFragmentShader = new aFragmentShader; // get vertex program if (vertexMem!=0) tVertexShader->loadFromMemory(vertexMem); // get fragment program if (fragmentMem!=0) tFragmentShader->loadFromMemory(fragmentMem); // Compile vertex program if (vertexMem!=0) if (!tVertexShader->compile()) { cout << "***COMPILER ERROR (Vertex Shader):\n"; cout << tVertexShader->getCompilerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; return 0; } cout << "***GLSL Compiler Log (Vertex Shader):\n"; cout << tVertexShader->getCompilerLog() << "\n"; // Compile fragment program if (fragmentMem!=0) if (!tFragmentShader->compile()) { cout << "***COMPILER ERROR (Fragment Shader):\n"; cout << tFragmentShader->getCompilerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; return 0; } cout << "***GLSL Compiler Log (Fragment Shader):\n"; cout << tFragmentShader->getCompilerLog() << "\n"; // Add to object if (vertexMem!=0) o->addShader(tVertexShader); if (fragmentMem!=0) o->addShader(tFragmentShader); // link if (!o->link()) { cout << "**LINKER ERROR\n"; cout << o->getLinkerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; return 0; } cout << "***GLSL Linker Log:\n"; cout << o->getLinkerLog() << endl; _shaderObjectList.push_back(o); o->manageMemory(); return o; } glShader* glShaderManager::loadfromMemory(const char* vertexMem, const char* geometryMem, const char* fragmentMem) { glShader* o = new glShader(); o->UsesGeometryShader(true); o->SetInputPrimitiveType(_nInputPrimitiveType); o->SetOutputPrimitiveType(_nOutputPrimitiveType); o->SetVerticesOut(_nVerticesOut); aVertexShader* tVertexShader = new aVertexShader; aFragmentShader* tFragmentShader = new aFragmentShader; aGeometryShader* tGeometryShader = new aGeometryShader; // get vertex program if (vertexMem!=0) tVertexShader->loadFromMemory(vertexMem); // get fragment program if (fragmentMem!=0) tFragmentShader->loadFromMemory(fragmentMem); // get fragment program if (geometryMem!=0) tGeometryShader->loadFromMemory(geometryMem); // Compile vertex program if (vertexMem!=0) if (!tVertexShader->compile()) { cout << "***COMPILER ERROR (Vertex Shader):\n"; cout << tVertexShader->getCompilerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; delete tGeometryShader; return 0; } cout << "***GLSL Compiler Log (Vertex Shader):\n"; cout << tVertexShader->getCompilerLog() << "\n"; // Compile geometry program if (geometryMem!=0) if (!tGeometryShader->compile()) { cout << "***COMPILER ERROR (Geometry Shader):\n"; cout << tGeometryShader->getCompilerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; delete tGeometryShader; return 0; } cout << "***GLSL Compiler Log (Geometry Shader):\n"; cout << tVertexShader->getCompilerLog() << "\n"; // Compile fragment program if (fragmentMem!=0) if (!tFragmentShader->compile()) { cout << "***COMPILER ERROR (Fragment Shader):\n"; cout << tFragmentShader->getCompilerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; delete tGeometryShader; return 0; } cout << "***GLSL Compiler Log (Fragment Shader):\n"; cout << tFragmentShader->getCompilerLog() << "\n"; // Add to object if (vertexMem!=0) o->addShader(tVertexShader); if (geometryMem!=0) o->addShader(tGeometryShader); if (fragmentMem!=0) o->addShader(tFragmentShader); // link if (!o->link()) { cout << "**LINKER ERROR\n"; cout << o->getLinkerLog() << endl; delete o; delete tVertexShader; delete tFragmentShader; delete tGeometryShader; return 0; } cout << "***GLSL Linker Log:\n"; cout << o->getLinkerLog() << endl; _shaderObjectList.push_back(o); o->manageMemory(); return o; } // ---------------------------------------------------------------------------- bool glShaderManager::free(glShader* o) { vector<glShader*>::iterator i=_shaderObjectList.begin(); while (i!=_shaderObjectList.end()) { if ((*i)==o) { _shaderObjectList.erase(i); delete o; return true; } i++; } return false; }
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
FilterAthres.h
.h
97
9
#pragma once class FilterAthres { public: FilterAthres(void); ~FilterAthres(void); };
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
Scale.h
.h
80
7
COLORREF GetKeyColor(int input); void DICOMtoImage(int min, int max);
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
glsl.h
.h
23,617
327
/****************************************************************************** glsl.h Version: 1.0.0_rc5 Last update: 2006/11/14 (c) 2003-2006 by Martin Christen. All Rights reserved. ******************************************************************************/ /*! \page libglslnews What's new in libglsl \section s_libglslnews What's New * New in RC5: \item libglsl is actually a lib again. MT and MTDLL runtime is available. GLEW is included in the library. \item Supporting Extension: GL_EXT_bindable_uniform (GeForce 8) * New in RC4: \item Support for Geometry Shader \item Shader Model 4: Support for unsigned integers (Vertex Attributes are currently unsupported, but easy to integrate if you actually need them) \item retrieve variable index with GetUniformLocation \item All setUniformXXX can use index \item Added GetProgramObject in class glShader to return the OpenGL Program Object \todo Support all vertex attribute types \todo Support glGetActiveAttrib \todo Support glGetAttribLocation \todo Support New Matrix Types (OpenGL 2.1) \todo Make SetUniformXXX / VertexXXX calls template-based \note Make sure to check extension "GL_EXT_geometry_shader4" before using Geometry shaders! */ #ifndef A_GLSL_H #define A_GLSL_H //! \defgroup GLSL libglsl //#include "glslSettings.h" #include <vector> #include <iostream> //#define GLEW_STATIC //#include <GL/glew.h> #define GLSLAPI // static build namespace cwc { class glShaderManager; //! Shader Object holds the Shader Source, the OpenGL "Shader Object" and provides some methods to load shaders. /*! \author Martin Christen \ingroup GLSL \bug This class should be an interface. (pure virtual) */ class GLSLAPI glShaderObject { friend class glShader; public: glShaderObject(); virtual ~glShaderObject(); int load(char* filename); //!< \brief Loads a shader file. \param filename The name of the ASCII file containing the shader. \return returns 0 if everything is ok.\n -1: File not found\n -2: Empty File\n -3: no memory void loadFromMemory(const char* program); //!< \brief Load program from null-terminated char array. \param program Address of the memory containing the shader program. bool compile(void); //!< compile program char* getCompilerLog(void); //!< get compiler messages GLint getAttribLocation(char* attribName); //!< \brief Retrieve attribute location. \return Returns attribute location. \param attribName Specify attribute name. protected: int program_type; //!< The program type. 1=Vertex Program, 2=Fragment Program, 3=Geometry Progam, 0=none GLuint ShaderObject; //!< Shader Object GLubyte* ShaderSource; //!< ASCII Source-Code GLcharARB* compiler_log; bool is_compiled; //!< true if compiled bool _memalloc; //!< true if memory for shader source was allocated }; //----------------------------------------------------------------------------- //! \brief Class holding Vertex Shader \ingroup GLSL \author Martin Christen class GLSLAPI aVertexShader : public glShaderObject { public: aVertexShader(); //!< Constructor for Vertex Shader virtual ~aVertexShader(); }; //----------------------------------------------------------------------------- //! \brief Class holding Fragment Shader \ingroup GLSL \author Martin Christen class GLSLAPI aFragmentShader : public glShaderObject { public: aFragmentShader(); //!< Constructor for Fragment Shader virtual ~aFragmentShader(); }; //----------------------------------------------------------------------------- //! \brief Class holding Geometry Shader \ingroup GLSL \author Martin Christen class GLSLAPI aGeometryShader : public glShaderObject { public: aGeometryShader(); //!< Constructor for Geometry Shader virtual ~aGeometryShader(); }; //----------------------------------------------------------------------------- //! \brief Controlling compiled and linked GLSL program. \ingroup GLSL \author Martin Christen class GLSLAPI glShader { friend class glShaderManager; public: glShader(); virtual ~glShader(); void addShader(glShaderObject* ShaderProgram); //!< add a Vertex or Fragment Program \param ShaderProgram The shader object. //!< Returns the OpenGL Program Object (only needed if you want to control everything yourself) \return The OpenGL Program Object GLuint GetProgramObject(){return ProgramObject;} bool link(void); //!< Link all Shaders char* getLinkerLog(void); //!< Get Linker Messages \return char pointer to linker messages. Memory of this string is available until you link again or destroy this class. void begin(); //!< use Shader. OpenGL calls will go through vertex, geometry and/or fragment shaders. void end(); //!< Stop using this shader. OpenGL calls will go through regular pipeline. // Geometry Shader: Input Type, Output and Number of Vertices out void SetInputPrimitiveType(int nInputPrimitiveType); //!< Set the input primitive type for the geometry shader void SetOutputPrimitiveType(int nOutputPrimitiveType); //!< Set the output primitive type for the geometry shader void SetVerticesOut(int nVerticesOut); //!< Set the maximal number of vertices the geometry shader can output GLint GetUniformLocation(const GLcharARB *name); //!< Retrieve Location (index) of a Uniform Variable // Submitting Uniform Variables. You can set varname to 0 and specifiy index retrieved with GetUniformLocation (best performance) bool setUniform1f(GLcharARB* varname, GLfloat v0, GLint index = -1); //!< Specify value of uniform variable. \param varname The name of the uniform variable. bool setUniform2f(GLcharARB* varname, GLfloat v0, GLfloat v1, GLint index = -1); //!< Specify value of uniform variable. \param varname The name of the uniform variable. bool setUniform3f(GLcharARB* varname, GLfloat v0, GLfloat v1, GLfloat v2, GLint index = -1); //!< Specify value of uniform variable. \param varname The name of the uniform variable. bool setUniform4f(GLcharARB* varname, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3, GLint index = -1); //!< Specify value of uniform variable. \param varname The name of the uniform variable. bool setUniform1i(GLcharARB* varname, GLint v0, GLint index = -1); //!< Specify value of uniform integer variable. \param varname The name of the uniform variable. bool setUniform2i(GLcharARB* varname, GLint v0, GLint v1, GLint index = -1); //!< Specify value of uniform integer variable. \param varname The name of the uniform variable. bool setUniform3i(GLcharARB* varname, GLint v0, GLint v1, GLint v2, GLint index = -1); //!< Specify value of uniform integer variable. \param varname The name of the uniform variable. bool setUniform4i(GLcharARB* varname, GLint v0, GLint v1, GLint v2, GLint v3, GLint index = -1); //!< Specify value of uniform integer variable. \param varname The name of the uniform variable. // Note: unsigned integers require GL_EXT_gpu_shader4 (for example GeForce 8800) bool setUniform1ui(GLcharARB* varname, GLuint v0, GLint index = -1); //!< Specify value of uniform unsigned integer variable. \warning Requires GL_EXT_gpu_shader4. \param varname The name of the uniform variable. bool setUniform2ui(GLcharARB* varname, GLuint v0, GLuint v1, GLint index = -1); //!< Specify value of uniform unsigned integer variable. \warning Requires GL_EXT_gpu_shader4. \param varname The name of the uniform variable. bool setUniform3ui(GLcharARB* varname, GLuint v0, GLuint v1, GLuint v2, GLint index = -1); //!< Specify value of uniform unsigned integer variable. \warning Requires GL_EXT_gpu_shader4. \param varname The name of the uniform variable. bool setUniform4ui(GLcharARB* varname, GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLint index = -1); //!< Specify value of uniform unsigned integer variable. \warning Requires GL_EXT_gpu_shader4. \param varname The name of the uniform variable. // Arrays bool setUniform1fv(GLcharARB* varname, GLsizei count, GLfloat *value, GLint index = -1); //!< Specify values of uniform array. \param varname The name of the uniform variable. bool setUniform2fv(GLcharARB* varname, GLsizei count, GLfloat *value, GLint index = -1); //!< Specify values of uniform array. \param varname The name of the uniform variable. bool setUniform3fv(GLcharARB* varname, GLsizei count, GLfloat *value, GLint index = -1); //!< Specify values of uniform array. \param varname The name of the uniform variable. bool setUniform4fv(GLcharARB* varname, GLsizei count, GLfloat *value, GLint index = -1); //!< Specify values of uniform array. \param varname The name of the uniform variable. bool setUniform1iv(GLcharARB* varname, GLsizei count, GLint *value, GLint index = -1); //!< Specify values of uniform array. \param varname The name of the uniform variable. bool setUniform2iv(GLcharARB* varname, GLsizei count, GLint *value, GLint index = -1); //!< Specify values of uniform array. \param varname The name of the uniform variable. bool setUniform3iv(GLcharARB* varname, GLsizei count, GLint *value, GLint index = -1); //!< Specify values of uniform array. \param varname The name of the uniform variable. bool setUniform4iv(GLcharARB* varname, GLsizei count, GLint *value, GLint index = -1); //!< Specify values of uniform array. \param varname The name of the uniform variable. bool setUniform1uiv(GLcharARB* varname, GLsizei count, GLuint *value, GLint index = -1); //!< Specify values of uniform array. \warning Requires GL_EXT_gpu_shader4. \param varname The name of the uniform variable. bool setUniform2uiv(GLcharARB* varname, GLsizei count, GLuint *value, GLint index = -1); //!< Specify values of uniform array. \warning Requires GL_EXT_gpu_shader4. \param varname The name of the uniform variable. bool setUniform3uiv(GLcharARB* varname, GLsizei count, GLuint *value, GLint index = -1); //!< Specify values of uniform array. \warning Requires GL_EXT_gpu_shader4. \param varname The name of the uniform variable. bool setUniform4uiv(GLcharARB* varname, GLsizei count, GLuint *value, GLint index = -1); //!< Specify values of uniform array. \warning Requires GL_EXT_gpu_shader4. \param varname The name of the uniform variable. bool setUniformMatrix2fv(GLcharARB* varname, GLsizei count, GLboolean transpose, GLfloat *value, GLint index = -1); //!< Specify values of uniform 2x2 matrix. \param varname The name of the uniform variable. bool setUniformMatrix3fv(GLcharARB* varname, GLsizei count, GLboolean transpose, GLfloat *value, GLint index = -1); //!< Specify values of uniform 3x3 matrix. \param varname The name of the uniform variable. bool setUniformMatrix4fv(GLcharARB* varname, GLsizei count, GLboolean transpose, GLfloat *value, GLint index = -1); //!< Specify values of uniform 4x4 matrix. \param varname The name of the uniform variable. // Receive Uniform variables: void getUniformfv(GLcharARB* varname, GLfloat* values, GLint index = -1); //!< Receive value of uniform variable. \param varname The name of the uniform variable. void getUniformiv(GLcharARB* varname, GLint* values, GLint index = -1); //!< Receive value of uniform variable. \param varname The name of the uniform variable. void getUniformuiv(GLcharARB* varname, GLuint* values, GLint index = -1); //!< Receive value of uniform variable. \warning Requires GL_EXT_gpu_shader4 \param varname The name of the uniform variable. /*! This method simply calls glBindAttribLocation for the current ProgramObject \warning NVidia implementation is different than the GLSL standard: GLSL attempts to eliminate aliasing of vertex attributes but this is integral to NVIDIA’s hardware approach and necessary for maintaining compatibility with existing OpenGL applications that NVIDIA customers rely on. NVIDIA’s GLSL implementation therefore does not allow built-in vertex attributes to collide with a generic vertex attributes that is assigned to a particular vertex attribute index with glBindAttribLocation. For example, you should not use gl_Normal (a built-in vertex attribute) and also use glBindAttribLocation to bind a generic vertex attribute named "whatever" to vertex attribute index 2 because gl_Normal aliases to index 2. \verbatim gl_Vertex 0 gl_Normal 2 gl_Color 3 gl_SecondaryColor 4 gl_FogCoord 5 gl_MultiTexCoord0 8 gl_MultiTexCoord1 9 gl_MultiTexCoord2 10 gl_MultiTexCoord3 11 gl_MultiTexCoord4 12 gl_MultiTexCoord5 13 gl_MultiTexCoord6 14 gl_MultiTexCoord7 15 \endverbatim \param index Index of the variable \param name Name of the attribute. */ void BindAttribLocation(GLint index, GLchar* name); //GLfloat bool setVertexAttrib1f(GLuint index, GLfloat v0); //!< Specify value of attribute. \param index The index of the vertex attribute. \param v0 value of the attribute component bool setVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1); //!< Specify value of attribute. \param index The index of the vertex attribute. \param v0 value of the attribute component \param v1 value of the attribute component bool setVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2); //!< Specify value of attribute. \param index The index of the vertex attribute. \param v0 value of the attribute component \param v1 value of the attribute component \param v2 value of the attribute component bool setVertexAttrib4f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); //!< Specify value of attribute. \param index The index of the vertex attribute. \param v0 value of the attribute component \param v1 value of the attribute component \param v2 value of the attribute component \param v3 value of the attribute component //GLdouble bool setVertexAttrib1d(GLuint index, GLdouble v0); //!< Specify value of attribute. \param index The index of the vertex attribute. \param v0 value of the attribute component bool setVertexAttrib2d(GLuint index, GLdouble v0, GLdouble v1); //!< Specify value of attribute. \param index The index of the vertex attribute. \param v0 value of the attribute component \param v1 value of the attribute component bool setVertexAttrib3d(GLuint index, GLdouble v0, GLdouble v1, GLdouble v2); //!< Specify value of attribute. \param index The index of the vertex attribute. \param v0 value of the attribute component \param v1 value of the attribute component \param v2 value of the attribute component bool setVertexAttrib4d(GLuint index, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); //!< Specify value of attribute. \param index The index of the vertex attribute. \param v0 value of the attribute component \param v1 value of the attribute component \param v2 value of the attribute component \param v3 value of the attribute component //GLshort bool setVertexAttrib1s(GLuint index, GLshort v0); //!< Specify value of attribute. \param index The index of the vertex attribute. \param v0 value of the attribute component bool setVertexAttrib2s(GLuint index, GLshort v0, GLshort v1); //!< Specify value of attribute. \param index The index of the vertex attribute. \param v0 value of the attribute component \param v1 value of the attribute component bool setVertexAttrib3s(GLuint index, GLshort v0, GLshort v1, GLshort v2); //!< Specify value of attribute. \param index The index of the vertex attribute. \param v0 value of the attribute component \param v1 value of the attribute component \param v2 value of the attribute component bool setVertexAttrib4s(GLuint index, GLshort v0, GLshort v1, GLshort v2, GLshort v3); //!< Specify value of attribute. \param index The index of the vertex attribute. \param v0 value of the attribute component \param v1 value of the attribute component \param v2 value of the attribute component \param v3 value of the attribute component // Normalized Byte (for example for RGBA colors) bool setVertexAttribNormalizedByte(GLuint index, GLbyte v0, GLbyte v1, GLbyte v2, GLbyte v3); //!< Specify value of attribute. Values will be normalized. //GLint (Requires GL_EXT_gpu_shader4) bool setVertexAttrib1i(GLuint index, GLint v0); //!< Specify value of attribute. Requires GL_EXT_gpu_shader4. bool setVertexAttrib2i(GLuint index, GLint v0, GLint v1); //!< Specify value of attribute. Requires GL_EXT_gpu_shader4. bool setVertexAttrib3i(GLuint index, GLint v0, GLint v1, GLint v2); //!< Specify value of attribute. Requires GL_EXT_gpu_shader4. bool setVertexAttrib4i(GLuint index, GLint v0, GLint v1, GLint v2, GLint v3); //!< Specify value of attribute. Requires GL_EXT_gpu_shader4. //GLuint (Requires GL_EXT_gpu_shader4) bool setVertexAttrib1ui(GLuint index, GLuint v0); //!< Specify value of attribute. \warning Requires GL_EXT_gpu_shader4. \param v0 value of the first component bool setVertexAttrib2ui(GLuint index, GLuint v0, GLuint v1); //!< Specify value of attribute. \warning Requires GL_EXT_gpu_shader4. bool setVertexAttrib3ui(GLuint index, GLuint v0, GLuint v1, GLuint v2); //!< Specify value of attribute. \warning Requires GL_EXT_gpu_shader4. bool setVertexAttrib4ui(GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3); //!< Specify value of attribute. \warning Requires GL_EXT_gpu_shader4. //! Enable this Shader: void enable(void) //!< Enables Shader (Shader is enabled by default) { _noshader = true; } //! Disable this Shader: void disable(void) //!< Disables Shader. { _noshader = false; } protected: void manageMemory(void){_mM = true;} void UsesGeometryShader(bool bYesNo){ _bUsesGeometryShader = bYesNo;} private: GLuint ProgramObject; // GLProgramObject GLcharARB* linker_log; bool is_linked; std::vector<glShaderObject*> ShaderList; // List of all Shader Programs bool _mM; bool _noshader; bool _bUsesGeometryShader; int _nInputPrimitiveType; int _nOutputPrimitiveType; int _nVerticesOut; }; //----------------------------------------------------------------------------- //! To simplify the process loading/compiling/linking shaders this high level interface to simplify setup of a vertex/fragment shader was created. \ingroup GLSL \author Martin Christen class GLSLAPI glShaderManager { public: glShaderManager(); virtual ~glShaderManager(); // Regular GLSL (Vertex+Fragment Shader) glShader* loadfromFile(char* vertexFile, char* fragmentFile); //!< load vertex/fragment shader from file. If you specify 0 for one of the shaders, the fixed function pipeline is used for that part. \param vertexFile Vertex Shader File. \param fragmentFile Fragment Shader File. glShader* loadfromMemory(const char* vertexMem, const char* fragmentMem); //!< load vertex/fragment shader from memory. If you specify 0 for one of the shaders, the fixed function pipeline is used for that part. // With Geometry Shader (Vertex+Geomentry+Fragment Shader) glShader* loadfromFile(char* vertexFile, char* geometryFile, char* fragmentFile); //!< load vertex/geometry/fragment shader from file. If you specify 0 for one of the shaders, the fixed function pipeline is used for that part. \param vertexFile Vertex Shader File. \param geometryFile Geometry Shader File \param fragmentFile Fragment Shader File. glShader* loadfromMemory(const char* vertexMem, const char* geometryMem, const char* fragmentMem); //!< load vertex/geometry/fragment shader from memory. If you specify 0 for one of the shaders, the fixed function pipeline is used for that part. void SetInputPrimitiveType(int nInputPrimitiveType); //!< Set the input primitive type for the geometry shader \param nInputPrimitiveType Input Primitive Type, for example GL_TRIANGLES void SetOutputPrimitiveType(int nOutputPrimitiveType); //!< Set the output primitive type for the geometry shader \param nOutputPrimitiveType Output Primitive Type, for example GL_TRIANGLE_STRIP void SetVerticesOut(int nVerticesOut); //!< Set the maximal number of vertices the geometry shader can output \param nVerticesOut Maximal number of output vertices. It is possible to output less vertices! bool free(glShader* o); //!< Remove the shader and free the memory occupied by this shader. private: std::vector<glShader*> _shaderObjectList; int _nInputPrimitiveType; int _nOutputPrimitiveType; int _nVerticesOut; }; //----------------------------------------------------------------------------- // Global functions to initialize OpenGL Extensions and check for GLSL and // OpenGL2. Also functions to check if Shader Model 4 is available and if // Geometry Shaders are supported. bool GLSLAPI InitOpenGLExtensions(void); //!< Initialize OpenGL Extensions (using glew) \ingroup GLSL bool GLSLAPI HasGLSLSupport(void); //!< Returns true if OpenGL Shading Language is supported. (This function will return a GLSL version number in a future release) \ingroup GLSL bool GLSLAPI HasOpenGL2Support(void); //!< Returns true if OpenGL 2.0 is supported. This function is deprecated and shouldn't be used anymore. \ingroup GLSL \deprecated bool GLSLAPI HasGeometryShaderSupport(void); //!< Returns true if Geometry Shaders are supported. \ingroup GLSL bool GLSLAPI HasShaderModel4(void); //!< Returns true if Shader Model 4 is supported. \ingroup GLSL // these function names are deprecated, just here for backwards // compatibility. It is very likely they will be removed in a future version #define initGLExtensions InitOpenGLExtensions #define checkGLSL HasGLSLSupport #define checkGL2 HasOpenGL2Support //---------------------------------------------------------------------------- }; #endif // A_GLSL_H
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
RendererHelper.cpp
.cpp
9,999
363
#include "StdAfx.h" #include "RendererHelper.h" #include "RawDataProcessor.h" #include "TranformationMgr.h" #include "MainFrm.h" #include "DICOM ViewerDoc.h" GLfloat dOrthoSize = 1.0f; CRendererHelper::CRendererHelper(void) : m_pRawDataProc(NULL),m_zoom(1.0) { AspectRatio = 1; for(int i = 0; i < 3; i++) { m_min_vector[i] = -1.0f; m_max_vector[i] = 1.0f; } } CRendererHelper::~CRendererHelper(void) { } bool CRendererHelper::Initialize( HDC hContext_i ,CRawDataProcessor* pRawDataProc_i ) { //Setting up the dialog to support the OpenGL. PIXELFORMATDESCRIPTOR stPixelFormatDescriptor; memset( &stPixelFormatDescriptor, 0, sizeof( PIXELFORMATDESCRIPTOR )); stPixelFormatDescriptor.nSize = sizeof( PIXELFORMATDESCRIPTOR ); stPixelFormatDescriptor.nVersion = 1; stPixelFormatDescriptor.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW ; stPixelFormatDescriptor.iPixelType = PFD_TYPE_RGBA; stPixelFormatDescriptor.cColorBits = 24; stPixelFormatDescriptor.cDepthBits = 32; stPixelFormatDescriptor.cStencilBits = 8; stPixelFormatDescriptor.iLayerType = PFD_MAIN_PLANE ; int nPixelFormat = ChoosePixelFormat( hContext_i, &stPixelFormatDescriptor ); //Collect the pixel format. if( nPixelFormat == 0 ) { AfxMessageBox( _T( "Error while Choosing Pixel format" )); return false; } //Set the pixel format to the current dialog. if( !SetPixelFormat( hContext_i, nPixelFormat, &stPixelFormatDescriptor )) { AfxMessageBox( _T( "Error while setting pixel format" )); return false; } //Create a device context. m_hglContext = wglCreateContext( hContext_i ); if( !m_hglContext ) { AfxMessageBox( _T( "Rendering Context Creation Failed" )); return false; } //Make the created device context as the current device context. BOOL bResult = wglMakeCurrent( hContext_i, m_hglContext ); if( !bResult ) { AfxMessageBox( _T( "wglMakeCurrent Failed" )); return false; } glClearColor( 0.0f,0.0f, 0.0f, 0.0f ); glewInit(); if(GL_TRUE != glewGetExtension("GL_EXT_texture3D")) { AfxMessageBox( _T( "3D texture is not supported !" )); return false; } if(m_pRawDataProc == NULL) { m_pRawDataProc = pRawDataProc_i; } //if(m_pTransformMgr == NULL) //{ // m_pTransformMgr = pTransformationMgr_i; //} return true; } void CRendererHelper::Resize( int nWidth_i, int nHeight_i ) { AspectRatio = ( GLdouble )(nWidth_i) / ( GLdouble )(nHeight_i ); if(nHeight_i == 0) nHeight_i = 1; double view_size = 0; if(nWidth_i <= nHeight_i) { view_size = nWidth_i; } else { view_size = nHeight_i; } AspectWidth = nWidth_i / view_size; AspectHeight = nHeight_i / view_size; //glViewport((nWidth_i - view_size)/2, (nHeight_i - view_size)/2, view_size, view_size); glViewport(0, 0, nWidth_i, nHeight_i); //fAspect = (GLfloat)nWidth_i/(GLfloat)nHeight_i; glMatrixMode(GL_PROJECTION); glLoadIdentity(); //glFrustum(0,view_size,0,view_size,-10,20); glFrustum(0,nWidth_i,0,nHeight_i,-10,20); //gluPerspective(45.0f, fAspect, -10.0f, 100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable( GL_ALPHA_TEST ); glAlphaFunc( GL_GREATER, 0.05f ); glEnable(GL_BLEND); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); } void CRendererHelper::DrawPolygon(void) { /* draws the sides of a unit cube (0,0,0)-(1,1,1) */ glBegin(GL_POLYGON);/* f1: front */ glNormal3f(-1.0f,0.0f,0.0f); glVertex3f(0.0f,0.0f,0.0f); glVertex3f(0.0f,0.0f,1.0f); glVertex3f(1.0f,0.0f,1.0f); glVertex3f(1.0f,0.0f,0.0f); glEnd(); glBegin(GL_POLYGON);/* f2: bottom */ glNormal3f(0.0f,0.0f,-1.0f); glVertex3f(0.0f,0.0f,0.0f); glVertex3f(1.0f,0.0f,0.0f); glVertex3f(1.0f,1.0f,0.0f); glVertex3f(0.0f,1.0f,0.0f); glEnd(); glBegin(GL_POLYGON);/* f3:back */ glNormal3f(1.0f,0.0f,0.0f); glVertex3f(1.0f,1.0f,0.0f); glVertex3f(1.0f,1.0f,1.0f); glVertex3f(0.0f,1.0f,1.0f); glVertex3f(0.0f,1.0f,0.0f); glEnd(); glBegin(GL_POLYGON);/* f4: top */ glNormal3f(0.0f,0.0f,1.0f); glVertex3f(1.0f,1.0f,1.0f); glVertex3f(1.0f,0.0f,1.0f); glVertex3f(0.0f,0.0f,1.0f); glVertex3f(0.0f,1.0f,1.0f); glEnd(); glBegin(GL_POLYGON);/* f5: left */ glNormal3f(0.0f,1.0f,0.0f); glVertex3f(0.0f,0.0f,0.0f); glVertex3f(0.0f,1.0f,0.0f); glVertex3f(0.0f,1.0f,1.0f); glVertex3f(0.0f,0.0f,1.0f); glEnd(); glBegin(GL_POLYGON);/* f6: right */ glNormal3f(0.0f,-1.0f,0.0f); glVertex3f(1.0f,0.0f,0.0f); glVertex3f(1.0f,0.0f,1.0f); glVertex3f(1.0f,1.0f,1.0f); glVertex3f(1.0f,1.0f,0.0f); glEnd(); } void CRendererHelper::DrawBox(void) { m_min_vector[0] = -1.0f*AspectHeight; m_max_vector[0] = 1.0f*AspectHeight; m_min_vector[1] = -1.0f*AspectWidth; m_max_vector[1] = 1.0f*AspectWidth; //m_min_vector[1] = -1.0f; //m_max_vector[1] = 1.0f; m_min_vector[2] = -1.0f; m_max_vector[2] = 1.0f; glBegin(GL_LINES); // X, Y, Z ¼± Ç¥½Ã glColor3f(1.0, 0.0, 0.0); // XÃà // glVertex3f(m_min_vector[0], m_min_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_min_vector[1], m_min_vector[2]); glVertex3f(m_min_vector[0], m_min_vector[1], m_max_vector[2]); glVertex3f(m_max_vector[0], m_min_vector[1], m_max_vector[2]); glVertex3f(m_min_vector[0], m_min_vector[1], m_min_vector[2]); glVertex3f(m_min_vector[0], m_min_vector[1], m_max_vector[2]); glVertex3f(m_max_vector[0], m_min_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_min_vector[1], m_max_vector[2]); // glVertex3f(m_min_vector[0], m_max_vector[1], m_max_vector[2]); glVertex3f(m_max_vector[0], m_max_vector[1], m_max_vector[2]); glVertex3f(m_min_vector[0], m_max_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_max_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_max_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_max_vector[1], m_max_vector[2]); glVertex3f(m_min_vector[0], m_max_vector[1], m_min_vector[2]); glVertex3f(m_min_vector[0], m_max_vector[1], m_max_vector[2]); // glVertex3f(m_min_vector[0], m_min_vector[1], m_max_vector[2]); glVertex3f(m_min_vector[0], m_max_vector[1], m_max_vector[2]); glVertex3f(m_max_vector[0], m_min_vector[1], m_max_vector[2]); glVertex3f(m_max_vector[0], m_max_vector[1], m_max_vector[2]); glVertex3f(m_min_vector[0], m_min_vector[1], m_min_vector[2]); glVertex3f(m_min_vector[0], m_max_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_min_vector[1], m_min_vector[2]); glVertex3f(m_max_vector[0], m_max_vector[1], m_min_vector[2]); glEnd(); } // Macro to draw the quad. // Performance can be achieved by making a call list. // To make it simple i am not using that now :-) #define MAP_3DTEXT( TexIndex ) \ glTexCoord3f(0.0f, 0.0f, ((float)TexIndex+1.0f)/2.0f); \ glVertex3f(-dOrthoSize,-dOrthoSize,TexIndex);\ glTexCoord3f(1.0f, 0.0f, ((float)TexIndex+1.0f)/2.0f); \ glVertex3f(dOrthoSize,-dOrthoSize,TexIndex);\ glTexCoord3f(1.0f, 1.0f, ((float)TexIndex+1.0f)/2.0f); \ glVertex3f(dOrthoSize,dOrthoSize,TexIndex);\ glTexCoord3f(0.0f, 1.0f, ((float)TexIndex+1.0f)/2.0f); \ glVertex3f(-dOrthoSize,dOrthoSize,TexIndex); void CRendererHelper::Render() { CDICOMViewerDoc* pDoc = (CDICOMViewerDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument(); if (!pDoc) return; if(!pDoc->IsDataLoaded()) return; float fFrameCount = (float)m_pRawDataProc->GetDepth(); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glMatrixMode( GL_TEXTURE ); glLoadIdentity(); m_camera.Render(); // Translate and make 0.5f as the center // (texture co ordinate is from 0 to 1. so center of rotation has to be 0.5f) glTranslatef( 0.5f, 0.5f, 0.5f ); glScalef(m_zoom,m_zoom,m_zoom); //glRotatef(90.0f,1,0,0); //glRotatef(180.0f,0,1,0); glMultMatrixd( m_camera.GetMatrix()); glTranslatef( -0.5f, -0.5f, -0.5f ); glEnable(GL_TEXTURE_3D); glBindTexture( GL_TEXTURE_3D, m_pRawDataProc->GetTexture3D() ); for ( float fIndx = -1.0f; fIndx <= 1.0f; fIndx+=0.01f ) { glBegin(GL_QUADS); //MAP_3DTEXT( fIndx ); glTexCoord3f(0.0f, 0.0f, ((float)fIndx+1.0f)/2.0f); glVertex3f(-dOrthoSize*AspectHeight,-dOrthoSize*AspectWidth,fIndx); glTexCoord3f(1.0f, 0.0f, ((float)fIndx+1.0f)/2.0f); glVertex3f(dOrthoSize*AspectHeight,-dOrthoSize*AspectWidth,fIndx); glTexCoord3f(1.0f, 1.0f, ((float)fIndx+1.0f)/2.0f); glVertex3f(dOrthoSize*AspectHeight,dOrthoSize*AspectWidth,fIndx); glTexCoord3f(0.0f, 1.0f, ((float)fIndx+1.0f)/2.0f); glVertex3f(-dOrthoSize*AspectHeight,dOrthoSize*AspectWidth,fIndx); glEnd(); } //DrawBox(); glFlush(); } void CRendererHelper::MouseMove(UINT nFlags, CPoint point) { CDICOMViewerDoc* pDoc = (CDICOMViewerDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument(); ASSERT_VALID(pDoc); if (!pDoc) { return; } if( nFlags & MK_RBUTTON ) { m_camera.Rotate( mRotReference.y-point.y, mRotReference.x-point.x, 0 ); mRotReference = point; m_parent->Invalidate(FALSE); } } void CRendererHelper::LButtonDown(UINT nFlags, CPoint point) { } void CRendererHelper::LButtonUp(UINT nFlags, CPoint point) { } BOOL CRendererHelper::MouseWheel(UINT nFlags, short zDelta, CPoint pt) { if(zDelta >= 0) { setZoomDelta(-0.1); } else { setZoomDelta(0.1); } m_parent->Invalidate(FALSE); return TRUE; } void CRendererHelper::RButtonDown(UINT nFlags, CPoint point) { mRotReference = point; } void CRendererHelper::RButtonUp(UINT nFlags, CPoint point) { }
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
SpectrumPoint.h
.h
320
19
#pragma once class SpectrumPoint { public: SpectrumPoint(void); ~SpectrumPoint(void); bool InsideRect(int x, int y); void SetFixed(bool _bFixed){ m_bFixed = _bFixed; } bool GetFixed(){ return m_bFixed; } CRect m_rt; COLORREF m_color; bool m_bExist; bool m_bDrag; private: bool m_bFixed; };
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
RawDataProcessor.h
.h
705
44
#pragma once // CRawDataProcessor class CDICOMViewerDoc; class CRawDataProcessor { public: CRawDataProcessor(); virtual ~CRawDataProcessor(); // Call this only after the open gl is initialized. bool ReadFile(CDICOMViewerDoc* _pDoc, int nWidth_i, int nHeight_i, int nSlices_i ); int GetTexture3D() { return m_nTexId; } const int GetWidth() { return m_uImageWidth; } const int GetHeight() { return m_uImageHeight; } const int GetDepth() { return m_uImageCount; } private: int m_uImageCount; int m_uImageWidth; int m_uImageHeight; int m_nTexId; };
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
maxflow.cpp
.cpp
14,906
685
/* maxflow.cpp */ #include "stdafx.h" #include <stdio.h> #include "graph.h" /* special constants for node->parent */ #define TERMINAL ( (arc *) 1 ) /* to terminal */ #define ORPHAN ( (arc *) 2 ) /* orphan */ #define INFINITE_D ((int)(((unsigned)-1)/2)) /* infinite distance to the terminal */ /***********************************************************************/ /* Functions for processing active list. i->next points to the next node in the list (or to i, if i is the last node in the list). If i->next is NULL iff i is not in the list. There are two queues. Active nodes are added to the end of the second queue and read from the front of the first queue. If the first queue is empty, it is replaced by the second queue (and the second queue becomes empty). */ template <typename captype, typename tcaptype, typename flowtype> inline void Graph<captype,tcaptype,flowtype>::set_active(node *i) { if (!i->next) { /* it's not in the list yet */ if (queue_last[1]) queue_last[1] -> next = i; else queue_first[1] = i; queue_last[1] = i; i -> next = i; } } /* Returns the next active node. If it is connected to the sink, it stays in the list, otherwise it is removed from the list */ template <typename captype, typename tcaptype, typename flowtype> inline typename Graph<captype,tcaptype,flowtype>::node* Graph<captype,tcaptype,flowtype>::next_active() { node *i; while ( 1 ) { if (!(i=queue_first[0])) { queue_first[0] = i = queue_first[1]; queue_last[0] = queue_last[1]; queue_first[1] = NULL; queue_last[1] = NULL; if (!i) return NULL; } /* remove it from the active list */ if (i->next == i) queue_first[0] = queue_last[0] = NULL; else queue_first[0] = i -> next; i -> next = NULL; /* a node in the list is active iff it has a parent */ if (i->parent) return i; } } /***********************************************************************/ template <typename captype, typename tcaptype, typename flowtype> inline void Graph<captype,tcaptype,flowtype>::set_orphan_front(node *i) { nodeptr *np; i -> parent = ORPHAN; np = nodeptr_block -> New(); np -> ptr = i; np -> next = orphan_first; orphan_first = np; } template <typename captype, typename tcaptype, typename flowtype> inline void Graph<captype,tcaptype,flowtype>::set_orphan_rear(node *i) { nodeptr *np; i -> parent = ORPHAN; np = nodeptr_block -> New(); np -> ptr = i; if (orphan_last) orphan_last -> next = np; else orphan_first = np; orphan_last = np; np -> next = NULL; } /***********************************************************************/ template <typename captype, typename tcaptype, typename flowtype> inline void Graph<captype,tcaptype,flowtype>::add_to_changed_list(node *i) { if (changed_list && !i->is_in_changed_list) { node_id* ptr = changed_list->New(); *ptr = (node_id)(i - nodes); i->is_in_changed_list = true; } } /***********************************************************************/ template <typename captype, typename tcaptype, typename flowtype> void Graph<captype,tcaptype,flowtype>::maxflow_init() { node *i; queue_first[0] = queue_last[0] = NULL; queue_first[1] = queue_last[1] = NULL; orphan_first = NULL; TIME = 0; for (i=nodes; i<node_last; i++) { i -> next = NULL; i -> is_marked = 0; i -> is_in_changed_list = 0; i -> TS = TIME; if (i->tr_cap > 0) { /* i is connected to the source */ i -> is_sink = 0; i -> parent = TERMINAL; set_active(i); i -> DIST = 1; } else if (i->tr_cap < 0) { /* i is connected to the sink */ i -> is_sink = 1; i -> parent = TERMINAL; set_active(i); i -> DIST = 1; } else { i -> parent = NULL; } } } template <typename captype, typename tcaptype, typename flowtype> void Graph<captype,tcaptype,flowtype>::maxflow_reuse_trees_init() { node* i; node* j; node* queue = queue_first[1]; arc* a; nodeptr* np; queue_first[0] = queue_last[0] = NULL; queue_first[1] = queue_last[1] = NULL; orphan_first = orphan_last = NULL; TIME ++; while ((i=queue)) { queue = i->next; if (queue == i) queue = NULL; i->next = NULL; i->is_marked = 0; set_active(i); if (i->tr_cap == 0) { if (i->parent) set_orphan_rear(i); continue; } if (i->tr_cap > 0) { if (!i->parent || i->is_sink) { i->is_sink = 0; for (a=i->first; a; a=a->next) { j = a->head; if (!j->is_marked) { if (j->parent == a->sister) set_orphan_rear(j); if (j->parent && j->is_sink && a->r_cap > 0) set_active(j); } } add_to_changed_list(i); } } else { if (!i->parent || !i->is_sink) { i->is_sink = 1; for (a=i->first; a; a=a->next) { j = a->head; if (!j->is_marked) { if (j->parent == a->sister) set_orphan_rear(j); if (j->parent && !j->is_sink && a->sister->r_cap > 0) set_active(j); } } add_to_changed_list(i); } } i->parent = TERMINAL; i -> TS = TIME; i -> DIST = 1; } //test_consistency(); /* adoption */ while ((np=orphan_first)) { orphan_first = np -> next; i = np -> ptr; nodeptr_block -> Delete(np); if (!orphan_first) orphan_last = NULL; if (i->is_sink) process_sink_orphan(i); else process_source_orphan(i); } /* adoption end */ //test_consistency(); } template <typename captype, typename tcaptype, typename flowtype> void Graph<captype,tcaptype,flowtype>::augment(arc *middle_arc) { node *i; arc *a; tcaptype bottleneck; /* 1. Finding bottleneck capacity */ /* 1a - the source tree */ bottleneck = middle_arc -> r_cap; for (i=middle_arc->sister->head; ; i=a->head) { a = i -> parent; if (a == TERMINAL) break; if (bottleneck > a->sister->r_cap) bottleneck = a -> sister -> r_cap; } if (bottleneck > i->tr_cap) bottleneck = i -> tr_cap; /* 1b - the sink tree */ for (i=middle_arc->head; ; i=a->head) { a = i -> parent; if (a == TERMINAL) break; if (bottleneck > a->r_cap) bottleneck = a -> r_cap; } if (bottleneck > - i->tr_cap) bottleneck = - i -> tr_cap; /* 2. Augmenting */ /* 2a - the source tree */ middle_arc -> sister -> r_cap += bottleneck; middle_arc -> r_cap -= bottleneck; for (i=middle_arc->sister->head; ; i=a->head) { a = i -> parent; if (a == TERMINAL) break; a -> r_cap += bottleneck; a -> sister -> r_cap -= bottleneck; if (!a->sister->r_cap) { set_orphan_front(i); // add i to the beginning of the adoption list } } i -> tr_cap -= bottleneck; if (!i->tr_cap) { set_orphan_front(i); // add i to the beginning of the adoption list } /* 2b - the sink tree */ for (i=middle_arc->head; ; i=a->head) { a = i -> parent; if (a == TERMINAL) break; a -> sister -> r_cap += bottleneck; a -> r_cap -= bottleneck; if (!a->r_cap) { set_orphan_front(i); // add i to the beginning of the adoption list } } i -> tr_cap += bottleneck; if (!i->tr_cap) { set_orphan_front(i); // add i to the beginning of the adoption list } flow += bottleneck; } /***********************************************************************/ template <typename captype, typename tcaptype, typename flowtype> void Graph<captype,tcaptype,flowtype>::process_source_orphan(node *i) { node *j; arc *a0, *a0_min = NULL, *a; int d, d_min = INFINITE_D; /* trying to find a new parent */ for (a0=i->first; a0; a0=a0->next) if (a0->sister->r_cap) { j = a0 -> head; if (!j->is_sink && (a=j->parent)) { /* checking the origin of j */ d = 0; while ( 1 ) { if (j->TS == TIME) { d += j -> DIST; break; } a = j -> parent; d ++; if (a==TERMINAL) { j -> TS = TIME; j -> DIST = 1; break; } if (a==ORPHAN) { d = INFINITE_D; break; } j = a -> head; } if (d<INFINITE_D) /* j originates from the source - done */ { if (d<d_min) { a0_min = a0; d_min = d; } /* set marks along the path */ for (j=a0->head; j->TS!=TIME; j=j->parent->head) { j -> TS = TIME; j -> DIST = d --; } } } } if (i->parent = a0_min) { i -> TS = TIME; i -> DIST = d_min + 1; } else { /* no parent is found */ add_to_changed_list(i); /* process neighbors */ for (a0=i->first; a0; a0=a0->next) { j = a0 -> head; if (!j->is_sink && (a=j->parent)) { if (a0->sister->r_cap) set_active(j); if (a!=TERMINAL && a!=ORPHAN && a->head==i) { set_orphan_rear(j); // add j to the end of the adoption list } } } } } template <typename captype, typename tcaptype, typename flowtype> void Graph<captype,tcaptype,flowtype>::process_sink_orphan(node *i) { node *j; arc *a0, *a0_min = NULL, *a; int d, d_min = INFINITE_D; /* trying to find a new parent */ for (a0=i->first; a0; a0=a0->next) if (a0->r_cap) { j = a0 -> head; if (j->is_sink && (a=j->parent)) { /* checking the origin of j */ d = 0; while ( 1 ) { if (j->TS == TIME) { d += j -> DIST; break; } a = j -> parent; d ++; if (a==TERMINAL) { j -> TS = TIME; j -> DIST = 1; break; } if (a==ORPHAN) { d = INFINITE_D; break; } j = a -> head; } if (d<INFINITE_D) /* j originates from the sink - done */ { if (d<d_min) { a0_min = a0; d_min = d; } /* set marks along the path */ for (j=a0->head; j->TS!=TIME; j=j->parent->head) { j -> TS = TIME; j -> DIST = d --; } } } } if (i->parent = a0_min) { i -> TS = TIME; i -> DIST = d_min + 1; } else { /* no parent is found */ add_to_changed_list(i); /* process neighbors */ for (a0=i->first; a0; a0=a0->next) { j = a0 -> head; if (j->is_sink && (a=j->parent)) { if (a0->r_cap) set_active(j); if (a!=TERMINAL && a!=ORPHAN && a->head==i) { set_orphan_rear(j); // add j to the end of the adoption list } } } } } /***********************************************************************/ template <typename captype, typename tcaptype, typename flowtype> flowtype Graph<captype,tcaptype,flowtype>::maxflow(bool reuse_trees, Block<node_id>* _changed_list) { node *i, *j, *current_node = NULL; arc *a; nodeptr *np, *np_next; if (!nodeptr_block) { nodeptr_block = new DBlock<nodeptr>(NODEPTR_BLOCK_SIZE, error_function); } changed_list = _changed_list; if (maxflow_iteration == 0 && reuse_trees) { if (error_function) (*error_function)("reuse_trees cannot be used in the first call to maxflow()!"); exit(1); } if (changed_list && !reuse_trees) { if (error_function) (*error_function)("changed_list cannot be used without reuse_trees!"); exit(1); } if (reuse_trees) maxflow_reuse_trees_init(); else maxflow_init(); // main loop while ( 1 ) { // test_consistency(current_node); if ((i=current_node)) { i -> next = NULL; /* remove active flag */ if (!i->parent) i = NULL; } if (!i) { if (!(i = next_active())) break; } /* growth */ if (!i->is_sink) { /* grow source tree */ for (a=i->first; a; a=a->next) if (a->r_cap) { j = a -> head; if (!j->parent) { j -> is_sink = 0; j -> parent = a -> sister; j -> TS = i -> TS; j -> DIST = i -> DIST + 1; set_active(j); add_to_changed_list(j); } else if (j->is_sink) break; else if (j->TS <= i->TS && j->DIST > i->DIST) { /* heuristic - trying to make the distance from j to the source shorter */ j -> parent = a -> sister; j -> TS = i -> TS; j -> DIST = i -> DIST + 1; } } } else { /* grow sink tree */ for (a=i->first; a; a=a->next) if (a->sister->r_cap) { j = a -> head; if (!j->parent) { j -> is_sink = 1; j -> parent = a -> sister; j -> TS = i -> TS; j -> DIST = i -> DIST + 1; set_active(j); add_to_changed_list(j); } else if (!j->is_sink) { a = a -> sister; break; } else if (j->TS <= i->TS && j->DIST > i->DIST) { /* heuristic - trying to make the distance from j to the sink shorter */ j -> parent = a -> sister; j -> TS = i -> TS; j -> DIST = i -> DIST + 1; } } } TIME ++; if (a) { i -> next = i; /* set active flag */ current_node = i; /* augmentation */ augment(a); /* augmentation end */ /* adoption */ while ((np=orphan_first)) { np_next = np -> next; np -> next = NULL; while ((np=orphan_first)) { orphan_first = np -> next; i = np -> ptr; nodeptr_block -> Delete(np); if (!orphan_first) orphan_last = NULL; if (i->is_sink) process_sink_orphan(i); else process_source_orphan(i); } orphan_first = np_next; } /* adoption end */ } else current_node = NULL; } // test_consistency(); if (!reuse_trees || (maxflow_iteration % 64) == 0) { delete nodeptr_block; nodeptr_block = NULL; } maxflow_iteration ++; return flow; } /***********************************************************************/ template <typename captype, typename tcaptype, typename flowtype> void Graph<captype,tcaptype,flowtype>::test_consistency(node* current_node) { node *i; arc *a; int r; int num1 = 0, num2 = 0; // test whether all nodes i with i->next!=NULL are indeed in the queue for (i=nodes; i<node_last; i++) { if (i->next || i==current_node) num1 ++; } for (r=0; r<3; r++) { i = (r == 2) ? current_node : queue_first[r]; if (i) for ( ; ; i=i->next) { num2 ++; if (i->next == i) { if (r<2) assert(i == queue_last[r]); else assert(i == current_node); break; } } } assert(num1 == num2); for (i=nodes; i<node_last; i++) { // test whether all edges in seach trees are non-saturated if (i->parent == NULL) {} else if (i->parent == ORPHAN) {} else if (i->parent == TERMINAL) { if (!i->is_sink) assert(i->tr_cap > 0); else assert(i->tr_cap < 0); } else { if (!i->is_sink) assert (i->parent->sister->r_cap > 0); else assert (i->parent->r_cap > 0); } // test whether passive nodes in search trees have neighbors in // a different tree through non-saturated edges if (i->parent && !i->next) { if (!i->is_sink) { assert(i->tr_cap >= 0); for (a=i->first; a; a=a->next) { if (a->r_cap > 0) assert(a->head->parent && !a->head->is_sink); } } else { assert(i->tr_cap <= 0); for (a=i->first; a; a=a->next) { if (a->sister->r_cap > 0) assert(a->head->parent && a->head->is_sink); } } } // test marking invariants if (i->parent && i->parent!=ORPHAN && i->parent!=TERMINAL) { assert(i->TS <= i->parent->head->TS); if (i->TS == i->parent->head->TS) assert(i->DIST > i->parent->head->DIST); } } } #include "instances.inc"
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
picking.h
.h
334
10
#pragma once //#include <glm/glm.hpp> // //glm::vec4 GetColorByIndex(int index); //int GetIndexByColor(int r, int g, int b); //int GetPickedColorIndexUnderMouse(); // //void Get3DRayUnderMouse(glm::vec3* v1, glm::vec3* v2); //bool RaySphereCollision(glm::vec3 vSphereCenter, float fSphereRadius, glm::vec3 vA, glm::vec3 vB);
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
FilterGraphCut.h
.h
103
9
#pragma once class FilterGraphCut { public: FilterGraphCut(void); ~FilterGraphCut(void); };
Unknown
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
RawDataProcessor.cpp
.cpp
3,028
93
#include "StdAfx.h" #include "RawDataProcessor.h" #include "DICOM ViewerDoc.h" #include "Scale.h" CRawDataProcessor::CRawDataProcessor(void) : m_uImageWidth(0) ,m_uImageHeight(0) ,m_uImageCount(0) ,m_nTexId(0) { } CRawDataProcessor::~CRawDataProcessor(void) { // If not initialized, then this will be zero. So no checking is needed. if( 0 != m_nTexId ) { glDeleteTextures( 1, (GLuint*)&m_nTexId ); } } bool CRawDataProcessor::ReadFile(CDICOMViewerDoc* _pDoc, int nWidth_i, int nHeight_i, int nSlices_i ) { // File has only image data. The dimension of the data should be known. m_uImageCount = nSlices_i; m_uImageWidth = nWidth_i; m_uImageHeight = nHeight_i; // Holds the RGBA buffer char* pRGBABuffer = new char[ m_uImageWidth*m_uImageHeight*m_uImageCount*4 ]; if( !pRGBABuffer) { return false; } // Convert the data to RGBA data. // Here we are simply putting the same value to R, G, B and A channels. // Usually for raw data, the alpha value will be constructed by a threshold value given by the user for(int z = 0; z < nSlices_i; z++) { for(int y = 0; y < nHeight_i; y++) { for(int x = 0; x < nWidth_i; x++) { pRGBABuffer[z*512*512*4+y*512*4+x*4] = 0; pRGBABuffer[z*512*512*4+y*512*4+x*4+1]= 0; pRGBABuffer[z*512*512*4+y*512*4+x*4+2]= 0; pRGBABuffer[z*512*512*4+y*512*4+x*4+3]= 0; int lux = m_Volume[z][y][x]; // int lux_d = DICOMtoImage(lux, _pDoc->m_HUmin, _pDoc->m_HUmax); if((_pDoc->m_startHisto < lux)&&(lux < _pDoc->m_endHisto)) { COLORREF color = GetKeyColor(lux); pRGBABuffer[z*512*512*4+y*512*4+x*4] = GetRValue(color); pRGBABuffer[z*512*512*4+y*512*4+x*4+1]= GetGValue(color); pRGBABuffer[z*512*512*4+y*512*4+x*4+2]= GetBValue(color); pRGBABuffer[z*512*512*4+y*512*4+x*4+3]= lux; } } } } // If this function is getting called again for another data file. // Deleting and creating texture is not a good idea, // we can use the glTexSubImage3D for better performance for such scenario. // I am not using that now :-) if( 0 != m_nTexId ) { glDeleteTextures( 1, (GLuint*)&m_nTexId ); } glGenTextures(1,(GLuint*)&m_nTexId ); glBindTexture( GL_TEXTURE_3D, m_nTexId ); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, m_uImageWidth, m_uImageHeight , m_uImageCount, 0, GL_RGBA, GL_UNSIGNED_BYTE, pRGBABuffer ); glBindTexture( GL_TEXTURE_3D, 0 ); delete[] pRGBABuffer; return true; }
C++
3D
IACT-Medical-Image-Processing/DICOM-3D-Viewer
FilterThres.h
.h
94
9
#pragma once class FilterThres { public: FilterThres(void); ~FilterThres(void); };
Unknown
3D
feos-org/feos
CHANGELOG.md
.md
12,666
182
# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] ### Packaging - Updated `quantity` dependency to 0.13 and removed the `typenum` dependency. [#323](https://github.com/feos-org/feos/pull/323) ## [0.9.2] - 2025-12-11 ### Fixed - Fixed calculation of enthalpies of adsorption for mixtures. [#329](https://github.com/feos-org/feos/pull/329) - Updated to `ndarray` 0.17 and `num-dual`0.13 to fix a broken dependency resolution. [#327](https://github.com/feos-org/feos/pull/327) - Fixed calculation of parameter combination in entropy scaling for mixtures in `viscosity_correlation`, `diffusion_correlation`, `thermal_conductivity_correlation`. [#323](https://github.com/feos-org/feos/pull/323) ## [0.9.1] - 2025-11-24 ### Fixed - Fixed a wrong Jacobian entry in `heteroazeotrope_t`. (Thanks to @ImagineBaggins for reporting the issue) [#320](https://github.com/feos-org/feos/pull/320) ## [0.9.0] - 2025-11-08 ### Added - Integrated the functionalities of [`feos-ad`](https://github.com/feos-org/feos-ad). [#289](https://github.com/feos-org/feos/pull/289) - In Rust: Full access to arbitrary derivatives of properties and phase equilibria with respect to model parameters. See, e.g., [`feos-campd`](https://github.com/feos-org/feos-campd) for an application to molecular design. - In Python: Specialized functions for the parallel evaluation of relevant properties (vapor pressure, liquid density, bubble/dew point pressure) including the gradients with respect to model parameters for parameter estimations or the inclusion in backpropagation frameworks. - Implement pure-component multiparameter equations of state from CoolProp. [#301](https://github.com/feos-org/feos/pull/301) ### Changed - :warning: Changed the format of parameter files. The contents of the old `model_record` field are now flattened into the `PureRecord`/`SegmentRecord`. [#233](https://github.com/feos-org/feos/pull/233) - Generalized the implementation of association to allow for arbitrarily many association sites per molecule or group and full control over each interaction. [#233](https://github.com/feos-org/feos/pull/233) [#290](https://github.com/feos-org/feos/pull/290) - Reimplemented the Python interface to avoid the necessity of having multiple classes with the same name. - `feos.eos.State` and `feos.dft.State` (and analogous classes) are combined into `feos.State`. [#274](https://github.com/feos-org/feos/pull/274) - All `feos.<model>.PureRecord` (and similar classes) are combined into `feos.PureRecord`. [#271](https://github.com/feos-org/feos/pull/271) - All Python classes are exported at the package root. [#309](https://github.com/feos-org/feos/pull/309) - Add initial density as optional argument to critical point algorithms. [#300](https://github.com/feos-org/feos/pull/300) ### Packaging - Updated `quantity` dependency to 0.12. - Updated `num-dual` dependency to 0.12. - Updated `numpy`, `PyO3` and `pythonize` dependencies to 0.27. - Updated `nalgebra` dependency to 0.34. ## [0.8.0] - 2024-12-28 ### Fixed - Fixed the handling of association records in combination with induced association in PC-SAFT [#264](https://github.com/feos-org/feos/pull/264) ### Packaging - Updated `quantity` dependency to 0.10. [#262](https://github.com/feos-org/feos/pull/262) - Updated `num-dual` dependency to 0.11. [#262](https://github.com/feos-org/feos/pull/262) - Updated `numpy` and `PyO3` dependencies to 0.23. [#262](https://github.com/feos-org/feos/pull/262) ## [0.7.0] - 2024-05-21 ### Added - Added SAFT-VR Mie equation of state. [#237](https://github.com/feos-org/feos/pull/237) - Added ePC-SAFT equation of state. [#229](https://github.com/feos-org/feos/pull/229) ### Changed - Updated model implementations to account for the removal of trait objects for Helmholtz energy contributions and the de Broglie in `feos-core`. [#226](https://github.com/feos-org/feos/pull/226) - Changed Helmholtz energy functions in `PcSaft` contributions so that the temperature-dependent diameter is re-used across different contributions. [#226](https://github.com/feos-org/feos/pull/226) - Renamed structs in `uvtheory` module in accordance with names in other models (`UV...` to `UVTheory...`). [#226](https://github.com/feos-org/feos/pull/226) - Restructured `uvtheory` module: added modules for BH and WCA. [#226](https://github.com/feos-org/feos/pull/226) - Updated github action versions for CI/CD. [#226](https://github.com/feos-org/feos/pull/226) - Added `codegen-units = 1` to `release-lto` profile. [#226](https://github.com/feos-org/feos/pull/226) ### Removed - Removed `VirialOrder` from `uvtheory` module. Orders are now variants of the existing `Perturbation` enum. [#226](https://github.com/feos-org/feos/pull/226) ### Packaging - Updated `quantity` dependency to 0.8. [#238](https://github.com/feos-org/feos/pull/238) - Updated `num-dual` dependency to 0.9. [#238](https://github.com/feos-org/feos/pull/238) - Updated `numpy` and `PyO3` dependencies to 0.21. [#238](https://github.com/feos-org/feos/pull/238) ## [0.6.1] - 2024-01-11 - Python only: Release the changes introduced in `feos-core` 0.6.1. ## [0.6.0] - 2023-12-19 ### Added - Added `EquationOfState.ideal_gas()` to initialize an equation of state that only consists of an ideal gas contribution. [#204](https://github.com/feos-org/feos/pull/204) - Added `PureRecord`, `SegmentRecord`, `Identifier`, and `IdentifierOption` to `feos.ideal_gas`. [#205](https://github.com/feos-org/feos/pull/205) - Added implementation of the Joback ideal gas model that was previously part of `feos-core`. [#204](https://github.com/feos-org/feos/pull/204) - Added an implementation of the ideal gas heat capacity based on DIPPR equations. [#204](https://github.com/feos-org/feos/pull/204) - Added re-exports for the members of `feos-core` and `feos-dft` in the new modules `feos::core` and `feos::dft`. [#212](https://github.com/feos-org/feos/pull/212) ### Changed - Split `feos.ideal_gas` into `feos.joback` and `feos.dippr`. [#204](https://github.com/feos-org/feos/pull/204) ## [0.5.1] - 2023-11-23 - Python only: Release the changes introduced in `feos-core` 0.5.1. ## [0.5.0] - 2023-10-20 ### Added - Added `IdealGasModel` enum that collects all implementors of the `IdealGas` trait. [#158](https://github.com/feos-org/feos/pull/158) - Added `feos.ideal_gas` module in Python from which (currently) `Joback` and `JobackParameters` are available. [#158](https://github.com/feos-org/feos/pull/158) - Added binary association parameters to PC-SAFT. [#167](https://github.com/feos-org/feos/pull/167) - Added derive for `EntropyScaling` for SAFT-VRQ Mie to `ResidualModel` and adjusted parameter initialization. [#179](https://github.com/feos-org/feos/pull/179) ### Changed - Changed the internal implementation of the association contribution to accomodate more general association schemes. [#150](https://github.com/feos-org/feos/pull/150) - To comply with the new association implementation, the default values of `na` and `nb` are now `0` rather than `1`. Parameter files have been adapted accordingly. [#150](https://github.com/feos-org/feos/pull/150) - Added the possibility to specify a pure component correction parameter `phi` for the heterosegmented gc PC-SAFT equation of state. [#157](https://github.com/feos-org/feos/pull/157) - Adjusted all models' implementation of the `Parameter` trait which now requires `Result`s in some methods. [#161](https://github.com/feos-org/feos/pull/161) - Renamed `EosVariant` to `ResidualModel`. [#158](https://github.com/feos-org/feos/pull/158) - Added methods to add an ideal gas contribution to an initialized equation of state object in Python. [#158](https://github.com/feos-org/feos/pull/158) - Moved `molar_weight` impls to `Residual` due to removal of `MolarWeight` trait. [#177](https://github.com/feos-org/feos/pull/158) ### Packaging - Updated `quantity` dependency to 0.7. - Updated `num-dual` dependency to 0.8. [#137](https://github.com/feos-org/feos/pull/137) - Updated `numpy` and `PyO3` dependencies to 0.20. ## [0.4.3] - 2023-03-20 - Python only: Release the changes introduced in `feos-core` 0.4.2. ## [0.4.2] - 2023-03-20 - Python only: Release the changes introduced in `feos-core` 0.4.1 and `feos-dft` 0.4.1. ## [0.4.1] - 2023-01-28 ### Changed - Replaced some slow array operations to make calculations with multiple associating molecules significantly faster. [#129](https://github.com/feos-org/feos/pull/129) ### Fixed - Fixed a regression introduced in [#108](https://github.com/feos-org/feos/pull/108) that lead to incorrect results for the 3B association scheme. [#129](https://github.com/feos-org/feos/pull/129) ## [0.4.0] - 2023-01-27 ### Added - Added SAFT-VRQ Mie equation of state and Helmholtz energy functional for first order Feynman-Hibbs corrected Mie fluids. [#79](https://github.com/feos-org/feos/pull/79) - Added `estimator` module to documentation. [#86](https://github.com/feos-org/feos/pull/86) - Added benchmarks for the evaluation of the Helmholtz energy and some properties of the `State` object for PC-SAFT. [#89](https://github.com/feos-org/feos/pull/89) - The Python class `StateVec` is exposed in both the `feos.eos` and `feos.dft` module. [#113](https://github.com/feos-org/feos/pull/113) - Added uv-B3-theory and additional optional argument `virial_order` to uvtheory constructor to enable uv-B3. [#98](https://github.com/feos-org/feos/pull/98) ### Changed - Export `EosVariant` and `FunctionalVariant` directly in the crate root instead of their own modules. [#62](https://github.com/feos-org/feos/pull/62) - Changed constructors `VaporPressure::new` and `DataSet.vapor_pressure` (Python) to take a new optional argument `critical_temperature`. [#86](https://github.com/feos-org/feos/pull/86) - The limitations of the homo gc method for PC-SAFT are enforced more strictly. [#88](https://github.com/feos-org/feos/pull/88) - Removed generics for units in all structs and traits in favor of static SI units. [#115](https://github.com/feos-org/feos/pull/115) ### Packaging - Updated `pyo3` and `numpy` dependencies to 0.18. [#119](https://github.com/feos-org/feos/pull/119) - Updated `quantity` dependency to 0.6. [#119](https://github.com/feos-org/feos/pull/119) - Updated `num-dual` dependency to 0.6. [#119](https://github.com/feos-org/feos/pull/119) ### Fixed - Fixed incorrect indexing that lead to panics in the polar contribution of gc-PC-SAFT. [#104](https://github.com/feos-org/feos/pull/104) - `VaporPressure` now returns an empty array instead of crashing. [#124](https://github.com/feos-org/feos/pull/124) ## [0.3.0] - 2022-09-14 - Major restructuring of the entire `feos` project. All individual models are reunited in the `feos` crate. `feos-core` and `feos-dft` still live as individual crates within the `feos` workspace. ## [0.2.1] - 2022-05-13 ### Fixed - Fixed a bug due to which the default ideal gas contribution was used for every equation of state. [#17](https://github.com/feos-org/feos/pull/17) ## [0.2.0] - 2022-05-10 ### Added - Added [gc-PC-SAFT](https://github.com/feos-org/feos-gc-pcsaft) equation of state and Helmholtz energy functional. - Added [PeTS](https://github.com/feos-org/feos-pets) equation of state and Helmholtz energy functional. - Added [UV-Theory](https://github.com/feos-org/feos-uvtheory) equation of state for Mie fluids. ### Changed - Combined all equations of state into a single Python class `EquationOfState` and all Helmholtz energy functionals into the Python class `HelmholtzEnergyFunctional`. [#11](https://github.com/feos-org/feos/pull/11) ### Packaging - Updated [`quantity`](https://github.com/itt-ustutt/quantity/blob/master/CHANGELOG.md) to 0.5.0. - Updated [`feos-core`](https://github.com/feos-org/feos-core/blob/main/CHANGELOG.md) to 0.2.0. - Updated [`feos-dft`](https://github.com/feos-org/feos-dft/blob/main/CHANGELOG.md) to 0.2.0. - Updated [`feos-pcsaft`](https://github.com/feos-org/feos-pcsaft/blob/main/CHANGELOG.md) to 0.2.0. ## [0.1.1] - 2022-02-23 ### Added - Added `pyproject.toml`. [#8](https://github.com/feos-org/feos/pull/8) - Fixed modules of `SI` classes to make them pickleable. [#8](https://github.com/feos-org/feos/pull/8) ### Packaging - Updated [`feos-core`](https://github.com/feos-org/feos-core/blob/main/CHANGELOG.md) to 0.1.5. - Updated [`feos-dft`](https://github.com/feos-org/feos-dft/blob/main/CHANGELOG.md) to 0.1.3. ## [0.1.0] - 2022-01-14 ### Added - Initial release
Markdown
3D
feos-org/feos
py-feos/src/estimator.rs
.rs
23,544
742
use crate::eos::PyEquationOfState; use crate::error::PyFeosError; use crate::ideal_gas::IdealGasModel; use crate::residual::ResidualModel; use crate::PyVerbosity; use feos::estimator::{ BinaryPhaseDiagram, BinaryVleChemicalPotential, BinaryVlePressure, DataSet, Diffusion, EquilibriumLiquidDensity, Estimator, LiquidDensity, Loss, Phase, VaporPressure, }; use feos_core::EquationOfState; use ndarray::Array1; use numpy::{PyArray1, PyArrayMethods, ToPyArray}; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use pyo3::PyErr; use quantity::*; use std::sync::Arc; #[derive(Debug, Clone, Copy, PartialEq)] #[pyclass(name = "Loss", eq)] pub(crate) enum PyLoss { Linear(), SoftL1(f64), Huber(f64), Cauchy(f64), Arctan(f64), } impl From<Loss> for PyLoss { fn from(value: Loss) -> Self { use Loss::*; match value { Linear => Self::Linear(), SoftL1(s) => Self::SoftL1(s), Huber(s) => Self::Huber(s), Cauchy(s) => Self::Cauchy(s), Arctan(s) => Self::Arctan(s), } } } impl From<PyLoss> for Loss { fn from(value: PyLoss) -> Self { use PyLoss::*; match value { Linear() => Self::Linear, SoftL1(s) => Self::SoftL1(s), Huber(s) => Self::Huber(s), Cauchy(s) => Self::Cauchy(s), Arctan(s) => Self::Arctan(s), } } } #[derive(Debug, Clone, Copy, PartialEq)] #[pyclass(name = "Phase", eq, eq_int)] pub(crate) enum PyPhase { Vapor, Liquid, } impl From<Phase> for PyPhase { fn from(value: Phase) -> Self { use Phase::*; match value { Vapor => Self::Vapor, Liquid => Self::Liquid, } } } impl From<PyPhase> for Phase { fn from(value: PyPhase) -> Self { use PyPhase::*; match value { Vapor => Self::Vapor, Liquid => Self::Liquid, } } } /// A collection of experimental data that can be used to compute /// cost functions and make predictions using an equation of state. #[pyclass(name = "DataSet")] #[derive(Clone)] pub struct PyDataSet(Arc<dyn DataSet<EquationOfState<IdealGasModel, ResidualModel>>>); #[pymethods] impl PyDataSet { /// Compute the cost function for each input value. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state that is used. /// loss : Loss /// The loss function that is applied to residuals /// to handle outliers. /// /// Returns /// ------- /// numpy.ndarray[Float] /// The cost function evaluated for each experimental data point. /// /// Note /// ---- /// The cost function that is used depends on the /// property. For most properties it is the absolute relative difference. /// See the constructors of the respective properties /// to learn about the cost functions that are used. #[pyo3(text_signature = "($self, eos, loss)")] fn cost<'py>( &self, eos: &PyEquationOfState, loss: PyLoss, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray1<f64>>> { Ok(self .0 .cost(&eos.0, loss.into()) .map_err(PyFeosError::from)? .view() .to_pyarray(py)) } /// Return the property of interest for each data point /// of the input as computed by the equation of state. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state that is used. /// /// Returns /// ------- /// SIArray1 #[pyo3(text_signature = "($self, eos)")] fn predict<'py>( &self, eos: &PyEquationOfState, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray1<f64>>> { Ok(self .0 .predict(&eos.0) .map_err(PyFeosError::from)? .view() .to_pyarray(py)) } /// Return the relative difference between experimental data /// and prediction of the equation of state. /// /// The relative difference is computed as: /// /// .. math:: \text{Relative Difference} = \frac{x_i^\text{prediction} - x_i^\text{experiment}}{x_i^\text{experiment}} /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state that is used. /// /// Returns /// ------- /// numpy.ndarray[Float] #[pyo3(text_signature = "($self, eos)")] fn relative_difference<'py>( &self, eos: &PyEquationOfState, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray1<f64>>> { Ok(self .0 .relative_difference(&eos.0) .map_err(PyFeosError::from)? .view() .to_pyarray(py)) } /// Return the mean absolute relative difference. /// /// The mean absolute relative difference is computed as: /// /// .. math:: \text{MARD} = \frac{1}{N}\sum_{i=1}^{N} \left|\frac{x_i^\text{prediction} - x_i^\text{experiment}}{x_i^\text{experiment}} \right| /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state that is used. /// /// Returns /// ------- /// Float #[pyo3(text_signature = "($self, eos)")] fn mean_absolute_relative_difference(&self, eos: &PyEquationOfState) -> PyResult<f64> { Ok(self .0 .mean_absolute_relative_difference(&eos.0) .map_err(PyFeosError::from)?) } /// Create a DataSet with experimental data for vapor pressure. /// /// Parameters /// ---------- /// target : SIArray1 /// Experimental data for vapor pressure. /// temperature : SIArray1 /// Temperature for experimental data points. /// extrapolate : bool, optional /// Use Antoine type equation to extrapolate vapor /// pressure if experimental data is above critial /// point of model. Defaults to False. /// critical_temperature : SINumber, optional /// Estimate of the critical temperature used as initial /// value for critical point calculation. Defaults to None. /// For additional information, see note. /// max_iter : int, optional /// The maximum number of iterations for critical point /// and VLE algorithms. /// tol: float, optional /// Solution tolerance for critical point /// and VLE algorithms. /// verbosity : Verbosity, optional /// Verbosity for critical point /// and VLE algorithms. /// /// Returns /// ------- /// ``DataSet`` /// /// Note /// ---- /// If no critical temperature is provided, the maximum of the `temperature` input /// is used. If that fails, the default temperatures of the critical point routine /// are used. #[staticmethod] #[pyo3( text_signature = "(target, temperature, extrapolate, critical_temperature=None, max_iter=None, tol=None, verbosity=None)" )] #[pyo3(signature = (target, temperature, extrapolate, critical_temperature=None, max_iter=None, tol=None, verbosity=None))] fn vapor_pressure( target: Pressure<Array1<f64>>, temperature: Temperature<Array1<f64>>, extrapolate: Option<bool>, critical_temperature: Option<Temperature>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> Self { Self(Arc::new(VaporPressure::new( target, temperature, extrapolate.unwrap_or(false), critical_temperature, Some((max_iter, tol, verbosity.map(|v| v.into())).into()), ))) } /// Create a DataSet with experimental data for liquid density. /// /// Parameters /// ---------- /// target : SIArray1 /// Experimental data for liquid density. /// temperature : SIArray1 /// Temperature for experimental data points. /// pressure : SIArray1 /// Pressure for experimental data points. /// /// Returns /// ------- /// DataSet #[staticmethod] #[pyo3(text_signature = "(target, temperature, pressure)")] fn liquid_density( target: MassDensity<Array1<f64>>, temperature: Temperature<Array1<f64>>, pressure: Pressure<Array1<f64>>, ) -> Self { Self(Arc::new(LiquidDensity::new(target, temperature, pressure))) } /// Create a DataSet with experimental data for liquid density /// for a vapor liquid equilibrium. /// /// Parameters /// ---------- /// target : SIArray1 /// Experimental data for liquid density. /// temperature : SIArray1 /// Temperature for experimental data points. /// max_iter : int, optional /// The maximum number of iterations for critical point /// and VLE algorithms. /// tol: float, optional /// Solution tolerance for critical point /// and VLE algorithms. /// verbosity : Verbosity, optional /// Verbosity for critical point /// and VLE algorithms. /// /// Returns /// ------- /// DataSet #[staticmethod] #[pyo3(text_signature = "(target, temperature, max_iter=None, tol=None, verbosity=None)")] #[pyo3(signature = (target, temperature, max_iter=None, tol=None, verbosity=None))] fn equilibrium_liquid_density( target: MassDensity<Array1<f64>>, temperature: Temperature<Array1<f64>>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> Self { Self(Arc::new(EquilibriumLiquidDensity::new( target, temperature, Some((max_iter, tol, verbosity.map(|v| v.into())).into()), ))) } /// Create a DataSet with experimental data for binary /// phase equilibria using the chemical potential residual. /// /// Parameters /// ---------- /// temperature : SIArray1 /// Temperature of the experimental data points. /// pressure : SIArray1 /// Pressure of the experimental data points. /// liquid_molefracs : np.array[float] /// Molar composition of component 1 in the liquid phase. /// vapor_molefracs : np.array[float] /// Molar composition of component 1 in the vapor phase. /// /// Returns /// ------- /// DataSet #[staticmethod] #[pyo3(text_signature = "(temperature, pressure, liquid_molefracs, vapor_molefracs)")] fn binary_vle_chemical_potential( temperature: Temperature<Array1<f64>>, pressure: Pressure<Array1<f64>>, liquid_molefracs: &Bound<'_, PyArray1<f64>>, vapor_molefracs: &Bound<'_, PyArray1<f64>>, ) -> Self { Self(Arc::new(BinaryVleChemicalPotential::new( temperature, pressure, liquid_molefracs.to_owned_array(), vapor_molefracs.to_owned_array(), ))) } /// Create a DataSet with experimental data for binary /// phase equilibria using the pressure residual. /// /// Parameters /// ---------- /// temperature : SIArray1 /// Temperature of the experimental data points. /// pressure : SIArray1 /// Pressure of the experimental data points. /// molefracs : np.array[float] /// Molar composition of component 1 in the considered phase. /// phase : Phase /// The phase of the experimental data points. /// /// Returns /// ------- /// DataSet #[staticmethod] #[pyo3(text_signature = "(temperature, pressure, molefracs, phase)")] fn binary_vle_pressure( temperature: Temperature<Array1<f64>>, pressure: Pressure<Array1<f64>>, molefracs: &Bound<'_, PyArray1<f64>>, phase: PyPhase, ) -> Self { Self(Arc::new(BinaryVlePressure::new( temperature, pressure, molefracs.to_owned_array(), phase.into(), ))) } /// Create a DataSet with experimental data for binary /// phase diagrams using the distance residual. /// /// Parameters /// ---------- /// specification : SINumber /// The constant temperature/pressure of the isotherm/isobar. /// temperature_or_pressure : SIArray1 /// The temperature (isobar) or pressure (isotherm) of the /// experimental data points. /// liquid_molefracs : np.array[float], optional /// Molar composition of component 1 in the liquid phase. /// vapor_molefracs : np.array[float], optional /// Molar composition of component 1 in the vapor phase. /// npoints : int, optional /// The resolution of the phase diagram used to calculate /// the distance residual. /// /// Returns /// ------- /// DataSet #[staticmethod] #[pyo3( text_signature = "(specification, temperature_or_pressure, liquid_molefracs=None, vapor_molefracs=None, npoints=None)" )] #[pyo3(signature = (specification, temperature_or_pressure, liquid_molefracs=None, vapor_molefracs=None, npoints=None))] fn binary_phase_diagram( specification: Bound<'_, PyAny>, temperature_or_pressure: Bound<'_, PyAny>, liquid_molefracs: Option<&Bound<'_, PyArray1<f64>>>, vapor_molefracs: Option<&Bound<'_, PyArray1<f64>>>, npoints: Option<usize>, ) -> PyResult<Self> { if let Ok(t) = specification.extract::<Temperature>() { Ok(Self(Arc::new(BinaryPhaseDiagram::new( t, temperature_or_pressure.extract()?, liquid_molefracs.map(|x| x.to_owned_array()), vapor_molefracs.map(|x| x.to_owned_array()), npoints, )))) } else if let Ok(p) = specification.extract::<Pressure>() { Ok(Self(Arc::new(BinaryPhaseDiagram::new( p, temperature_or_pressure.extract()?, liquid_molefracs.map(|x| x.to_owned_array()), vapor_molefracs.map(|x| x.to_owned_array()), npoints, )))) } else { Err(PyErr::new::<PyValueError, _>(format!( "Wrong units! Expected K or Pa, got {}.", temperature_or_pressure.call_method0("__repr__")? ))) } } /// Return `target` as ``SIArray1``. #[getter] fn get_target<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1<f64>> { self.0.target().view().to_pyarray(py) } /// Return number of stored data points. #[getter] fn get_datapoints(&self) -> usize { self.0.datapoints() } fn __repr__(&self) -> PyResult<String> { Ok(self.0.to_string()) } } /// A collection of `DataSet`s that can be used to compute metrics for experimental data. /// /// Parameters /// ---------- /// data : List[DataSet] /// The properties and experimental data points to add to /// the estimator. /// weights : List[float] /// The weight of each property. When computing the cost function, /// the weights are normalized (sum of weights equals unity). /// losses : List[Loss] /// The loss functions for each property. /// /// Returns /// ------- /// Estimator #[pyclass(name = "Estimator")] pub struct PyEstimator(Estimator<EquationOfState<IdealGasModel, ResidualModel>>); #[pymethods] impl PyEstimator { #[new] #[pyo3(text_signature = "(data, weights, losses)")] fn new(data: Vec<PyDataSet>, weights: Vec<f64>, losses: Vec<PyLoss>) -> Self { Self(Estimator::new( data.iter().map(|d| d.0.clone()).collect(), weights, losses.iter().map(|&l| l.into()).collect(), )) } /// Compute the cost function for each ``DataSet``. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state that is used. /// /// Returns /// ------- /// numpy.ndarray[Float] /// The cost function evaluated for each experimental data point /// of each ``DataSet``. /// /// Note /// ---- /// The cost function is: /// /// - The relative difference between prediction and target value, /// - to which a loss function is applied, /// - and which is weighted according to the number of datapoints, /// - and the relative weights as defined in the Estimator object. #[pyo3(text_signature = "($self, eos)")] fn cost<'py>( &self, eos: &PyEquationOfState, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray1<f64>>> { Ok(self .0 .cost(&eos.0) .map_err(PyFeosError::from)? .view() .to_pyarray(py)) } /// Return the properties as computed by the /// equation of state for each `DataSet`. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state that is used. /// /// Returns /// ------- /// List[SIArray1] #[pyo3(text_signature = "($self, eos)")] fn predict<'py>( &self, eos: &PyEquationOfState, py: Python<'py>, ) -> PyResult<Vec<Bound<'py, PyArray1<f64>>>> { Ok(self .0 .predict(&eos.0) .map_err(PyFeosError::from)? .iter() .map(|d| d.view().to_pyarray(py)) .collect()) } /// Return the relative difference between experimental data /// and prediction of the equation of state for each ``DataSet``. /// /// The relative difference is computed as: /// /// .. math:: \text{Relative Difference} = \frac{x_i^\text{prediction} - x_i^\text{experiment}}{x_i^\text{experiment}} /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state that is used. /// /// Returns /// ------- /// List[numpy.ndarray[Float]] #[pyo3(text_signature = "($self, eos)")] fn relative_difference<'py>( &self, eos: &PyEquationOfState, py: Python<'py>, ) -> PyResult<Vec<Bound<'py, PyArray1<f64>>>> { Ok(self .0 .relative_difference(&eos.0) .map_err(PyFeosError::from)? .iter() .map(|d| d.view().to_pyarray(py)) .collect()) } /// Return the mean absolute relative difference for each ``DataSet``. /// /// The mean absolute relative difference is computed as: /// /// .. math:: \text{MARD} = \frac{1}{N}\sum_{i=1}^{N} \left|\frac{x_i^\text{prediction} - x_i^\text{experiment}}{x_i^\text{experiment}} \right| /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state that is used. /// /// Returns /// ------- /// numpy.ndarray[Float] #[pyo3(text_signature = "($self, eos)")] fn mean_absolute_relative_difference<'py>( &self, eos: &PyEquationOfState, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray1<f64>>> { Ok(self .0 .mean_absolute_relative_difference(&eos.0) .map_err(PyFeosError::from)? .view() .to_pyarray(py)) } /// Return the stored ``DataSet``s. /// /// Returns /// ------- /// List[DataSet] #[getter] fn get_datasets(&self) -> Vec<PyDataSet> { self.0.datasets().iter().cloned().map(PyDataSet).collect() } fn _repr_markdown_(&self) -> String { self.0._repr_markdownn_() } fn __repr__(&self) -> PyResult<String> { Ok(self.0.to_string()) } } #[pymethods] impl PyDataSet { /// Create a DataSet with experimental data for viscosity. /// /// Parameters /// ---------- /// target : SIArray1 /// Experimental data for viscosity. /// temperature : SIArray1 /// Temperature for experimental data points. /// pressure : SIArray1 /// Pressure for experimental data points. /// phase : List[Phase], optional /// Phase of data. Used to determine the starting /// density for the density iteration. If provided, /// resulting states may not be stable. /// /// Returns /// ------- /// DataSet #[staticmethod] #[pyo3(text_signature = "(target, temperature, pressure, phase=None)")] #[pyo3(signature = (target, temperature, pressure, phase=None))] fn viscosity( target: quantity::Viscosity<Array1<f64>>, temperature: Temperature<Array1<f64>>, pressure: Pressure<Array1<f64>>, phase: Option<Vec<PyPhase>>, ) -> Self { let p = phase.map(|p| (p.into_iter().map(|p| p.into()).collect())); Self(Arc::new(feos::estimator::Viscosity::new( target, temperature, pressure, p.as_ref(), ))) } /// Create a DataSet with experimental data for thermal conductivity. /// /// Parameters /// ---------- /// target : SIArray1 /// Experimental data for thermal conductivity. /// temperature : SIArray1 /// Temperature for experimental data points. /// pressure : SIArray1 /// Pressure for experimental data points. /// phase : List[Phase], optional /// Phase of data. Used to determine the starting /// density for the density iteration. If provided, /// resulting states may not be stable. /// /// Returns /// ------- /// DataSet #[staticmethod] #[pyo3(text_signature = "(target, temperature, pressure, phase=None)")] #[pyo3(signature = (target, temperature, pressure, phase=None))] fn thermal_conductivity( target: quantity::ThermalConductivity<Array1<f64>>, temperature: Temperature<Array1<f64>>, pressure: Pressure<Array1<f64>>, phase: Option<Vec<PyPhase>>, ) -> Self { let p = phase.map(|p| (p.into_iter().map(|p| p.into()).collect())); Self(Arc::new(feos::estimator::ThermalConductivity::new( target, temperature, pressure, p.as_ref(), ))) } /// Create a DataSet with experimental data for diffusion coefficient. /// /// Parameters /// ---------- /// target : SIArray1 /// Experimental data for diffusion coefficient. /// temperature : SIArray1 /// Temperature for experimental data points. /// pressure : SIArray1 /// Pressure for experimental data points. /// phase : List[Phase], optional /// Phase of data. Used to determine the starting /// density for the density iteration. If provided, /// resulting states may not be stable. /// /// Returns /// ------- /// DataSet #[staticmethod] #[pyo3(text_signature = "(target, temperature, pressure, phase=None)")] #[pyo3(signature = (target, temperature, pressure, phase=None))] fn diffusion( target: quantity::Diffusivity<Array1<f64>>, temperature: Temperature<Array1<f64>>, pressure: Pressure<Array1<f64>>, phase: Option<Vec<PyPhase>>, ) -> Self { let p = phase.map(|p| (p.into_iter().map(|p| p.into()).collect())); Self(Arc::new(Diffusion::new( target, temperature, pressure, p.as_ref(), ))) } }
Rust
3D
feos-org/feos
py-feos/src/lib.rs
.rs
3,980
132
#![warn(clippy::all)] #![warn(clippy::allow_attributes)] use feos_core::Verbosity; use pyo3::prelude::*; #[cfg(feature = "ad")] pub(crate) mod ad; #[cfg(feature = "dft")] pub(crate) mod dft; pub(crate) mod eos; pub(crate) mod error; // pub(crate) mod estimator; pub(crate) mod ideal_gas; pub(crate) mod parameter; pub(crate) mod phase_equilibria; pub(crate) mod residual; pub(crate) mod state; pub(crate) mod user_defined; /// Output level for phase equilibrium solvers. #[derive(Debug, Clone, Copy, PartialEq)] #[pyclass(name = "Verbosity", eq, eq_int)] pub(crate) enum PyVerbosity { /// Do not print output. None, /// Print information about the success of failure of the iteration. Result, /// Print a detailed outpur for every iteration. Iter, } impl From<Verbosity> for PyVerbosity { fn from(value: Verbosity) -> Self { use Verbosity::*; match value { None => Self::None, Result => Self::Result, Iter => Self::Iter, } } } impl From<PyVerbosity> for Verbosity { fn from(value: PyVerbosity) -> Self { use PyVerbosity::*; match value { None => Self::None, Result => Self::Result, Iter => Self::Iter, } } } #[pymodule] fn feos(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add("__version__", env!("CARGO_PKG_VERSION"))?; // Utility m.add_class::<PyVerbosity>()?; // State & phase equilibria. m.add_class::<state::PyContributions>()?; m.add_class::<state::PyState>()?; m.add_class::<state::PyStateVec>()?; m.add_class::<phase_equilibria::PyPhaseDiagram>()?; m.add_class::<phase_equilibria::PyPhaseDiagramHetero>()?; m.add_class::<phase_equilibria::PyPhaseEquilibrium>()?; // Parameter m.add_class::<parameter::PyIdentifier>()?; m.add_class::<parameter::PyIdentifierOption>()?; m.add_class::<parameter::PyChemicalRecord>()?; m.add_class::<parameter::PySmartsRecord>()?; m.add_class::<parameter::PyPureRecord>()?; m.add_class::<parameter::PySegmentRecord>()?; m.add_class::<parameter::PyBinaryRecord>()?; m.add_class::<parameter::PyBinarySegmentRecord>()?; m.add_class::<parameter::PyParameters>()?; m.add_class::<parameter::PyGcParameters>()?; // Equation of state m.add_class::<eos::PyEquationOfState>()?; // // Estimator // m.add_class::<estimator::PyDataSet>()?; // m.add_class::<estimator::PyEstimator>()?; // m.add_class::<estimator::PyLoss>()?; // m.add_class::<estimator::PyPhase>()?; // AD #[cfg(feature = "ad")] { m.add_function(wrap_pyfunction!(ad::vapor_pressure_derivatives, m)?)?; m.add_function(wrap_pyfunction!(ad::liquid_density_derivatives, m)?)?; m.add_function(wrap_pyfunction!( ad::equilibrium_liquid_density_derivatives, m )?)?; m.add_function(wrap_pyfunction!(ad::bubble_point_pressure_derivatives, m)?)?; m.add_function(wrap_pyfunction!(ad::dew_point_pressure_derivatives, m)?)?; m.add_class::<ad::PyEquationOfStateAD>()?; } #[cfg(feature = "dft")] { m.add_class::<dft::PyHelmholtzEnergyFunctional>()?; m.add_class::<dft::PyFMTVersion>()?; m.add_class::<dft::PyGeometry>()?; // Solver m.add_class::<dft::PyDFTSolver>()?; m.add_class::<dft::PyDFTSolverLog>()?; // Adsorption m.add_class::<dft::PyAdsorption1D>()?; m.add_class::<dft::PyAdsorption3D>()?; m.add_class::<dft::PyExternalPotential>()?; m.add_class::<dft::PyPore1D>()?; m.add_class::<dft::PyPore2D>()?; m.add_class::<dft::PyPore3D>()?; // Interface m.add_class::<dft::PySurfaceTensionDiagram>()?; m.add_class::<dft::PyPlanarInterface>()?; // Solvation m.add_class::<dft::PyPairCorrelation>()?; m.add_class::<dft::PySolvationProfile>()?; } Ok(()) }
Rust
3D
feos-org/feos
py-feos/src/state.rs
.rs
53,537
1,686
use crate::eos::parse_molefracs; use crate::{ PyVerbosity, eos::PyEquationOfState, error::PyFeosError, ideal_gas::IdealGasModel, residual::ResidualModel, }; use feos_core::{ Contributions, DensityInitialization, EquationOfState, FeosError, ResidualDyn, State, StateVec, }; use ndarray::{Array1, Array2}; use numpy::nalgebra::{DMatrix, DVector}; use numpy::{IntoPyArray, PyArray1, PyArray2, PyReadonlyArray1, ToPyArray}; use pyo3::exceptions::{PyIndexError, PyValueError}; use pyo3::prelude::*; use quantity::*; use std::collections::HashMap; use std::ops::{Deref, Div, Neg, Sub}; use std::sync::Arc; type Quot<T1, T2> = <T1 as Div<T2>>::Output; type DpDn<T> = Quantity<T, <_Pressure as Sub<_Moles>>::Output>; type InvT<T> = Quantity<T, <_Temperature as Neg>::Output>; type InvP<T> = Quantity<T, <_Pressure as Neg>::Output>; type InvM<T> = Quantity<T, <_Moles as Neg>::Output>; /// Possible contributions that can be computed. #[derive(Clone, Copy, PartialEq)] #[pyclass(name = "Contributions", eq, eq_int)] pub enum PyContributions { /// Only compute the ideal gas contribution IdealGas, /// Only compute the difference between the total and the ideal gas contribution Residual, /// Compute ideal gas and residual contributions Total, } impl From<Contributions> for PyContributions { fn from(value: Contributions) -> Self { use Contributions::*; match value { IdealGas => Self::IdealGas, Residual => Self::Residual, Total => Self::Total, } } } impl From<PyContributions> for Contributions { fn from(value: PyContributions) -> Self { use PyContributions::*; match value { IdealGas => Self::IdealGas, Residual => Self::Residual, Total => Self::Total, } } } /// A thermodynamic state at given conditions. /// /// Parameters /// ---------- /// eos : Eos /// The equation of state to use. /// temperature : SINumber, optional /// Temperature. /// volume : SINumber, optional /// Volume. /// density : SINumber, optional /// Molar density. /// partial_density : SIArray1, optional /// Partial molar densities. /// total_moles : SINumber, optional /// Total amount of substance (of a mixture). /// moles : SIArray1, optional /// Amount of substance for each component. /// molefracs : numpy.ndarray[float] /// Molar fraction of each component. /// pressure : SINumber, optional /// Pressure. /// molar_enthalpy : SINumber, optional /// Molar enthalpy. /// molar_entropy : SINumber, optional /// Molar entropy. /// molar_internal_energy: SINumber, optional /// Molar internal energy /// density_initialization : {'vapor', 'liquid', SINumber, None}, optional /// Method used to initialize density for density iteration. /// 'vapor' and 'liquid' are inferred from the maximum density of the equation of state. /// If no density or keyword is provided, the vapor and liquid phase is tested and, if /// different, the result with the lower free energy is returned. /// initial_temperature : SINumber, optional /// Initial temperature for temperature iteration. Can improve convergence /// when the state is specified with pressure and molar entropy or enthalpy. /// /// Returns /// ------- /// State : state at given conditions /// /// Raises /// ------ /// Error /// When the state cannot be created using the combination of input. #[pyclass(name = "State")] #[derive(Clone)] pub struct PyState(pub State<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>); #[pymethods] impl PyState { #[new] #[pyo3( text_signature = "(eos, temperature=None, volume=None, density=None, partial_density=None, total_moles=None, moles=None, molefracs=None, pressure=None, molar_enthalpy=None, molar_entropy=None, molar_internal_energy=None, density_initialization=None, initial_temperature=None)" )] #[pyo3(signature = (eos, temperature=None, volume=None, density=None, partial_density=None, total_moles=None, moles=None, molefracs=None, pressure=None, molar_enthalpy=None, molar_entropy=None, molar_internal_energy=None, density_initialization=None, initial_temperature=None))] #[expect(clippy::too_many_arguments)] pub fn new<'py>( eos: &PyEquationOfState, temperature: Option<Temperature>, volume: Option<Volume>, density: Option<Density>, partial_density: Option<Density<DVector<f64>>>, total_moles: Option<Moles>, moles: Option<Moles<DVector<f64>>>, molefracs: Option<PyReadonlyArray1<'py, f64>>, pressure: Option<Pressure>, molar_enthalpy: Option<MolarEnergy>, molar_entropy: Option<MolarEntropy>, molar_internal_energy: Option<MolarEnergy>, density_initialization: Option<&Bound<'py, PyAny>>, initial_temperature: Option<Temperature>, ) -> PyResult<Self> { let x = parse_molefracs(molefracs); let density_init = if let Some(di) = density_initialization { if let Ok(d) = di.extract::<String>().as_deref() { match d { "vapor" => Ok(Some(DensityInitialization::Vapor)), "liquid" => Ok(Some(DensityInitialization::Liquid)), _ => Err(PyErr::new::<PyValueError, _>( "`density_initialization` must be 'vapor' or 'liquid'.".to_string(), )), } } else if let Ok(d) = di.extract::<Density>() { Ok(Some(DensityInitialization::InitialDensity(d))) } else { Err(PyErr::new::<PyValueError, _>("`density_initialization` must be 'vapor' or 'liquid' or a molar density as `SINumber` has to be provided.".to_string())) } } else { Ok(None) }; let s = State::new_full( &eos.0, temperature, volume, density, partial_density.as_ref(), total_moles, moles.as_ref(), x.as_ref(), pressure, molar_enthalpy, molar_entropy, molar_internal_energy, density_init?, initial_temperature, ) .map_err(PyFeosError::from)?; Ok(Self(s)) } /// Return a list of thermodynamic state at critical conditions /// for each pure substance in the system. /// /// Parameters /// ---------- /// eos: EquationOfState /// The equation of state to use. /// initial_temperature: SINumber, optional /// The initial temperature. /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// list[State] : List of pure-substance State objects at critical conditions. #[staticmethod] #[pyo3( text_signature = "(eos, initial_temperature=None, initial_density=None, max_iter=None, tol=None, verbosity=None)" )] #[pyo3(signature = (eos, initial_temperature=None, initial_density=None, max_iter=None, tol=None, verbosity=None))] fn critical_point_pure( eos: &PyEquationOfState, initial_temperature: Option<Temperature>, initial_density: Option<Density>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Vec<Self>> { let cp = State::critical_point_pure( &eos.0, initial_temperature, initial_density, (max_iter, tol, verbosity.map(|v| v.into())).into(), ) .map_err(PyFeosError::from)?; Ok(cp.into_iter().map(Self).collect()) } /// Create a thermodynamic state at critical conditions. /// /// Parameters /// ---------- /// eos: EquationOfState /// The equation of state to use. /// molefracs: np.ndarray[float], optional /// Molar composition. /// Only optional for a pure component. /// initial_temperature: SINumber, optional /// The initial temperature. /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// State : State at critical conditions. #[staticmethod] #[pyo3( text_signature = "(eos, molefracs=None, initial_temperature=None, initial_density=None, max_iter=None, tol=None, verbosity=None)" )] #[pyo3(signature = (eos, molefracs=None, initial_temperature=None, initial_density=None, max_iter=None, tol=None, verbosity=None))] fn critical_point<'py>( eos: &PyEquationOfState, molefracs: Option<PyReadonlyArray1<'py, f64>>, initial_temperature: Option<Temperature>, initial_density: Option<Density>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Self> { Ok(PyState( State::critical_point( &eos.0, parse_molefracs(molefracs).as_ref(), initial_temperature, initial_density, (max_iter, tol, verbosity.map(|v| v.into())).into(), ) .map_err(PyFeosError::from)?, )) } /// Create a thermodynamic state at critical conditions for a binary system. /// /// Parameters /// ---------- /// eos: EquationOfState /// The equation of state to use. /// temperature_or_pressure: SINumber /// temperature_or_pressure. /// initial_temperature: SINumber, optional /// An initial guess for the temperature. /// initial_molefracs: [float], optional /// An initial guess for the composition. /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// State : State at critical conditions. #[staticmethod] #[pyo3( text_signature = "(eos, temperature_or_pressure, initial_temperature=None, initial_molefracs=None, initial_density=None, max_iter=None, tol=None, verbosity=None)" )] #[pyo3(signature = (eos, temperature_or_pressure, initial_temperature=None, initial_molefracs=None, initial_density=None, max_iter=None, tol=None, verbosity=None))] #[expect(clippy::too_many_arguments)] fn critical_point_binary( eos: &PyEquationOfState, temperature_or_pressure: Bound<'_, PyAny>, initial_temperature: Option<Temperature>, initial_molefracs: Option<[f64; 2]>, initial_density: Option<Density>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Self> { let v = verbosity.map(|v| v.into()); if let Ok(t) = temperature_or_pressure.extract::<Temperature>() { Ok(PyState( State::critical_point_binary( &eos.0, t, initial_temperature, initial_molefracs, initial_density, (max_iter, tol, v).into(), ) .map_err(PyFeosError::from)?, )) } else if let Ok(p) = temperature_or_pressure.extract::<Pressure>() { Ok(PyState( State::critical_point_binary( &eos.0, p, initial_temperature, initial_molefracs, initial_density, (max_iter, tol, v).into(), ) .map_err(PyFeosError::from)?, )) } else { let repr = temperature_or_pressure .call_method0("__repr__") .map_err(|e| FeosError::Error(e.to_string())) .map_err(PyFeosError::from)?; let err = FeosError::WrongUnits("K or Pa".to_string(), repr.to_string()); Err(PyFeosError::from(err).into()) } } /// Calculate spinodal states for a given temperature and composition. /// /// Parameters /// ---------- /// eos: EquationOfState /// The equation of state to use. /// temperature: SINumber /// The temperature. /// molefracs: np.ndarray[float], optional /// Molar composition. /// Only optional for a pure component. /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// (State, State): Spinodal states. #[staticmethod] #[pyo3( text_signature = "(eos, temperature, molefracs=None, max_iter=None, tol=None, verbosity=None)" )] #[pyo3(signature = (eos, temperature, molefracs=None, max_iter=None, tol=None, verbosity=None))] fn spinodal<'py>( eos: &PyEquationOfState, temperature: Temperature, molefracs: Option<PyReadonlyArray1<'py, f64>>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<(Self, Self)> { let [state1, state2] = State::spinodal( &eos.0, temperature, parse_molefracs(molefracs).as_ref(), (max_iter, tol, verbosity.map(|v| v.into())).into(), ) .map_err(PyFeosError::from)?; Ok((PyState(state1), PyState(state2))) } /// Performs a stability analysis and returns a list of stable /// candidate states. /// /// Parameters /// ---------- /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// State #[pyo3(text_signature = "(max_iter=None, tol=None, verbosity=None)")] #[pyo3(signature = (max_iter=None, tol=None, verbosity=None))] fn stability_analysis( &self, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Vec<Self>> { Ok(self .0 .stability_analysis((max_iter, tol, verbosity.map(|v| v.into())).into()) .map_err(PyFeosError::from)? .into_iter() .map(Self) .collect()) } /// Performs a stability analysis and returns whether the state /// is stable /// /// Parameters /// ---------- /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// bool #[pyo3(text_signature = "(max_iter=None, tol=None, verbosity=None)")] #[pyo3(signature = (max_iter=None, tol=None, verbosity=None))] fn is_stable( &self, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<bool> { Ok(self .0 .is_stable((max_iter, tol, verbosity.map(|v| v.into())).into()) .map_err(PyFeosError::from)?) } /// Return pressure. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn pressure(&self, contributions: PyContributions) -> Pressure { self.0.pressure(contributions.into()) } /// Return pressure contributions. /// /// Returns /// ------- /// List[Tuple[str, SINumber]] fn pressure_contributions(&self) -> Vec<(&'static str, Pressure)> { self.0.pressure_contributions() } /// Return compressibility. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// float #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn compressibility(&self, contributions: PyContributions) -> f64 { self.0.compressibility(contributions.into()) } /// Return partial derivative of pressure w.r.t. volume. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn dp_dv(&self, contributions: PyContributions) -> Quot<Pressure, Volume> { self.0.dp_dv(contributions.into()) } /// Return partial derivative of pressure w.r.t. density. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn dp_drho(&self, contributions: PyContributions) -> Quot<Pressure, Density> { self.0.dp_drho(contributions.into()) } /// Return partial derivative of pressure w.r.t. temperature. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn dp_dt(&self, contributions: PyContributions) -> Quot<Pressure, Temperature> { self.0.dp_dt(contributions.into()) } /// Return partial derivative of pressure w.r.t. amount of substance. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SIArray1 #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn dp_dni(&self, contributions: PyContributions) -> DpDn<DVector<f64>> { self.0.dp_dni(contributions.into()) } /// Return second partial derivative of pressure w.r.t. volume. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn d2p_dv2(&self, contributions: PyContributions) -> Quot<Quot<Pressure, Volume>, Volume> { self.0.d2p_dv2(contributions.into()) } /// Return second partial derivative of pressure w.r.t. density. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn d2p_drho2(&self, contributions: PyContributions) -> Quot<Quot<Pressure, Density>, Density> { self.0.d2p_drho2(contributions.into()) } /// Return partial molar volume of each component. /// /// Returns /// ------- /// SIArray1 fn partial_molar_volume(&self) -> MolarVolume<DVector<f64>> { self.0.partial_molar_volume() } /// Return chemical potential of each component. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SIArray1 #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn chemical_potential(&self, contributions: PyContributions) -> MolarEnergy<DVector<f64>> { self.0.chemical_potential(contributions.into()) } /// Return chemical potential contributions. /// /// Parameters /// ---------- /// component: int /// the component for which the contributions /// are calculated /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// List[Tuple[str, SINumber]] #[pyo3(signature = (component, contributions=PyContributions::Total), text_signature = "($self, component, contributions)")] fn chemical_potential_contributions( &self, component: usize, contributions: PyContributions, ) -> Vec<(&'static str, MolarEnergy)> { self.0 .chemical_potential_contributions(component, contributions.into()) } /// Return derivative of chemical potential w.r.t temperature. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SIArray1 #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn dmu_dt( &self, contributions: PyContributions, ) -> Quot<MolarEnergy<DVector<f64>>, Temperature> { self.0.dmu_dt(contributions.into()) } /// Return derivative of chemical potential w.r.t amount of substance. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SIArray2 #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn dmu_dni(&self, contributions: PyContributions) -> Quot<MolarEnergy<DMatrix<f64>>, Moles> { self.0.dmu_dni(contributions.into()) } /// Return logarithmic fugacity coefficient. /// /// Returns /// ------- /// numpy.ndarray fn ln_phi<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1<f64>> { PyArray1::from_slice(py, self.0.ln_phi().as_slice()) } /// Return logarithmic fugacity coefficient of all components treated as /// pure substance at mixture temperature and pressure. /// /// Returns /// ------- /// numpy.ndarray fn ln_phi_pure_liquid<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyArray1<f64>>> { Ok(PyArray1::from_slice( py, self.0 .ln_phi_pure_liquid() .map_err(PyFeosError::from)? .as_slice(), )) } /// Return logarithmic symmetric activity coefficient. /// /// Returns /// ------- /// numpy.ndarray fn ln_symmetric_activity_coefficient<'py>( &self, py: Python<'py>, ) -> PyResult<Bound<'py, PyArray1<f64>>> { Ok(PyArray1::from_slice( py, self.0 .ln_symmetric_activity_coefficient() .map_err(PyFeosError::from)? .as_slice(), )) } /// Return Henry's law constant of every solute (x_i=0) for a given solvent (x_i>0). /// /// Parameters /// ---------- /// eos : Eos /// The equation of state to use. /// temperature : SINumber /// Temperature. /// molefracs : np.ndarray[float] /// Composition of the solvent including x_i=0 for solutes. /// /// Returns /// ------- /// SIArray1 #[staticmethod] fn henrys_law_constant( eos: &PyEquationOfState, temperature: Temperature, molefracs: PyReadonlyArray1<f64>, ) -> PyResult<Vec<Pressure>> { Ok(State::henrys_law_constant( &eos.0, temperature, &parse_molefracs(Some(molefracs)).unwrap(), ) .map_err(PyFeosError::from)?) } /// Return Henry's law constant of a binary system, assuming the first /// component is the solute and the second component is the solvent. /// /// Parameters /// ---------- /// eos : Eos /// The equation of state to use. /// temperature : SINumber /// Temperature. /// /// Returns /// ------- /// SIArray1 #[staticmethod] fn henrys_law_constant_binary( eos: &PyEquationOfState, temperature: Temperature, ) -> PyResult<Pressure> { Ok(State::henrys_law_constant_binary(&eos.0, temperature).map_err(PyFeosError::from)?) } /// Return derivative of logarithmic fugacity coefficient w.r.t. temperature. /// /// Returns /// ------- /// SIArray1 fn dln_phi_dt(&self) -> InvT<DVector<f64>> { self.0.dln_phi_dt() } /// Return derivative of logarithmic fugacity coefficient w.r.t. pressure. /// /// Returns /// ------- /// SIArray1 fn dln_phi_dp(&self) -> InvP<DVector<f64>> { self.0.dln_phi_dp() } /// Return derivative of logarithmic fugacity coefficient w.r.t. amount of substance. /// /// Returns /// ------- /// SIArray2 fn dln_phi_dnj(&self) -> InvM<DMatrix<f64>> { self.0.dln_phi_dnj() } /// Return thermodynamic factor. /// /// Returns /// ------- /// numpy.ndarray fn thermodynamic_factor<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray2<f64>> { self.0.thermodynamic_factor().to_pyarray(py) } /// Return molar isochoric heat capacity. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn molar_isochoric_heat_capacity(&self, contributions: PyContributions) -> MolarEntropy { self.0.molar_isochoric_heat_capacity(contributions.into()) } /// Return derivative of isochoric heat capacity w.r.t. temperature. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn dc_v_dt(&self, contributions: PyContributions) -> Quot<MolarEntropy, Temperature> { self.0.dc_v_dt(contributions.into()) } /// Return molar isobaric heat capacity. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn molar_isobaric_heat_capacity(&self, contributions: PyContributions) -> MolarEntropy { self.0.molar_isobaric_heat_capacity(contributions.into()) } /// Return entropy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn entropy(&self, contributions: PyContributions) -> Entropy { self.0.entropy(contributions.into()) } /// Return derivative of entropy with respect to temperature. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn ds_dt(&self, contributions: PyContributions) -> Quot<Entropy, Temperature> { self.0.ds_dt(contributions.into()) } /// Return molar entropy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn molar_entropy(&self, contributions: PyContributions) -> MolarEntropy { self.0.molar_entropy(contributions.into()) } /// Return partial molar entropy of each component. /// /// Returns /// ------- /// SIArray1 fn partial_molar_entropy(&self) -> MolarEntropy<DVector<f64>> { self.0.partial_molar_entropy() } /// Return enthalpy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn enthalpy(&self, contributions: PyContributions) -> Energy { self.0.enthalpy(contributions.into()) } /// Return molar enthalpy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn molar_enthalpy(&self, contributions: PyContributions) -> MolarEnergy { self.0.molar_enthalpy(contributions.into()) } /// Return partial molar enthalpy of each component. /// /// Returns /// ------- /// SIArray1 fn partial_molar_enthalpy(&self) -> MolarEnergy<DVector<f64>> { self.0.partial_molar_enthalpy() } /// Return Helmholtz energy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn helmholtz_energy(&self, contributions: PyContributions) -> Energy { self.0.helmholtz_energy(contributions.into()) } /// Return molar Helmholtz energy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn molar_helmholtz_energy(&self, contributions: PyContributions) -> MolarEnergy { self.0.molar_helmholtz_energy(contributions.into()) } /// Return residual Helmholtz energy contributions. /// /// Returns /// ------- /// List[Tuple[str, SINumber]] fn residual_molar_helmholtz_energy_contributions(&self) -> Vec<(&'static str, MolarEnergy)> { self.0.residual_molar_helmholtz_energy_contributions() } /// Return Gibbs energy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn gibbs_energy(&self, contributions: PyContributions) -> Energy { self.0.gibbs_energy(contributions.into()) } /// Return molar Gibbs energy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn molar_gibbs_energy(&self, contributions: PyContributions) -> MolarEnergy { self.0.molar_gibbs_energy(contributions.into()) } /// Return internal energy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn internal_energy(&self, contributions: PyContributions) -> Energy { self.0.internal_energy(contributions.into()) } /// Return molar internal energy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn molar_internal_energy(&self, contributions: PyContributions) -> MolarEnergy { self.0.molar_internal_energy(contributions.into()) } /// Return Joule Thomson coefficient. /// /// Returns /// ------- /// SINumber fn joule_thomson(&self) -> Quot<Temperature, Pressure> { self.0.joule_thomson() } /// Return isentropy compressibility coefficient. /// /// Returns /// ------- /// SINumber fn isentropic_compressibility(&self) -> Quot<f64, Pressure> { self.0.isentropic_compressibility() } /// Return isothermal compressibility coefficient. /// /// Returns /// ------- /// SINumber fn isothermal_compressibility(&self) -> Quot<f64, Pressure> { self.0.isothermal_compressibility() } /// Return isenthalpic compressibility coefficient. /// /// Returns /// ------- /// SINumber fn isenthalpic_compressibility(&self) -> Quot<f64, Pressure> { self.0.isenthalpic_compressibility() } /// Return thermal expansivity coefficient. /// /// Returns /// ------- /// SINumber fn thermal_expansivity(&self) -> Quot<f64, Temperature> { self.0.thermal_expansivity() } /// Return Grueneisen parameter. /// /// Returns /// ------- /// float fn grueneisen_parameter(&self) -> f64 { self.0.grueneisen_parameter() } /// Return structure factor. /// /// Returns /// ------- /// float fn structure_factor(&self) -> f64 { self.0.structure_factor() } /// Return total molar weight. /// /// Returns /// ------- /// SINumber fn total_molar_weight(&self) -> MolarWeight { self.0.total_molar_weight() } /// Return speed of sound. /// /// Returns /// ------- /// SINumber fn speed_of_sound(&self) -> Velocity { self.0.speed_of_sound() } /// Returns mass of each component in the system. /// /// Returns /// ------- /// SIArray1 fn mass(&self) -> Mass<DVector<f64>> { self.0.mass() } /// Returns system's total mass. /// /// Returns /// ------- /// SINumber fn total_mass(&self) -> Mass { self.0.total_mass() } /// Returns system's mass density. /// /// Returns /// ------- /// SINumber fn mass_density(&self) -> MassDensity { self.0.mass_density() } /// Returns mass fractions for each component. /// /// Returns /// ------- /// numpy.ndarray[Float64] fn massfracs<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1<f64>> { PyArray1::from_slice(py, self.0.massfracs().as_slice()) } /// Return mass specific Helmholtz energy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn specific_helmholtz_energy(&self, contributions: PyContributions) -> SpecificEnergy { self.0.specific_helmholtz_energy(contributions.into()) } /// Return mass specific entropy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn specific_entropy(&self, contributions: PyContributions) -> SpecificEntropy { self.0.specific_entropy(contributions.into()) } /// Return mass specific internal_energy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn specific_internal_energy(&self, contributions: PyContributions) -> SpecificEnergy { self.0.specific_internal_energy(contributions.into()) } /// Return mass specific gibbs_energy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn specific_gibbs_energy(&self, contributions: PyContributions) -> SpecificEnergy { self.0.specific_gibbs_energy(contributions.into()) } /// Return mass specific enthalpy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn specific_enthalpy(&self, contributions: PyContributions) -> SpecificEnergy { self.0.specific_enthalpy(contributions.into()) } /// Return mass specific isochoric heat capacity. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn specific_isochoric_heat_capacity(&self, contributions: PyContributions) -> SpecificEntropy { self.0 .specific_isochoric_heat_capacity(contributions.into()) } /// Return mass specific isobaric heat capacity. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn specific_isobaric_heat_capacity(&self, contributions: PyContributions) -> SpecificEntropy { self.0.specific_isobaric_heat_capacity(contributions.into()) } /// Return viscosity via entropy scaling. /// /// Returns /// ------- /// SINumber fn viscosity(&self) -> Viscosity { self.0.viscosity() } /// Return reference viscosity for entropy scaling. /// /// Returns /// ------- /// SINumber fn viscosity_reference(&self) -> Viscosity { self.0.viscosity_reference() } /// Return logarithmic reduced viscosity. /// /// This equals the viscosity correlation function /// as used by entropy scaling. /// /// Returns /// ------- /// float fn ln_viscosity_reduced(&self) -> f64 { self.0.ln_viscosity_reduced() } /// Return diffusion coefficient via entropy scaling. /// /// Returns /// ------- /// SINumber fn diffusion(&self) -> Diffusivity { self.0.diffusion() } /// Return reference diffusion for entropy scaling. /// /// Returns /// ------- /// SINumber fn diffusion_reference(&self) -> Diffusivity { self.0.diffusion_reference() } /// Return logarithmic reduced diffusion. /// /// This equals the diffusion correlation function /// as used by entropy scaling. /// /// Returns /// ------- /// float fn ln_diffusion_reduced(&self) -> f64 { self.0.ln_diffusion_reduced() } /// Return thermal conductivity via entropy scaling. /// /// Returns /// ------- /// SINumber fn thermal_conductivity(&self) -> ThermalConductivity { self.0.thermal_conductivity() } /// Return reference thermal conductivity for entropy scaling. /// /// Returns /// ------- /// SINumber fn thermal_conductivity_reference(&self) -> ThermalConductivity { self.0.thermal_conductivity_reference() } /// Return logarithmic reduced thermal conductivity. /// /// This equals the thermal conductivity correlation function /// as used by entropy scaling. /// /// Returns /// ------- /// float fn ln_thermal_conductivity_reduced(&self) -> f64 { self.0.ln_thermal_conductivity_reduced() } #[getter] fn get_total_moles(&self) -> Moles { self.0.total_moles } #[getter] fn get_temperature(&self) -> Temperature { self.0.temperature } #[getter] fn get_volume(&self) -> Volume { self.0.volume } #[getter] fn get_density(&self) -> Density { self.0.density } #[getter] fn get_moles(&self) -> Moles<DVector<f64>> { self.0.moles.clone() } #[getter] fn get_partial_density(&self) -> Density<DVector<f64>> { self.0.partial_density.clone() } #[getter] fn get_molefracs<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1<f64>> { PyArray1::from_slice(py, self.0.molefracs.as_slice()) } fn _repr_markdown_(&self) -> String { if self.0.eos.deref().components() == 1 { format!( "|temperature|density|\n|-|-|\n|{:.5}|{:.5}|", self.0.temperature, self.0.density ) } else { format!( "|temperature|density|molefracs\n|-|-|-|\n|{:.5}|{:.5}|{:.5?}|", self.0.temperature, self.0.density, self.0.molefracs.as_slice() ) } } fn __repr__(&self) -> PyResult<String> { Ok(self.0.to_string()) } } /// A list of states that provides convenient getters /// for properties of all the individual states. /// /// Parameters /// ---------- /// states : [State] /// A list of individual states. /// /// Returns /// ------- /// StateVec #[pyclass(name = "StateVec")] #[expect(clippy::type_complexity)] pub struct PyStateVec(Vec<State<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>>); impl From<StateVec<'_, Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>> for PyStateVec { fn from(vec: StateVec<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>) -> Self { Self(vec.into_iter().cloned().collect()) } } impl<'a> From<&'a PyStateVec> for StateVec<'a, Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>> { fn from(vec: &'a PyStateVec) -> Self { Self(vec.0.iter().collect()) } } #[pymethods] impl PyStateVec { #[new] fn new(states: Vec<PyState>) -> Self { Self(states.into_iter().map(|s| s.0).collect()) } fn __len__(&self) -> PyResult<usize> { Ok(self.0.len()) } fn __getitem__(&self, idx: isize) -> PyResult<PyState> { let i = if idx < 0 { self.0.len() as isize + idx } else { idx }; if (0..self.0.len()).contains(&(i as usize)) { Ok(PyState(self.0[i as usize].clone())) } else { Err(PyIndexError::new_err( "StateVec index out of range".to_string(), )) } } /// Return molar entropy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SIArray1 #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn molar_entropy(&self, contributions: PyContributions) -> MolarEntropy<Array1<f64>> { StateVec::from(self).molar_entropy(contributions.into()) } /// Return mass specific entropy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SIArray1 #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn specific_entropy(&self, contributions: PyContributions) -> SpecificEntropy<Array1<f64>> { StateVec::from(self).specific_entropy(contributions.into()) } /// Return molar enthalpy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SIArray1 #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn molar_enthalpy(&self, contributions: PyContributions) -> MolarEnergy<Array1<f64>> { StateVec::from(self).molar_enthalpy(contributions.into()) } /// Return mass specific enthalpy. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the Helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SIArray1 #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn specific_enthalpy(&self, contributions: PyContributions) -> SpecificEnergy<Array1<f64>> { StateVec::from(self).specific_enthalpy(contributions.into()) } #[getter] fn get_temperature(&self) -> Temperature<Array1<f64>> { StateVec::from(self).temperature() } #[getter] fn get_pressure(&self) -> Pressure<Array1<f64>> { StateVec::from(self).pressure() } #[getter] fn get_compressibility<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1<f64>> { StateVec::from(self).compressibility().into_pyarray(py) } #[getter] fn get_density(&self) -> Density<Array1<f64>> { StateVec::from(self).density() } #[getter] fn get_moles(&self) -> Moles<Array2<f64>> { StateVec::from(self).moles() } #[getter] fn get_molefracs<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray2<f64>> { StateVec::from(self).molefracs().into_pyarray(py) } #[getter] fn get_mass_density(&self) -> Option<MassDensity<Array1<f64>>> { self.0[0] .eos .residual .has_molar_weight() .then(|| StateVec::from(self).mass_density()) } #[getter] fn get_massfracs<'py>(&self, py: Python<'py>) -> Option<Bound<'py, PyArray2<f64>>> { self.0[0] .eos .residual .has_molar_weight() .then(|| StateVec::from(self).massfracs().into_pyarray(py)) } /// Returns selected properties of a StateVec as dictionary. /// /// Parameters /// ---------- /// contributions : Contributions, optional /// The contributions to consider when calculating properties. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// Dict[str, List[float]] /// Keys: property names. Values: property for each state. /// /// Notes /// ----- /// - temperature : K /// - pressure : Pa /// - densities : mol / m³ /// - mass densities : kg / m³ /// - molar enthalpies : kJ / mol /// - molar entropies : kJ / mol / K /// - specific enthalpies : kJ / kg /// - specific entropies : kJ / kg / K /// - xi: molefraction of component i /// - component index `i` matches to order of components in parameters. #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] pub fn to_dict(&self, contributions: PyContributions) -> HashMap<String, Vec<f64>> { let states = StateVec::from(self); let n = states.0[0].eos.deref().components(); let mut dict = HashMap::with_capacity(8 + n); if n != 1 { let xs = states.molefracs(); for i in 0..n { dict.insert(format!("x{i}"), xs.column(i).to_vec()); } } dict.insert( String::from("temperature"), states .temperature() .convert_to(KELVIN) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("pressure"), states .pressure() .convert_to(PASCAL) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("density"), states .density() .convert_to(MOL / METER.powi::<3>()) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("molar enthalpy"), states .molar_enthalpy(contributions.into()) .convert_to(KILO * JOULE / MOL) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("molar entropy"), states .molar_entropy(contributions.into()) .convert_to(KILO * JOULE / KELVIN / MOL) .into_raw_vec_and_offset() .0, ); if states.0[0].eos.residual.has_molar_weight() { dict.insert( String::from("mass density"), states .mass_density() .convert_to(KILOGRAM / METER.powi::<3>()) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("specific enthalpy"), states .specific_enthalpy(contributions.into()) .convert_to(KILO * JOULE / KILOGRAM) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("specific entropy"), states .specific_entropy(contributions.into()) .convert_to(KILO * JOULE / KELVIN / KILOGRAM) .into_raw_vec_and_offset() .0, ); } dict } }
Rust
3D
feos-org/feos
py-feos/src/ideal_gas.rs
.rs
602
22
//! Collection of ideal gas models. use crate::user_defined::PyIdealGas; use feos::ideal_gas::{Dippr, Joback}; use feos_core::IdealGas; use feos_derive::IdealGas; use num_dual::DualNum; use std::sync::Arc; /// Collection of different [IdealGas] implementations. /// /// Particularly relevant for situations in which generic types /// are undesirable (e.g. FFI). #[derive(IdealGas, Clone)] pub enum IdealGasModel { NoModel, Joback(Joback), Dippr(Dippr), #[cfg(feature = "multiparameter")] MultiParameter(feos::multiparameter::MultiParameterIdealGas), Python(Arc<PyIdealGas>), }
Rust
3D
feos-org/feos
py-feos/src/error.rs
.rs
555
24
use feos_core::FeosError; use pyo3::exceptions::PyRuntimeError; use pyo3::prelude::*; use thiserror::Error; #[derive(Debug, Error)] pub enum PyFeosError { #[error("{0}")] Error(String), #[error(transparent)] FeosError(#[from] FeosError), #[error(transparent)] Serde(#[from] serde_json::Error), #[cfg(feature = "rayon")] #[error(transparent)] Rayon(#[from] rayon::ThreadPoolBuildError), } impl From<PyFeosError> for PyErr { fn from(e: PyFeosError) -> PyErr { PyRuntimeError::new_err(e.to_string()) } }
Rust
3D
feos-org/feos
py-feos/src/residual.rs
.rs
3,663
117
use feos_core::cubic::PengRobinson; use feos_core::*; #[cfg(feature = "dft")] use feos_derive::{FunctionalContribution, HelmholtzEnergyFunctionalDyn}; use feos_derive::{ResidualDyn, Subset}; #[cfg(feature = "dft")] use feos_dft::{FunctionalContribution, HelmholtzEnergyFunctionalDyn}; use indexmap::IndexMap; use nalgebra::{DMatrix, DVector}; #[cfg(feature = "dft")] use ndarray::Array1; use num_dual::DualNum; use quantity::*; /// Collection of different [Residual] implementations. /// /// Particularly relevant for situations in which generic types /// are undesirable (e.g. FFI). #[cfg_attr(feature = "dft", derive(HelmholtzEnergyFunctionalDyn))] #[derive(ResidualDyn, Subset)] #[expect(clippy::large_enum_variant)] pub enum ResidualModel { // Equations of state NoResidual(NoResidual), #[cfg(feature = "pcsaft")] #[implement(molar_weight, parameter_info, entropy_scaling)] PcSaft(feos::pcsaft::PcSaft), #[cfg(feature = "epcsaft")] #[implement(molar_weight, parameter_info)] ElectrolytePcSaft(feos::epcsaft::ElectrolytePcSaft), #[cfg(feature = "gc_pcsaft")] #[implement(molar_weight)] GcPcSaft(feos::gc_pcsaft::GcPcSaft), #[implement(molar_weight, parameter_info)] PengRobinson(PengRobinson), #[implement(molar_weight)] Python(crate::user_defined::PyResidual), #[cfg(feature = "saftvrqmie")] #[implement(molar_weight, parameter_info)] SaftVRQMie(feos::saftvrqmie::SaftVRQMie), #[cfg(feature = "saftvrmie")] #[implement(molar_weight, parameter_info)] SaftVRMie(feos::saftvrmie::SaftVRMie), #[cfg(feature = "pets")] #[implement(molar_weight, parameter_info)] Pets(feos::pets::Pets), #[cfg(feature = "uvtheory")] #[implement(molar_weight, parameter_info)] UVTheory(feos::uvtheory::UVTheory), #[cfg(feature = "multiparameter")] #[implement(molar_weight)] MultiParameter(feos::multiparameter::MultiParameter), // Helmholtz energy functionals #[cfg(all(feature = "dft", feature = "pcsaft"))] #[implement( molar_weight, parameter_info, functional, fluid_parameters, pair_potential )] PcSaftFunctional(feos::pcsaft::PcSaftFunctional), #[cfg(all(feature = "dft", feature = "gc_pcsaft"))] #[implement(molar_weight, functional, fluid_parameters, bond_lengths)] GcPcSaftFunctional(feos::gc_pcsaft::GcPcSaftFunctional), #[cfg(all(feature = "dft", feature = "pets"))] #[implement( molar_weight, parameter_info, functional, fluid_parameters, pair_potential )] PetsFunctional(feos::pets::Pets), #[cfg(feature = "dft")] #[implement(functional, fluid_parameters, pair_potential)] FmtFunctional(feos::hard_sphere::FMTFunctional), #[cfg(all(feature = "dft", feature = "saftvrqmie"))] #[implement( molar_weight, parameter_info, functional, fluid_parameters, pair_potential )] SaftVRQMieFunctional(feos::saftvrqmie::SaftVRQMie), } #[cfg(feature = "dft")] #[derive(FunctionalContribution)] pub enum FunctionalContributionVariant<'a> { #[cfg(feature = "pcsaft")] PcSaftFunctional(feos::pcsaft::PcSaftFunctionalContribution<'a>), #[cfg(feature = "gc_pcsaft")] GcPcSaftFunctional(feos::gc_pcsaft::GcPcSaftFunctionalContribution<'a>), #[cfg(feature = "pets")] PetsFunctional(feos::pets::PetsFunctionalContribution<'a>), Fmt(feos::hard_sphere::FMTContribution<'a, feos::hard_sphere::HardSphereParameters>), #[cfg(feature = "saftvrqmie")] SaftVRQMieFunctional(feos::saftvrqmie::SaftVRQMieFunctionalContribution<'a>), }
Rust
3D
feos-org/feos
py-feos/src/user_defined.rs
.rs
11,649
344
#![allow(non_snake_case)] use feos_core::{IdealGas, Molarweight, ResidualDyn, StateHD, Subset}; use nalgebra::DVector; use num_dual::*; use numpy::{PyArray, PyReadonlyArrayDyn, PyReadwriteArrayDyn}; use pyo3::exceptions::PyTypeError; use pyo3::prelude::*; use quantity::MolarWeight; use std::any::Any; pub struct PyIdealGas(Py<PyAny>); impl PyIdealGas { pub fn new(obj: Bound<'_, PyAny>) -> PyResult<Self> { let attr = obj.hasattr("ln_lambda3")?; if !attr { panic!("{}", "Python Class has to have a method 'ln_lambda3' with signature:\n\tdef ln_lambda3(self, temperature: HD) -> HD\nwhere 'HD' has to be any (hyper-) dual number.") } Ok(Self(obj.unbind())) } } macro_rules! impl_ideal_gas { ($($py_hd_id:ident, $hd_ty:ty);*) => { impl IdealGas for PyIdealGas { fn ideal_gas_model(&self) -> &'static str { "Ideal gas (Python)" } fn ln_lambda3<D: DualNum<f64> + Copy>(&self, temperature: D) -> D { let mut result = D::zero(); $( if let Some(&t) = (&temperature as &dyn Any).downcast_ref::<$hd_ty>() { let l3_any = (&mut result as &mut dyn Any).downcast_mut::<$hd_ty>().unwrap(); *l3_any = Python::attach(|py| { let py_result = self .0 .bind(py) .call_method1("ln_lambda3", (<$py_hd_id>::from(t),)) .unwrap(); <$hd_ty>::from(py_result.extract::<$py_hd_id>().unwrap()) }); return result } )* panic!("ln_lambda3: input data type not understood") } } }; } /// Struct containing pointer to Python Class that implements Helmholtz energy. pub struct PyResidual(Py<PyAny>); impl PyResidual { pub fn new(obj: Bound<'_, PyAny>) -> PyResult<Self> { let attr = obj.hasattr("components")?; if !attr { panic!("Python Class has to have a method 'components' with signature:\n\tdef signature(self) -> int") } let attr = obj.hasattr("subset")?; if !attr { panic!("Python Class has to have a method 'subset' with signature:\n\tdef subset(self, component_list: List[int]) -> Self") } let attr = obj.hasattr("molar_weight")?; if !attr { panic!("Python Class has to have a method 'molar_weight' with signature:\n\tdef molar_weight(self) -> SIArray1\nwhere the size of the returned array has to be 'components'.") } let attr = obj.hasattr("max_density")?; if !attr { panic!("Python Class has to have a method 'max_density' with signature:\n\tdef max_density(self, moles: numpy.ndarray[float]) -> float\nwhere the size of the input array has to be 'components'.") } let attr = obj.hasattr("helmholtz_energy")?; if !attr { panic!("{}", "Python Class has to have a method 'helmholtz_energy' with signature:\n\tdef helmholtz_energy(self, state: StateHD) -> HD\nwhere 'HD' has to be any of {{float, Dual64, HyperDual64, HyperDualDual64, Dual3Dual64, Dual3_64}}.") } Ok(Self(obj.unbind())) } } macro_rules! impl_residual { ($($py_state_id:ident, $py_hd_id:ident, $hd_ty:ty);*) => { impl ResidualDyn for PyResidual { fn components(&self) -> usize { Python::attach(|py| { let py_result = self.0.bind(py).call_method0("components").unwrap(); py_result.extract().unwrap() }) } fn compute_max_density<D: DualNum<f64> + Copy>(&self, molefracs: &DVector<D>) -> D { let mut rho = D::zero(); $( if let Some(x) = (molefracs as &dyn Any).downcast_ref::<DVector<$hd_ty>>() { let r = (&mut rho as &mut dyn Any).downcast_mut::<$hd_ty>().unwrap(); *r = Python::attach(|py| { let py_result = self .0 .bind(py) .call_method1("max_density", (x.iter().copied().map(<$py_hd_id>::from).collect::<Vec<_>>(),)) .unwrap(); <$hd_ty>::from(py_result.extract::<$py_hd_id>().unwrap()) }); return rho } )* panic!("compute_max_density: input data type not understood") } fn reduced_helmholtz_energy_density_contributions<D: DualNum<f64> + Copy + >( &self, state: &StateHD<D>, ) -> Vec<(&'static str, D)> { // result to write to let mut a = D::zero(); $( if let Some(s) = (state as &dyn Any).downcast_ref::<StateHD<$hd_ty>>() { let d = (&mut a as &mut dyn Any).downcast_mut::<$hd_ty>().unwrap(); *d = Python::attach(|py| { let py_result = self .0 .bind(py) .call_method1("helmholtz_energy", (<$py_state_id>::from(s.clone()),)) .unwrap(); <$hd_ty>::from(py_result.extract::<$py_hd_id>().unwrap()) }); return vec![("Python", a)] } )* panic!("helmholtz_energy: input data type not understood") } } impl Molarweight for PyResidual { fn molar_weight(&self) -> MolarWeight<DVector<f64>> { Python::attach(|py| { let py_result = self.0.bind(py).call_method0("molar_weight").unwrap(); py_result .extract::<MolarWeight<DVector<f64>>>() .unwrap() }) } } impl Subset for PyResidual { fn subset(&self, component_list: &[usize]) -> Self { Python::attach(|py| { let py_result = self .0 .bind(py) .call_method1("subset", (component_list.to_vec(),)) .unwrap(); Self::new(py_result.extract().unwrap()).unwrap() }) } } } } macro_rules! state { ($py_state_id:ident, $py_hd_id:ident, $hd_ty:ty) => { #[pyclass] #[derive(Clone)] struct $py_state_id(StateHD<$hd_ty>); impl From<StateHD<$hd_ty>> for $py_state_id { fn from(s: StateHD<$hd_ty>) -> Self { Self(s) } } #[pymethods] impl $py_state_id { #[new] pub fn new(temperature: $py_hd_id, volume: $py_hd_id, moles: Vec<$py_hd_id>) -> Self { let moles = moles.into_iter().map(<$hd_ty>::from).collect(); Self(StateHD::<$hd_ty>::new( temperature.into(), volume.into(), &DVector::from_vec(moles), )) } #[getter] pub fn get_temperature(&self) -> $py_hd_id { <$py_hd_id>::from(self.0.temperature) } #[getter] pub fn get_partial_density(&self) -> Vec<$py_hd_id> { self.0 .partial_density .iter() .copied() .map(<$py_hd_id>::from) .collect() } #[getter] pub fn get_molefracs(&self) -> Vec<$py_hd_id> { self.0 .molefracs .iter() .copied() .map(<$py_hd_id>::from) .collect() } #[getter] pub fn get_density(&self) -> $py_hd_id { <$py_hd_id>::from(self.0.partial_density.sum()) } } }; } macro_rules! dual_number { ($py_hd_id:ident, $hd_ty:ty, $py_field_ty:ty) => { #[pyclass] #[derive(Clone)] struct $py_hd_id($hd_ty); impl_dual_num!($py_hd_id, $hd_ty, $py_field_ty); }; } macro_rules! impl_dual_state_helmholtz_energy { ($py_state_id:ident, $py_hd_id:ident, $hd_ty:ty, $py_field_ty:ty) => { dual_number!($py_hd_id, $hd_ty, $py_field_ty); state!($py_state_id, $py_hd_id, $hd_ty); }; } // No definition of dual number necessary for f64 state!(PyStateF, f64, f64); dual_number!(PyReal64, Real<f64, f64>, f64); impl_dual_state_helmholtz_energy!(PyStateD, PyDual64, Dual64, f64); dual_number!(PyDualVec3, DualSVec64<3>, f64); impl_dual_state_helmholtz_energy!( PyStateDualDualVec3, PyDualDualVec3, Dual<DualSVec64<3>, f64>, PyDualVec3 ); impl_dual_state_helmholtz_energy!(PyStateHD, PyHyperDual64, HyperDual64, f64); impl_dual_state_helmholtz_energy!(PyStateD2, PyDual2_64, Dual2_64, f64); impl_dual_state_helmholtz_energy!(PyStateD3, PyDual3_64, Dual3_64, f64); impl_dual_state_helmholtz_energy!(PyStateHDD, PyHyperDualDual64, HyperDual<Dual64, f64>, PyDual64); dual_number!(PyDualVec2, DualSVec64<2>, f64); impl_dual_state_helmholtz_energy!( PyStateHDDVec2, PyHyperDualVec2, HyperDual<DualSVec64<2>, f64>, PyDualVec2 ); impl_dual_state_helmholtz_energy!( PyStateHDDVec3, PyHyperDualVec3, HyperDual<DualSVec64<3>, f64>, PyDualVec3 ); impl_dual_state_helmholtz_energy!( PyStateD2D, PyDual2Dual64, Dual2<Dual64, f64>, PyDual64 ); impl_dual_state_helmholtz_energy!( PyStateD3D, PyDual3Dual64, Dual3<Dual64, f64>, PyDual64 ); impl_dual_state_helmholtz_energy!( PyStateD3DVec2, PyDual3DualVec2, Dual3<DualSVec64<2>, f64>, PyDualVec2 ); impl_dual_state_helmholtz_energy!( PyStateD3DVec3, PyDual3DualVec3, Dual3<DualSVec64<3>, f64>, PyDualVec3 ); impl_ideal_gas!( PyReal64, Real<f64, f64>; PyDual64, Dual64; PyDualDualVec3, Dual<DualSVec64<3>, f64>; PyHyperDual64, HyperDual64; PyDual2_64, Dual2_64; PyDual3_64, Dual3_64; PyHyperDualDual64, HyperDual<Dual64, f64>; PyHyperDualVec2, HyperDual<DualSVec64<2>, f64>; PyHyperDualVec3, HyperDual<DualSVec64<3>, f64>; PyDual2Dual64, Dual2<Dual64, f64>; PyDual3Dual64, Dual3<Dual64, f64>; PyDual3DualVec2, Dual3<DualSVec64<2>, f64>; PyDual3DualVec3, Dual3<DualSVec64<3>, f64> ); impl_residual!( PyStateF, f64, f64; PyStateD, PyDual64, Dual64; PyStateDualDualVec3, PyDualDualVec3, Dual<DualSVec64<3>, f64>; PyStateHD, PyHyperDual64, HyperDual64; PyStateD2, PyDual2_64, Dual2_64; PyStateD3, PyDual3_64, Dual3_64; PyStateHDD, PyHyperDualDual64, HyperDual<Dual64, f64>; PyStateHDDVec2, PyHyperDualVec2, HyperDual<DualSVec64<2>, f64>; PyStateHDDVec3, PyHyperDualVec3, HyperDual<DualSVec64<3>, f64>; PyStateD2D, PyDual2Dual64, Dual2<Dual64, f64>; PyStateD3D, PyDual3Dual64, Dual3<Dual64, f64>; PyStateD3DVec2, PyDual3DualVec2, Dual3<DualSVec64<2>, f64>; PyStateD3DVec3, PyDual3DualVec3, Dual3<DualSVec64<3>, f64> );
Rust
3D
feos-org/feos
py-feos/src/phase_equilibria.rs
.rs
53,628
1,468
use crate::{ PyVerbosity, eos::{PyEquationOfState, parse_molefracs}, error::PyFeosError, ideal_gas::IdealGasModel, residual::ResidualModel, state::{PyContributions, PyState, PyStateVec}, }; use feos_core::{ Contributions, EquationOfState, PhaseDiagram, PhaseDiagramHetero, PhaseEquilibrium, ResidualDyn, }; use indexmap::IndexMap; use nalgebra::DVector; use numpy::PyReadonlyArray1; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use quantity::*; use std::ops::Deref; use std::sync::Arc; /// A thermodynamic two phase equilibrium state. #[pyclass(name = "PhaseEquilibrium")] #[derive(Clone)] pub struct PyPhaseEquilibrium( pub PhaseEquilibrium<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>, 2>, ); #[pymethods] impl PyPhaseEquilibrium { /// Create a liquid and vapor state in equilibrium /// for a pure substance. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state. /// temperature_or_pressure : SINumber /// The system temperature or pressure. /// initial_state : PhaseEquilibrium, optional /// A phase equilibrium used as initial guess. /// Can speed up convergence. /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// PhaseEquilibrium /// /// Raises /// ------ /// RuntimeError /// When pressure iteration fails or no phase equilibrium is found. #[staticmethod] #[pyo3( text_signature = "(eos, temperature_or_pressure, initial_state=None, max_iter=None, tol=None, verbosity=None)" )] #[pyo3(signature = (eos, temperature_or_pressure, initial_state=None, max_iter=None, tol=None, verbosity=None))] pub(crate) fn pure( eos: &PyEquationOfState, temperature_or_pressure: Bound<'_, PyAny>, initial_state: Option<&PyPhaseEquilibrium>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Self> { if let Ok(t) = temperature_or_pressure.extract::<Temperature>() { Ok(Self( PhaseEquilibrium::pure( &eos.0, t, initial_state.map(|s| &s.0), (max_iter, tol, verbosity.map(|v| v.into())).into(), ) .map_err(PyFeosError::from)?, )) } else if let Ok(p) = temperature_or_pressure.extract::<Pressure>() { Ok(Self( PhaseEquilibrium::pure( &eos.0, p, initial_state.map(|s| &s.0), (max_iter, tol, verbosity.map(|v| v.into())).into(), ) .map_err(PyFeosError::from)?, )) } else { Err(PyErr::new::<PyValueError, _>(format!( "Wrong units! Expected K or Pa, got {}.", temperature_or_pressure.call_method0("__repr__")? ))) } } /// Create a liquid and vapor state in equilibrium /// for given temperature, pressure and feed composition. /// /// Can also be used to calculate liquid liquid phase separation. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state. /// temperature : SINumber /// The system temperature. /// pressure : SINumber /// The system pressure. /// feed : SIArray1 /// Feed composition (units of amount of substance). /// initial_state : PhaseEquilibrium, optional /// A phase equilibrium used as initial guess. /// Can speed up convergence. /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// PhaseEquilibrium /// /// Raises /// ------ /// RuntimeError /// When pressure iteration fails or no phase equilibrium is found. #[staticmethod] #[pyo3( text_signature = "(eos, temperature, pressure, feed, initial_state=None, max_iter=None, tol=None, verbosity=None, non_volatile_components=None)" )] #[pyo3(signature = (eos, temperature, pressure, feed, initial_state=None, max_iter=None, tol=None, verbosity=None, non_volatile_components=None))] #[expect(clippy::too_many_arguments)] pub(crate) fn tp_flash( eos: &PyEquationOfState, temperature: Temperature, pressure: Pressure, feed: Moles<DVector<f64>>, initial_state: Option<&PyPhaseEquilibrium>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, non_volatile_components: Option<Vec<usize>>, ) -> PyResult<Self> { Ok(Self( PhaseEquilibrium::tp_flash( &eos.0, temperature, pressure, &feed, initial_state.map(|s| &s.0), (max_iter, tol, verbosity.map(|v| v.into())).into(), non_volatile_components, ) .map_err(PyFeosError::from)?, )) } /// Compute a phase equilibrium for given temperature /// or pressure and liquid mole fractions. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state. /// temperature_or_pressure : SINumber /// The system temperature_or_pressure. /// liquid_molefracs : numpy.ndarray /// The mole fraction of the liquid phase. /// tp_init : SINumber, optional /// The system pressure/temperature used as starting /// condition for the iteration. /// vapor_molefracs : numpy.ndarray, optional /// The mole fraction of the vapor phase used as /// starting condition for iteration. /// max_iter_inner : int, optional /// The maximum number of inner iterations. /// max_iter_outer : int, optional /// The maximum number of outer iterations. /// tol_inner : float, optional /// The solution tolerance in the inner loop. /// tol_outer : float, optional /// The solution tolerance in the outer loop. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// PhaseEquilibrium #[staticmethod] #[pyo3( text_signature = "(eos, temperature_or_pressure, liquid_molefracs, tp_init=None, vapor_molefracs=None, max_iter_inner=None, max_iter_outer=None, tol_inner=None, tol_outer=None, verbosity=None)" )] #[pyo3(signature = (eos, temperature_or_pressure, liquid_molefracs, tp_init=None, vapor_molefracs=None, max_iter_inner=None, max_iter_outer=None, tol_inner=None, tol_outer=None, verbosity=None))] #[expect(clippy::too_many_arguments)] pub(crate) fn bubble_point<'py>( eos: &PyEquationOfState, temperature_or_pressure: Bound<'_, PyAny>, liquid_molefracs: PyReadonlyArray1<'py, f64>, tp_init: Option<Bound<'_, PyAny>>, vapor_molefracs: Option<PyReadonlyArray1<'py, f64>>, max_iter_inner: Option<usize>, max_iter_outer: Option<usize>, tol_inner: Option<f64>, tol_outer: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Self> { let x = parse_molefracs(vapor_molefracs); if let Ok(t) = temperature_or_pressure.extract::<Temperature>() { Ok(Self( PhaseEquilibrium::bubble_point( &eos.0, t, &parse_molefracs(Some(liquid_molefracs)).unwrap(), tp_init.map(|p| p.extract()).transpose()?, x.as_ref(), ( (max_iter_inner, tol_inner, verbosity.map(|v| v.into())).into(), (max_iter_outer, tol_outer, verbosity.map(|v| v.into())).into(), ), ) .map_err(PyFeosError::from)?, )) } else if let Ok(p) = temperature_or_pressure.extract::<Pressure>() { Ok(Self( PhaseEquilibrium::bubble_point( &eos.0, p, &parse_molefracs(Some(liquid_molefracs)).unwrap(), tp_init.map(|p| p.extract()).transpose()?, x.as_ref(), ( (max_iter_inner, tol_inner, verbosity.map(|v| v.into())).into(), (max_iter_outer, tol_outer, verbosity.map(|v| v.into())).into(), ), ) .map_err(PyFeosError::from)?, )) } else { Err(PyErr::new::<PyValueError, _>(format!( "Wrong units! Expected K or Pa, got {}.", temperature_or_pressure.call_method0("__repr__")? ))) } } /// Compute a phase equilibrium for given temperature /// or pressure and vapor mole fractions. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state. /// temperature_or_pressure : SINumber /// The system temperature or pressure. /// vapor_molefracs : numpy.ndarray /// The mole fraction of the vapor phase. /// tp_init : SINumber, optional /// The system pressure/temperature used as starting /// condition for the iteration. /// liquid_molefracs : numpy.ndarray, optional /// The mole fraction of the liquid phase used as /// starting condition for iteration. /// max_iter_inner : int, optional /// The maximum number of inner iterations. /// max_iter_outer : int, optional /// The maximum number of outer iterations. /// tol_inner : float, optional /// The solution tolerance in the inner loop. /// tol_outer : float, optional /// The solution tolerance in the outer loop. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// PhaseEquilibrium #[staticmethod] #[pyo3( text_signature = "(eos, temperature_or_pressure, vapor_molefracs, tp_init=None, liquid_molefracs=None, max_iter_inner=None, max_iter_outer=None, tol_inner=None, tol_outer=None, verbosity=None)" )] #[pyo3(signature = (eos, temperature_or_pressure, vapor_molefracs, tp_init=None, liquid_molefracs=None, max_iter_inner=None, max_iter_outer=None, tol_inner=None, tol_outer=None, verbosity=None))] #[expect(clippy::too_many_arguments)] pub(crate) fn dew_point<'py>( eos: &PyEquationOfState, temperature_or_pressure: Bound<'_, PyAny>, vapor_molefracs: PyReadonlyArray1<'py, f64>, tp_init: Option<Bound<'_, PyAny>>, liquid_molefracs: Option<PyReadonlyArray1<'py, f64>>, max_iter_inner: Option<usize>, max_iter_outer: Option<usize>, tol_inner: Option<f64>, tol_outer: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Self> { let x = parse_molefracs(liquid_molefracs); if let Ok(t) = temperature_or_pressure.extract::<Temperature>() { Ok(Self( PhaseEquilibrium::dew_point( &eos.0, t, &parse_molefracs(Some(vapor_molefracs)).unwrap(), tp_init.map(|p| p.extract()).transpose()?, x.as_ref(), ( (max_iter_inner, tol_inner, verbosity.map(|v| v.into())).into(), (max_iter_outer, tol_outer, verbosity.map(|v| v.into())).into(), ), ) .map_err(PyFeosError::from)?, )) } else if let Ok(p) = temperature_or_pressure.extract::<Pressure>() { Ok(Self( PhaseEquilibrium::dew_point( &eos.0, p, &parse_molefracs(Some(vapor_molefracs)).unwrap(), tp_init.map(|p| p.extract()).transpose()?, x.as_ref(), ( (max_iter_inner, tol_inner, verbosity.map(|v| v.into())).into(), (max_iter_outer, tol_outer, verbosity.map(|v| v.into())).into(), ), ) .map_err(PyFeosError::from)?, )) } else { Err(PyErr::new::<PyValueError, _>(format!( "Wrong units! Expected K or Pa, got {}.", temperature_or_pressure.call_method0("__repr__")? ))) } } // /// Creates a new PhaseEquilibrium that contains two states at the // /// specified temperature, pressure and moles. // /// // /// The constructor can be used in custom phase equilibrium solvers or, // /// e.g., to generate initial guesses for an actual VLE solver. // /// In general, the two states generated are NOT in an equilibrium. // /// // /// Parameters // /// ---------- // /// eos : EquationOfState // /// The equation of state. // /// temperature : SINumber // /// The system temperature. // /// pressure : SINumber // /// The system pressure. // /// vapor_moles : SIArray1 // /// Amount of substance of the vapor phase. // /// liquid_moles : SIArray1 // /// Amount of substance of the liquid phase. // /// // /// Returns // /// ------- // /// PhaseEquilibrium // #[staticmethod] // pub(crate) fn new_npt( // eos: &PyEquationOfState, // temperature: Temperature, // pressure: Pressure, // vapor_moles: Moles<DVector<f64>>, // liquid_moles: Moles<DVector<f64>>, // ) -> PyResult<Self> { // Ok(Self( // PhaseEquilibrium::new_xpt(&eos.0, temperature, pressure, &vapor_moles, &liquid_moles) // .map_err(PyFeosError::from)?, // )) // } #[getter] fn get_vapor(&self) -> PyState { PyState(self.0.vapor().clone()) } #[getter] fn get_liquid(&self) -> PyState { PyState(self.0.liquid().clone()) } /// Calculate the pure component vapor-liquid equilibria for all /// components in the system. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state. /// temperature_or_pressure : SINumber /// The system temperature or pressure. /// /// Returns /// ------- /// list[PhaseEquilibrium] #[staticmethod] fn vle_pure_comps( eos: &PyEquationOfState, temperature_or_pressure: Bound<'_, PyAny>, ) -> PyResult<Vec<Option<Self>>> { if let Ok(t) = temperature_or_pressure.extract::<Temperature>() { Ok(PhaseEquilibrium::vle_pure_comps(&eos.0, t) .into_iter() .map(|o| o.map(Self)) .collect()) } else if let Ok(p) = temperature_or_pressure.extract::<Pressure>() { Ok(PhaseEquilibrium::vle_pure_comps(&eos.0, p) .into_iter() .map(|o| o.map(Self)) .collect()) } else { Err(PyErr::new::<PyValueError, _>(format!( "Wrong units! Expected K or Pa, got {}.", temperature_or_pressure.call_method0("__repr__")? ))) } } /// Calculate the pure component vapor pressures for all the /// components in the system. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state. /// temperature : SINumber /// The system temperature. /// /// Returns /// ------- /// list[SINumber] #[staticmethod] fn vapor_pressure(eos: &PyEquationOfState, temperature: Temperature) -> Vec<Option<Pressure>> { PhaseEquilibrium::vapor_pressure(&eos.0, temperature) } /// Calculate the pure component boiling temperatures for all the /// components in the system. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state. /// pressure : SINumber /// The system pressure. /// /// Returns /// ------- /// list[SINumber] #[staticmethod] fn boiling_temperature( eos: &PyEquationOfState, pressure: Pressure, ) -> Vec<Option<Temperature>> { PhaseEquilibrium::boiling_temperature(&eos.0, pressure) } fn _repr_markdown_(&self) -> String { self.0._repr_markdown_() } fn __repr__(&self) -> PyResult<String> { Ok(self.0.to_string()) } } /// A thermodynamic three phase equilibrium state. #[pyclass(name = "ThreePhaseEquilibrium")] #[derive(Clone)] struct PyThreePhaseEquilibrium( PhaseEquilibrium<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>, 3>, ); #[pymethods] impl PyPhaseEquilibrium { /// Calculate a heteroazeotrope in a binary mixture for a given temperature /// or pressure. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state. /// temperature_or_pressure : SINumber /// The system temperature or pressure. /// x_init : list[float] /// Initial guesses for the liquid molefracs of component 1 /// at the heteroazeotropic point. /// tp_init : SINumber, optional /// Initial guess for the temperature/pressure at the /// heteroszeotropic point. /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// max_iter_bd_inner : int, optional /// The maximum number of inner iterations in the bubble/dew point iteration. /// max_iter_bd_outer : int, optional /// The maximum number of outer iterations in the bubble/dew point iteration. /// tol_bd_inner : float, optional /// The solution tolerance in the inner loop of the bubble/dew point iteration. /// tol_bd_outer : float, optional /// The solution tolerance in the outer loop of the bubble/dew point iteration. /// verbosity_bd : Verbosity, optional /// The verbosity of the bubble/dew point iteration. #[staticmethod] #[pyo3( text_signature = "(eos, temperature_or_pressure, x_init, tp_init=None, max_iter=None, tol=None, verbosity=None, max_iter_bd_inner=None, max_iter_bd_outer=None, tol_bd_inner=None, tol_bd_outer=None, verbosity_bd=None)" )] #[pyo3(signature = (eos, temperature_or_pressure, x_init, tp_init=None, max_iter=None, tol=None, verbosity=None, max_iter_bd_inner=None, max_iter_bd_outer=None, tol_bd_inner=None, tol_bd_outer=None, verbosity_bd=None))] #[expect(clippy::too_many_arguments)] fn heteroazeotrope( eos: &PyEquationOfState, temperature_or_pressure: Bound<'_, PyAny>, x_init: (f64, f64), tp_init: Option<Bound<'_, PyAny>>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, max_iter_bd_inner: Option<usize>, max_iter_bd_outer: Option<usize>, tol_bd_inner: Option<f64>, tol_bd_outer: Option<f64>, verbosity_bd: Option<PyVerbosity>, ) -> PyResult<PyThreePhaseEquilibrium> { if let Ok(t) = temperature_or_pressure.extract::<Temperature>() { Ok(PyThreePhaseEquilibrium( PhaseEquilibrium::heteroazeotrope( &eos.0, t, x_init, tp_init.map(|t| t.extract()).transpose()?, (max_iter, tol, verbosity.map(|v| v.into())).into(), ( ( max_iter_bd_inner, tol_bd_inner, verbosity_bd.map(|v| v.into()), ) .into(), ( max_iter_bd_outer, tol_bd_outer, verbosity_bd.map(|v| v.into()), ) .into(), ), ) .map_err(PyFeosError::from)?, )) } else if let Ok(p) = temperature_or_pressure.extract::<Pressure>() { Ok(PyThreePhaseEquilibrium( PhaseEquilibrium::heteroazeotrope( &eos.0, p, x_init, tp_init.map(|t| t.extract()).transpose()?, (max_iter, tol, verbosity.map(|v| v.into())).into(), ( ( max_iter_bd_inner, tol_bd_inner, verbosity_bd.map(|v| v.into()), ) .into(), ( max_iter_bd_outer, tol_bd_outer, verbosity_bd.map(|v| v.into()), ) .into(), ), ) .map_err(PyFeosError::from)?, )) } else { Err(PyErr::new::<PyValueError, _>(format!( "Wrong units! Expected K or Pa, got {}.", temperature_or_pressure.call_method0("__repr__")? ))) } } } #[pymethods] impl PyThreePhaseEquilibrium { #[getter] fn get_vapor(&self) -> PyState { PyState(self.0.vapor().clone()) } #[getter] fn get_liquid1(&self) -> PyState { PyState(self.0.liquid1().clone()) } #[getter] fn get_liquid2(&self) -> PyState { PyState(self.0.liquid2().clone()) } fn _repr_markdown_(&self) -> String { self.0._repr_markdown_() } fn __repr__(&self) -> PyResult<String> { Ok(self.0.to_string()) } } #[pymethods] impl PyState { /// Calculates a two phase Tp-flash with the state as feed. /// /// Parameters /// ---------- /// initial_state : PhaseEquilibrium, optional /// A phase equilibrium used as initial guess. /// Can speed up convergence. /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// PhaseEquilibrium /// /// Raises /// ------ /// RuntimeError /// When pressure iteration fails or no phase equilibrium is found. #[pyo3( text_signature = "($self, initial_state=None, max_iter=None, tol=None, verbosity=None, non_volatile_components=None)" )] #[pyo3(signature = (initial_state=None, max_iter=None, tol=None, verbosity=None, non_volatile_components=None))] pub(crate) fn tp_flash( &self, initial_state: Option<&PyPhaseEquilibrium>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, non_volatile_components: Option<Vec<usize>>, ) -> PyResult<PyPhaseEquilibrium> { Ok(PyPhaseEquilibrium( self.0 .tp_flash( initial_state.map(|s| &s.0), (max_iter, tol, verbosity.map(|v| v.into())).into(), non_volatile_components, ) .map_err(PyFeosError::from)?, )) } } /// Phase diagram for a pure component or a binary mixture. /// /// Parameters /// ---------- /// phase_equilibria : [PhaseEquilibrium] /// A list of individual phase equilibria. /// /// Returns /// ------- /// PhaseDiagram : the resulting phase diagram #[pyclass(name = "PhaseDiagram")] pub struct PyPhaseDiagram(PhaseDiagram<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>, 2>); #[pymethods] impl PyPhaseDiagram { #[new] fn new(phase_equilibria: Vec<PyPhaseEquilibrium>) -> Self { Self(PhaseDiagram::new( phase_equilibria.into_iter().map(|p| p.0).collect(), )) } /// Calculate a pure component phase diagram. /// /// Parameters /// ---------- /// eos: Eos /// The equation of state. /// min_temperature: SINumber /// The lower limit for the temperature. /// npoints: int /// The number of points. /// critical_temperature: SINumber, optional /// An estimate for the critical temperature to initialize /// the calculation if necessary. For most components not necessary. /// Defaults to `None`. /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// PhaseDiagram #[staticmethod] #[pyo3( text_signature = "(eos, min_temperature, npoints, critical_temperature=None, max_iter=None, tol=None, verbosity=None)" )] #[pyo3(signature = (eos, min_temperature, npoints, critical_temperature=None, max_iter=None, tol=None, verbosity=None))] pub(crate) fn pure( eos: &PyEquationOfState, min_temperature: Temperature, npoints: usize, critical_temperature: Option<Temperature>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Self> { let dia = PhaseDiagram::pure( &eos.0, min_temperature, npoints, critical_temperature, (max_iter, tol, verbosity.map(|v| v.into())).into(), ) .map_err(PyFeosError::from)?; Ok(Self(dia)) } /// Calculate a pure component phase diagram in parallel. /// /// Parameters /// ---------- /// eos : Eos /// The equation of state. /// min_temperature: SINumber /// The lower limit for the temperature. /// npoints : int /// The number of points. /// chunksize : int /// The number of points that are calculated in sequence /// within a thread. /// nthreads : int /// Number of threads. /// critical_temperature: SINumber, optional /// An estimate for the critical temperature to initialize /// the calculation if necessary. For most components not necessary. /// Defaults to `None`. /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// PhaseDiagram #[cfg(feature = "rayon")] #[staticmethod] #[pyo3( text_signature = "(eos, min_temperature, npoints, chunksize, nthreads, critical_temperature=None, max_iter=None, tol=None, verbosity=None)" )] #[pyo3(signature = (eos, min_temperature, npoints, chunksize, nthreads, critical_temperature=None, max_iter=None, tol=None, verbosity=None))] #[expect(clippy::too_many_arguments)] pub(crate) fn par_pure( eos: &PyEquationOfState, min_temperature: Temperature, npoints: usize, chunksize: usize, nthreads: usize, critical_temperature: Option<Temperature>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Self> { let thread_pool = rayon::ThreadPoolBuilder::new() .num_threads(nthreads) .build() .map_err(PyFeosError::from)?; let dia = PhaseDiagram::par_pure( &eos.0, min_temperature, npoints, chunksize, thread_pool, critical_temperature, (max_iter, tol, verbosity.map(|v| v.into())).into(), ) .map_err(PyFeosError::from)?; Ok(Self(dia)) } /// Calculate the bubble point line of a mixture with given composition. /// /// In the resulting phase diagram, the liquid states correspond to the /// bubble point line while the vapor states contain the corresponding /// equilibrium states at different compositions. /// /// Parameters /// ---------- /// eos: Eos /// The equation of state. /// molefracs: np.ndarray[float] /// The composition of the liquid phase. /// min_temperature: SINumber /// The lower limit for the temperature. /// npoints: int /// The number of points. /// critical_temperature: SINumber, optional /// An estimate for the critical temperature to initialize /// the calculation if necessary. For most components not necessary. /// Defaults to `None`. /// max_iter_inner : int, optional /// The maximum number of inner iterations in the bubble/dew point iteration. /// max_iter_outer : int, optional /// The maximum number of outer iterations in the bubble/dew point iteration. /// tol_inner : float, optional /// The solution tolerance in the inner loop of the bubble/dew point iteration. /// tol_outer : float, optional /// The solution tolerance in the outer loop of the bubble/dew point iteration. /// verbosity : Verbosity, optional /// The verbosity of the bubble/dew point iteration. /// /// Returns /// ------- /// PhaseDiagram #[staticmethod] #[pyo3( text_signature = "(eos, molefracs, min_temperature, npoints, critical_temperature=None, max_iter_inner=None, max_iter_outer=None, tol_inner=None, tol_outer=None, verbosity=None)" )] #[pyo3(signature = (eos, molefracs, min_temperature, npoints, critical_temperature=None, max_iter_inner=None, max_iter_outer=None, tol_inner=None, tol_outer=None, verbosity=None))] #[expect(clippy::too_many_arguments)] pub(crate) fn bubble_point_line<'py>( eos: &PyEquationOfState, molefracs: PyReadonlyArray1<'py, f64>, min_temperature: Temperature, npoints: usize, critical_temperature: Option<Temperature>, max_iter_inner: Option<usize>, max_iter_outer: Option<usize>, tol_inner: Option<f64>, tol_outer: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Self> { let dia = PhaseDiagram::bubble_point_line( &eos.0, &parse_molefracs(Some(molefracs)).unwrap(), min_temperature, npoints, critical_temperature, ( (max_iter_inner, tol_inner, verbosity.map(|v| v.into())).into(), (max_iter_outer, tol_outer, verbosity.map(|v| v.into())).into(), ), ) .map_err(PyFeosError::from)?; Ok(Self(dia)) } /// Calculate the dew point line of a mixture with given composition. /// /// In the resulting phase diagram, the vapor states correspond to the /// dew point line while the liquid states contain the corresponding /// equilibrium states at different compositions. /// /// Parameters /// ---------- /// eos: Eos /// The equation of state. /// molefracs: np.ndarray[float] /// The composition of the vapor phase. /// min_temperature: SINumber /// The lower limit for the temperature. /// npoints: int /// The number of points. /// critical_temperature: SINumber, optional /// An estimate for the critical temperature to initialize /// the calculation if necessary. For most components not necessary. /// Defaults to `None`. /// max_iter_inner : int, optional /// The maximum number of inner iterations in the bubble/dew point iteration. /// max_iter_outer : int, optional /// The maximum number of outer iterations in the bubble/dew point iteration. /// tol_inner : float, optional /// The solution tolerance in the inner loop of the bubble/dew point iteration. /// tol_outer : float, optional /// The solution tolerance in the outer loop of the bubble/dew point iteration. /// verbosity : Verbosity, optional /// The verbosity of the bubble/dew point iteration. /// /// Returns /// ------- /// PhaseDiagram #[staticmethod] #[pyo3( text_signature = "(eos, molefracs, min_temperature, npoints, critical_temperature=None, max_iter_inner=None, max_iter_outer=None, tol_inner=None, tol_outer=None, verbosity=None)" )] #[pyo3(signature = (eos, molefracs, min_temperature, npoints, critical_temperature=None, max_iter_inner=None, max_iter_outer=None, tol_inner=None, tol_outer=None, verbosity=None))] #[expect(clippy::too_many_arguments)] pub(crate) fn dew_point_line<'py>( eos: &PyEquationOfState, molefracs: PyReadonlyArray1<'py, f64>, min_temperature: Temperature, npoints: usize, critical_temperature: Option<Temperature>, max_iter_inner: Option<usize>, max_iter_outer: Option<usize>, tol_inner: Option<f64>, tol_outer: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Self> { let dia = PhaseDiagram::dew_point_line( &eos.0, &parse_molefracs(Some(molefracs)).unwrap(), min_temperature, npoints, critical_temperature, ( (max_iter_inner, tol_inner, verbosity.map(|v| v.into())).into(), (max_iter_outer, tol_outer, verbosity.map(|v| v.into())).into(), ), ) .map_err(PyFeosError::from)?; Ok(Self(dia)) } /// Calculate the spinodal lines for a mixture with fixed composition. /// /// Parameters /// ---------- /// eos: Eos /// The equation of state. /// molefracs: np.ndarray[float] /// The composition of the mixture. /// min_temperature: SINumber /// The lower limit for the temperature. /// npoints: int /// The number of points. /// critical_temperature: SINumber, optional /// An estimate for the critical temperature to initialize /// the calculation if necessary. For most components not necessary. /// Defaults to `None`. /// max_iter : int, optional /// The maximum number of iterations. /// tol: float, optional /// The solution tolerance. /// verbosity : Verbosity, optional /// The verbosity. /// /// Returns /// ------- /// PhaseDiagram #[staticmethod] #[pyo3( text_signature = "(eos, molefracs, min_temperature, npoints, critical_temperature=None, max_iter=None, tol=None, verbosity=None)" )] #[pyo3(signature = (eos, molefracs, min_temperature, npoints, critical_temperature=None, max_iter=None, tol=None, verbosity=None))] #[expect(clippy::too_many_arguments)] pub(crate) fn spinodal<'py>( eos: &PyEquationOfState, molefracs: PyReadonlyArray1<'py, f64>, min_temperature: Temperature, npoints: usize, critical_temperature: Option<Temperature>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Self> { let dia = PhaseDiagram::spinodal( &eos.0, &parse_molefracs(Some(molefracs)).unwrap(), min_temperature, npoints, critical_temperature, (max_iter, tol, verbosity.map(|v| v.into())).into(), ) .map_err(PyFeosError::from)?; Ok(Self(dia)) } #[getter] pub(crate) fn get_states(&self) -> Vec<PyPhaseEquilibrium> { self.0 .states .iter() .map(|vle| PyPhaseEquilibrium(vle.clone())) .collect() } #[getter] pub(crate) fn get_vapor(&self) -> PyStateVec { self.0.vapor().into() } #[getter] pub(crate) fn get_liquid(&self) -> PyStateVec { self.0.liquid().into() } /// Returns the phase diagram as dictionary. /// /// Parameters /// ---------- /// contributions : Contributions, optional /// The contributions to consider when calculating properties. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// Dict[str, List[float]] /// Keys: property names. Values: property for each state. /// /// Notes /// ----- /// - temperature : K /// - pressure : Pa /// - densities : mol / m³ /// - mass densities : kg / m³ /// - molar enthalpies : kJ / mol /// - molar entropies : kJ / mol / K /// - specific enthalpies : kJ / kg /// - specific entropies : kJ / kg / K /// - xi: liquid molefraction of component i /// - yi: vapor molefraction of component i /// - component index `i` matches to order of components in parameters. #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] pub(crate) fn to_dict(&self, contributions: PyContributions) -> IndexMap<String, Vec<f64>> { let n = self.0.states[0].liquid().eos.deref().components(); let c = Contributions::from(contributions); let mut dict = IndexMap::with_capacity(16 + 2 * n); if n != 1 { let xs = self.0.liquid().molefracs(); let ys = self.0.vapor().molefracs(); for i in 0..n { dict.insert(format!("x{i}"), xs.column(i).to_vec()); dict.insert(format!("y{i}"), ys.column(i).to_vec()); } } dict.insert( String::from("temperature"), self.0 .vapor() .temperature() .convert_to(KELVIN) .into_raw_vec_and_offset() .0, ); // Check if liquid and vapor pressures are different (e.g. if ) let p_v = self .0 .vapor() .pressure() .convert_to(PASCAL) .into_raw_vec_and_offset() .0; let p_l = self .0 .liquid() .pressure() .convert_to(PASCAL) .into_raw_vec_and_offset() .0; let different_pressures = p_v .iter() .zip(p_l.iter()) .any(|(pv, pl)| (pv - pl).abs() / pv > 1e-3); if different_pressures { dict.insert(String::from("pressure vapor"), p_v); dict.insert(String::from("pressure liquid"), p_l); } else { dict.insert(String::from("pressure"), p_v); } dict.insert( String::from("density liquid"), self.0 .liquid() .density() .convert_to(MOL / METER.powi::<3>()) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("density vapor"), self.0 .vapor() .density() .convert_to(MOL / METER.powi::<3>()) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("molar enthalpy liquid"), self.0 .liquid() .molar_enthalpy(c) .convert_to(KILO * JOULE / MOL) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("molar enthalpy vapor"), self.0 .vapor() .molar_enthalpy(c) .convert_to(KILO * JOULE / MOL) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("molar entropy liquid"), self.0 .liquid() .molar_entropy(c) .convert_to(KILO * JOULE / KELVIN / MOL) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("molar entropy vapor"), self.0 .vapor() .molar_entropy(c) .convert_to(KILO * JOULE / KELVIN / MOL) .into_raw_vec_and_offset() .0, ); if self.0.states[0].liquid().eos.residual.has_molar_weight() { dict.insert( String::from("mass density liquid"), self.0 .liquid() .mass_density() .convert_to(KILOGRAM / METER.powi::<3>()) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("mass density vapor"), self.0 .vapor() .mass_density() .convert_to(KILOGRAM / METER.powi::<3>()) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("specific enthalpy liquid"), self.0 .liquid() .specific_enthalpy(c) .convert_to(KILO * JOULE / KILOGRAM) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("specific enthalpy vapor"), self.0 .vapor() .specific_enthalpy(c) .convert_to(KILO * JOULE / KILOGRAM) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("specific entropy liquid"), self.0 .liquid() .specific_entropy(c) .convert_to(KILO * JOULE / KELVIN / KILOGRAM) .into_raw_vec_and_offset() .0, ); dict.insert( String::from("specific entropy vapor"), self.0 .vapor() .specific_entropy(c) .convert_to(KILO * JOULE / KELVIN / KILOGRAM) .into_raw_vec_and_offset() .0, ); } dict } /// Binary phase diagram calculated using bubble/dew point iterations. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state. /// temperature_or_pressure: SINumber /// The constant temperature or pressure. /// npoints: int, optional /// The number of points (default 51). /// x_lle: (float, float), optional /// An estimate for the molefractions of component 1 /// at the heteroazeotrop /// max_iter_inner : int, optional /// The maximum number of inner iterations in the bubble/dew point iteration. /// max_iter_outer : int, optional /// The maximum number of outer iterations in the bubble/dew point iteration. /// tol_inner : float, optional /// The solution tolerance in the inner loop of the bubble/dew point iteration. /// tol_outer : float, optional /// The solution tolerance in the outer loop of the bubble/dew point iteration. /// verbosity : Verbosity, optional /// The verbosity of the bubble/dew point iteration. /// /// Returns /// ------- /// PhaseDiagram #[staticmethod] #[pyo3( text_signature = "(eos, temperature_or_pressure, npoints=None, x_lle=None, max_iter_inner=None, max_iter_outer=None, tol_inner=None, tol_outer=None, verbosity=None)" )] #[pyo3(signature = (eos, temperature_or_pressure, npoints=None, x_lle=None, max_iter_inner=None, max_iter_outer=None, tol_inner=None, tol_outer=None, verbosity=None))] #[expect(clippy::too_many_arguments)] pub(crate) fn binary_vle( eos: &PyEquationOfState, temperature_or_pressure: Bound<'_, PyAny>, npoints: Option<usize>, x_lle: Option<(f64, f64)>, max_iter_inner: Option<usize>, max_iter_outer: Option<usize>, tol_inner: Option<f64>, tol_outer: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Self> { if let Ok(t) = temperature_or_pressure.extract::<Temperature>() { Ok(Self( PhaseDiagram::binary_vle( &eos.0, t, npoints, x_lle, ( (max_iter_inner, tol_inner, verbosity.map(|v| v.into())).into(), (max_iter_outer, tol_outer, verbosity.map(|v| v.into())).into(), ), ) .map_err(PyFeosError::from)?, )) } else if let Ok(p) = temperature_or_pressure.extract::<Pressure>() { Ok(Self( PhaseDiagram::binary_vle( &eos.0, p, npoints, x_lle, ( (max_iter_inner, tol_inner, verbosity.map(|v| v.into())).into(), (max_iter_outer, tol_outer, verbosity.map(|v| v.into())).into(), ), ) .map_err(PyFeosError::from)?, )) } else { Err(PyErr::new::<PyValueError, _>(format!( "Wrong units! Expected K or Pa, got {}.", temperature_or_pressure.call_method0("__repr__")? ))) } } /// Create a new phase diagram using Tp flash calculations. /// /// The usual use case for this function is the calculation of /// liquid-liquid phase diagrams, but it can be used for vapor- /// liquid diagrams as well, as long as the feed composition is /// in a two phase region. /// /// Parameters /// ---------- /// eos : EquationOfState /// The equation of state. /// temperature_or_pressure: SINumber /// The consant temperature or pressure. /// feed: SIArray1 /// Mole numbers in the (unstable) feed state. /// min_tp: /// The lower limit of the temperature/pressure range. /// max_tp: /// The upper limit of the temperature/pressure range. /// npoints: int, optional /// The number of points (default 51). /// /// Returns /// ------- /// PhaseDiagram #[staticmethod] #[pyo3(text_signature = "(eos, temperature_or_pressure, feed, min_tp, max_tp, npoints=None)")] #[pyo3(signature = (eos, temperature_or_pressure, feed, min_tp, max_tp, npoints=None))] pub(crate) fn lle( eos: &PyEquationOfState, temperature_or_pressure: Bound<'_, PyAny>, feed: Moles<DVector<f64>>, min_tp: Bound<'_, PyAny>, max_tp: Bound<'_, PyAny>, npoints: Option<usize>, ) -> PyResult<Self> { if let Ok(t) = temperature_or_pressure.extract::<Temperature>() { Ok(Self( PhaseDiagram::lle( &eos.0, t, &feed, min_tp.extract()?, max_tp.extract()?, npoints, ) .map_err(PyFeosError::from)?, )) } else if let Ok(p) = temperature_or_pressure.extract::<Pressure>() { Ok(Self( PhaseDiagram::lle( &eos.0, p, &feed, min_tp.extract()?, max_tp.extract()?, npoints, ) .map_err(PyFeosError::from)?, )) } else { Err(PyErr::new::<PyValueError, _>(format!( "Wrong units! Expected K or Pa, got {}.", temperature_or_pressure.call_method0("__repr__")? ))) } } } /// Phase diagram for a binary mixture exhibiting a heteroazeotrope. #[pyclass(name = "PhaseDiagramHetero")] pub struct PyPhaseDiagramHetero( PhaseDiagramHetero<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>, ); #[pymethods] impl PyPhaseDiagram { /// Phase diagram for a binary mixture exhibiting a heteroazeotrope. /// /// Parameters /// ---------- /// eos: SaftFunctional /// The SAFT Helmholtz energy functional. /// temperature_or_pressure: SINumber /// The temperature_or_pressure. /// x_lle: SINumber /// Initial values for the molefractions of component 1 /// at the heteroazeotrop. /// tp_lim_lle: SINumber, optional /// The minimum temperature up to which the LLE is calculated. /// If it is not provided, no LLE is calcualted. /// tp_init_vlle: SINumber, optional /// Initial value for the calculation of the VLLE. /// npoints_vle: int, optional /// The number of points for the VLE (default 51). /// npoints_lle: int, optional /// The number of points for the LLE (default 51). /// max_iter_inner : int, optional /// The maximum number of inner iterations in the bubble/dew point iteration. /// max_iter_outer : int, optional /// The maximum number of outer iterations in the bubble/dew point iteration. /// tol_inner : float, optional /// The solution tolerance in the inner loop of the bubble/dew point iteration. /// tol_outer : float, optional /// The solution tolerance in the outer loop of the bubble/dew point iteration. /// verbosity : Verbosity, optional /// The verbosity of the bubble/dew point iteration. /// /// Returns /// ------- /// PhaseDiagramHetero #[staticmethod] #[pyo3( text_signature = "(eos, temperature_or_pressure, x_lle, tp_lim_lle=None, tp_init_vlle=None, npoints_vle=None, npoints_lle=None, max_iter_inner=None, max_iter_outer=None, tol_inner=None, tol_outer=None, verbosity=None)" )] #[pyo3(signature = (eos, temperature_or_pressure, x_lle, tp_lim_lle=None, tp_init_vlle=None, npoints_vle=None, npoints_lle=None, max_iter_inner=None, max_iter_outer=None, tol_inner=None, tol_outer=None, verbosity=None))] #[expect(clippy::too_many_arguments)] pub(crate) fn binary_vlle( eos: &PyEquationOfState, temperature_or_pressure: Bound<'_, PyAny>, x_lle: (f64, f64), tp_lim_lle: Option<Bound<'_, PyAny>>, tp_init_vlle: Option<Bound<'_, PyAny>>, npoints_vle: Option<usize>, npoints_lle: Option<usize>, max_iter_inner: Option<usize>, max_iter_outer: Option<usize>, tol_inner: Option<f64>, tol_outer: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<PyPhaseDiagramHetero> { if let Ok(t) = temperature_or_pressure.extract::<Temperature>() { Ok(PyPhaseDiagramHetero( PhaseDiagram::binary_vlle( &eos.0, t, x_lle, tp_lim_lle.map(|t| t.extract()).transpose()?, tp_init_vlle.map(|t| t.extract()).transpose()?, npoints_vle, npoints_lle, ( (max_iter_inner, tol_inner, verbosity.map(|v| v.into())).into(), (max_iter_outer, tol_outer, verbosity.map(|v| v.into())).into(), ), ) .map_err(PyFeosError::from)?, )) } else if let Ok(p) = temperature_or_pressure.extract::<Pressure>() { Ok(PyPhaseDiagramHetero( PhaseDiagram::binary_vlle( &eos.0, p, x_lle, tp_lim_lle.map(|t| t.extract()).transpose()?, tp_init_vlle.map(|t| t.extract()).transpose()?, npoints_vle, npoints_lle, ( (max_iter_inner, tol_inner, verbosity.map(|v| v.into())).into(), (max_iter_outer, tol_outer, verbosity.map(|v| v.into())).into(), ), ) .map_err(PyFeosError::from)?, )) } else { Err(PyErr::new::<PyValueError, _>(format!( "Wrong units! Expected K or Pa, got {}.", temperature_or_pressure.call_method0("__repr__")? ))) } } } #[pymethods] impl PyPhaseDiagramHetero { #[getter] pub(crate) fn get_vle(&self) -> PyPhaseDiagram { PyPhaseDiagram(self.0.vle().clone()) } #[getter] pub(crate) fn get_vle1(&self) -> PyPhaseDiagram { PyPhaseDiagram(self.0.vle1.clone()) } #[getter] pub(crate) fn get_vle2(&self) -> PyPhaseDiagram { PyPhaseDiagram(self.0.vle2.clone()) } #[getter] pub(crate) fn get_lle(&self) -> Option<PyPhaseDiagram> { self.0.lle.as_ref().map(|d| PyPhaseDiagram(d.clone())) } }
Rust
3D
feos-org/feos
py-feos/src/ad/mod.rs
.rs
8,150
234
use feos::pcsaft::{PcSaftBinary, PcSaftPure}; use feos_core::{ParametersAD, PropertiesAD}; use numpy::{PyArray1, PyArray2, PyReadonlyArray2, ToPyArray}; use paste::paste; use pyo3::prelude::*; #[pyclass(name = "EquationOfStateAD", eq, eq_int)] #[derive(Clone, Copy, PartialEq)] pub enum PyEquationOfStateAD { PcSaftNonAssoc, PcSaftFull, } enum BinaryModels { PcSaftNonAssoc, PcSaftFull, } impl From<PyEquationOfStateAD> for BinaryModels { fn from(value: PyEquationOfStateAD) -> Self { match value { PyEquationOfStateAD::PcSaftNonAssoc => Self::PcSaftNonAssoc, PyEquationOfStateAD::PcSaftFull => Self::PcSaftFull, } } } type GradResult<'py> = ( Bound<'py, PyArray1<f64>>, Bound<'py, PyArray2<f64>>, Bound<'py, PyArray1<bool>>, ); /// Calculate vapor pressures and derivatives w.r.t. model parameters. /// /// Parameters /// ---------- /// model: EquationOfStateAD /// The equation of state to use. /// parameter_names: List[string] /// The name of the parameters for which derivatives are calculated. /// parameters: np.ndarray[float] /// The parameters for every data point. /// input: np.ndarray[float] /// The temperature (in K) for every data point. /// /// Returns /// ------- /// (np.ndarray[float], np.ndarray[float], np.ndarray[bool]): The vapor pressures (in Pa), gradients, and convergence status. #[pyfunction] pub fn vapor_pressure_derivatives<'py>( model: PyEquationOfStateAD, parameter_names: Bound<'py, PyAny>, parameters: PyReadonlyArray2<f64>, input: PyReadonlyArray2<f64>, ) -> GradResult<'py> { _vapor_pressure_derivatives(model, parameter_names, parameters, input) } /// Calculate liquid densities and derivatives w.r.t. model parameters. /// /// Parameters /// ---------- /// model: EquationOfStateAD /// The equation of state to use. /// parameter_names: List[string] /// The name of the parameters for which derivatives are calculated. /// parameters: np.ndarray[float] /// The parameters for every data point. /// input: np.ndarray[float] /// The temperature (in K) and pressure (in Pa) for every data point. /// /// Returns /// ------- /// (np.ndarray[float], np.ndarray[float], np.ndarray[bool]): The liquid densities (in kmol/m³), gradients, and convergence status. #[pyfunction] pub fn liquid_density_derivatives<'py>( model: PyEquationOfStateAD, parameter_names: Bound<'py, PyAny>, parameters: PyReadonlyArray2<f64>, input: PyReadonlyArray2<f64>, ) -> GradResult<'py> { _liquid_density_derivatives(model, parameter_names, parameters, input) } /// Calculate liquid densities at saturation and derivatives w.r.t. model parameters. /// /// Parameters /// ---------- /// model: EquationOfStateAD /// The equation of state to use. /// parameter_names: List[string] /// The name of the parameters for which derivatives are calculated. /// parameters: np.ndarray[float] /// The parameters for every data point. /// input: np.ndarray[float] /// The temperature (in K) for every data point. /// /// Returns /// ------- /// (np.ndarray[float], np.ndarray[float], np.ndarray[bool]): The liquid densities (in kmol/m³), gradients, and convergence status. #[pyfunction] pub fn equilibrium_liquid_density_derivatives<'py>( model: PyEquationOfStateAD, parameter_names: Bound<'py, PyAny>, parameters: PyReadonlyArray2<f64>, input: PyReadonlyArray2<f64>, ) -> GradResult<'py> { _equilibrium_liquid_density_derivatives(model, parameter_names, parameters, input) } /// Calculate bubble point pressures of binary mixtures and derivatives w.r.t. model parameters. /// /// Parameters /// ---------- /// model: EquationOfStateAD /// The equation of state to use. /// parameter_names: List[string] /// The name of the parameters for which derivatives are calculated. /// parameters: np.ndarray[float] /// The parameters for every data point. /// input: np.ndarray[float] /// The temperature (in K), composition of the first component, and an initial guess for the /// pressure (in Pa) for every data point. /// /// Returns /// ------- /// (np.ndarray[float], np.ndarray[float], np.ndarray[bool]): The bubble point pressures (in Pa), gradients, and convergence status. #[pyfunction] pub fn bubble_point_pressure_derivatives<'py>( model: PyEquationOfStateAD, parameter_names: Bound<'py, PyAny>, parameters: PyReadonlyArray2<f64>, input: PyReadonlyArray2<f64>, ) -> GradResult<'py> { _bubble_point_pressure_derivatives(model, parameter_names, parameters, input) } /// Calculate dew point pressures of binary mixtures and derivatives w.r.t. model parameters. /// /// Parameters /// ---------- /// model: EquationOfStateAD /// The equation of state to use. /// parameter_names: List[string] /// The name of the parameters for which derivatives are calculated. /// parameters: np.ndarray[float] /// The parameters for every data point. /// input: np.ndarray[float] /// The temperature (in K), composition of the first component, and an initial guess for the /// pressure (in Pa) for every data point. /// /// Returns /// ------- /// (np.ndarray[float], np.ndarray[float], np.ndarray[bool]): The dew point pressures (in Pa), gradients, and convergence status. #[pyfunction] pub fn dew_point_pressure_derivatives<'py>( model: PyEquationOfStateAD, parameter_names: Bound<'py, PyAny>, parameters: PyReadonlyArray2<f64>, input: PyReadonlyArray2<f64>, ) -> GradResult<'py> { _dew_point_pressure_derivatives(model, parameter_names, parameters, input) } macro_rules! expand_models { ($enum:ty, $prop:ident, $($model:ident: $type:ty),*) => { paste!( #[pyfunction] fn [<_ $prop _derivatives>]<'py>( model: PyEquationOfStateAD, parameter_names: Bound<'py, PyAny>, parameters: PyReadonlyArray2<f64>, input: PyReadonlyArray2<f64>, ) -> GradResult<'py> { match <$enum>::from(model) { $( <$enum>::$model => { $prop::<$type>(parameter_names, parameters, input) })* } }); }; } macro_rules! impl_evaluate_gradients { (pure, [$($prop:ident),*], $models:tt) => { $(impl_evaluate_gradients!(1,PyEquationOfStateAD,$prop,$models,0,1,2,3,4,5,max:6);)* }; (binary, [$($prop:ident),*], $models:tt) => { $(impl_evaluate_gradients!(2,BinaryModels,$prop,$models,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,max:15);)* }; ($n:literal, $enum:ty, $prop:ident, {$($model:ident: $type:ty),*}, $($p:literal,)* max: $max:literal) => { expand_models!($enum, $prop, $($model: $type),*); paste!( fn $prop<'py, R: ParametersAD<$n>>( parameter_names: Bound<'py, PyAny>, parameters: PyReadonlyArray2<f64>, input: PyReadonlyArray2<f64>, ) -> ( Bound<'py, PyArray1<f64>>, Bound<'py, PyArray2<f64>>, Bound<'py, PyArray1<bool>>, ) { let (value, grad, status) = $( if let Ok(p) = parameter_names.extract::<[String; $p]>() { R::[<$prop _parallel>](p, parameters.as_array(), input.as_array()) } else)* if let Ok(p) = parameter_names.extract::<[String; $max]>() { R::[<$prop _parallel>](p, parameters.as_array(), input.as_array()) } else { panic!("Gradients can only be evaluated for up to {} parameters!", $max) }; ( value.to_pyarray(parameter_names.py()), grad.to_pyarray(parameter_names.py()), status.to_pyarray(parameter_names.py()), ) }); }; } impl_evaluate_gradients!( pure, [vapor_pressure, liquid_density, equilibrium_liquid_density], {PcSaftNonAssoc: PcSaftPure<f64, 4>, PcSaftFull: PcSaftPure<f64, 8>} ); impl_evaluate_gradients!( binary, [bubble_point_pressure, dew_point_pressure], {PcSaftNonAssoc: PcSaftBinary<f64, 4>, PcSaftFull: PcSaftBinary<f64, 8>} );
Rust
3D
feos-org/feos
py-feos/src/eos/mod.rs
.rs
7,499
228
use crate::error::PyFeosError; use crate::ideal_gas::IdealGasModel; use crate::residual::ResidualModel; use feos_core::*; use indexmap::IndexMap; use nalgebra::{DVector, DVectorView, Dyn}; use numpy::{PyArray1, PyReadonlyArray1, ToPyArray}; use pyo3::prelude::*; use quantity::*; use std::ops::Div; use std::sync::Arc; type Quot<T1, T2> = <T1 as Div<T2>>::Output; mod constructors; #[cfg(feature = "epcsaft")] mod epcsaft; #[cfg(feature = "gc_pcsaft")] mod gc_pcsaft; #[cfg(feature = "multiparameter")] mod multiparameter; #[cfg(feature = "pcsaft")] mod pcsaft; #[cfg(feature = "pets")] mod pets; #[cfg(feature = "saftvrmie")] mod saftvrmie; #[cfg(feature = "saftvrqmie")] mod saftvrqmie; #[cfg(feature = "uvtheory")] mod uvtheory; /// Collection of equations of state. #[pyclass(name = "EquationOfState")] pub struct PyEquationOfState(pub Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>); #[pymethods] impl PyEquationOfState { #[getter] fn get_parameters<'py>(&self, py: Python<'py>) -> IndexMap<String, Bound<'py, PyAny>> { let pure = self.0.pure_parameters(); let binary = self.0.binary_parameters(); let association_ab = self.0.association_parameters_ab(); let association_cc = self.0.association_parameters_cc(); pure.into_iter() .map(|(k, v)| (k, PyArray1::from_slice(py, v.as_slice()).into_any())) .chain( binary .into_iter() .chain(association_ab) .chain(association_cc) .map(|(k, v)| (k, v.to_pyarray(py).into_any())), ) .collect() } /// Return maximum density for given amount of substance of each component. /// /// Parameters /// ---------- /// molefracs : np.ndarray[float], optional /// The composition of the mixture. /// /// Returns /// ------- /// SINumber #[pyo3(text_signature = "(molefracs=None)", signature = (molefracs=None))] fn max_density(&self, molefracs: Option<PyReadonlyArray1<f64>>) -> PyResult<Density> { Ok(self .0 .max_density(&parse_molefracs(molefracs)) .map_err(PyFeosError::from)?) } /// Calculate the second Virial coefficient B(T,x). /// /// Parameters /// ---------- /// temperature : SINumber /// The temperature for which B should be computed. /// molefracs : np.ndarray[float], optional /// The composition of the mixture. /// /// Returns /// ------- /// SINumber #[pyo3(text_signature = "(temperature, molefracs=None)", signature = (temperature, molefracs=None))] fn second_virial_coefficient( &self, temperature: Temperature, molefracs: Option<PyReadonlyArray1<f64>>, ) -> Quot<f64, Density> { self.0 .second_virial_coefficient(temperature, &parse_molefracs(molefracs)) } /// Calculate the third Virial coefficient C(T,x). /// /// Parameters /// ---------- /// temperature : SINumber /// The temperature for which C should be computed. /// molefracs : np.ndarray[float], optional /// The composition of the mixture. /// /// Returns /// ------- /// SINumber #[pyo3(text_signature = "(temperature, molefracs=None)", signature = (temperature, molefracs=None))] fn third_virial_coefficient( &self, temperature: Temperature, molefracs: Option<PyReadonlyArray1<f64>>, ) -> Quot<Quot<f64, Density>, Density> { self.0 .third_virial_coefficient(temperature, &parse_molefracs(molefracs)) } /// Calculate the derivative of the second Virial coefficient B(T,x) /// with respect to temperature. /// /// Parameters /// ---------- /// temperature : SINumber /// The temperature for which B' should be computed. /// molefracs : np.ndarray[float], optional /// The composition of the mixture. /// /// Returns /// ------- /// SINumber #[pyo3(text_signature = "(temperature, molefracs=None)", signature = (temperature, molefracs=None))] fn second_virial_coefficient_temperature_derivative( &self, temperature: Temperature, molefracs: Option<PyReadonlyArray1<f64>>, ) -> Quot<Quot<f64, Density>, Temperature> { self.0.second_virial_coefficient_temperature_derivative( temperature, &parse_molefracs(molefracs), ) } /// Calculate the derivative of the third Virial coefficient C(T,x) /// with respect to temperature. /// /// Parameters /// ---------- /// temperature : SINumber /// The temperature for which C' should be computed. /// molefracs : np.ndarray[float], optional /// The composition of the mixture. /// /// Returns /// ------- /// SINumber #[pyo3(text_signature = "(temperature, molefracs=None)", signature = (temperature, molefracs=None))] fn third_virial_coefficient_temperature_derivative( &self, temperature: Temperature, molefracs: Option<PyReadonlyArray1<f64>>, ) -> Quot<Quot<Quot<f64, Density>, Density>, Temperature> { self.0.third_virial_coefficient_temperature_derivative( temperature, &parse_molefracs(molefracs), ) } } impl PyEquationOfState { fn add_ideal_gas(&mut self, ideal_gas: Vec<IdealGasModel>) { let Some(eos) = Arc::get_mut(&mut self.0) else { panic!("Cannot change equation of state after using it!") }; if let ResidualModel::NoResidual(c) = &mut eos.residual { c.0 = ideal_gas.len() } if eos.ideal_gas.is_empty() || matches!(eos.ideal_gas[0], IdealGasModel::NoModel) { eos.ideal_gas = ideal_gas; } else { panic!("There is already an ideal gas model initialized for the equation of state!") } } } pub(crate) fn parse_molefracs(molefracs: Option<PyReadonlyArray1<f64>>) -> Option<DVector<f64>> { molefracs.map(|x| { let x: DVectorView<f64, Dyn, Dyn> = x .try_as_matrix() .expect("molefracs are in an invalid format!"); x.clone_owned() }) } // impl_state_entropy_scaling!(EquationOfState<Vec<IdealGasModel>, ResidualModel>, PyEquationOfState); // impl_phase_equilibrium!(EquationOfState<Vec<IdealGasModel>, ResidualModel>, PyEquationOfState); // #[cfg(feature = "estimator")] // impl_estimator!(EquationOfState<Vec<IdealGasModel>, ResidualModel>, PyEquationOfState); // #[cfg(all(feature = "estimator", feature = "pcsaft"))] // impl_estimator_entropy_scaling!(EquationOfState<Vec<IdealGasModel>, ResidualModel>, PyEquationOfState); // #[pymodule] // pub fn eos(m: &Bound<'_, PyModule>) -> PyResult<()> { // m.add_class::<Contributions>()?; // m.add_class::<Verbosity>()?; // m.add_class::<PyEquationOfState>()?; // m.add_class::<PyState>()?; // m.add_class::<PyStateVec>()?; // m.add_class::<PyPhaseDiagram>()?; // m.add_class::<PyPhaseEquilibrium>()?; // #[cfg(feature = "estimator")] // m.add_wrapped(wrap_pymodule!(estimator_eos))?; // Ok(()) // } // #[cfg(feature = "estimator")] // #[pymodule] // pub fn estimator_eos(m: &Bound<'_, PyModule>) -> PyResult<()> { // m.add_class::<PyDataSet>()?; // m.add_class::<PyEstimator>()?; // m.add_class::<PyLoss>()?; // m.add_class::<Phase>() // }
Rust
3D
feos-org/feos
py-feos/src/eos/constructors.rs
.rs
3,906
128
use super::PyEquationOfState; use crate::ideal_gas::IdealGasModel; use crate::parameter::{PyGcParameters, PyParameters}; use crate::residual::ResidualModel; use crate::user_defined::{PyIdealGas, PyResidual}; use feos::ideal_gas::{Dippr, Joback}; use feos_core::cubic::PengRobinson; use feos_core::*; use pyo3::prelude::*; use std::sync::Arc; #[pymethods] impl PyEquationOfState { /// Peng-Robinson equation of state. /// /// Parameters /// ---------- /// parameters : PengRobinsonParameters /// The parameters of the PR equation of state to use. /// /// Returns /// ------- /// EquationOfState /// The PR equation of state that can be used to compute thermodynamic /// states. #[staticmethod] pub fn peng_robinson(parameters: PyParameters) -> PyResult<Self> { let residual = ResidualModel::PengRobinson(PengRobinson::new(parameters.try_convert()?)); let ideal_gas = vec![IdealGasModel::NoModel; residual.components()]; Ok(Self(Arc::new(EquationOfState::new(ideal_gas, residual)))) } /// Residual Helmholtz energy model from a Python class. /// /// Parameters /// ---------- /// residual : Class /// A python class implementing the necessary methods /// to be used as residual equation of state. /// /// Returns /// ------- /// EquationOfState #[staticmethod] fn python_residual(residual: Bound<'_, PyAny>) -> PyResult<Self> { let residual = ResidualModel::Python(PyResidual::new(residual)?); let ideal_gas = vec![IdealGasModel::NoModel; residual.components()]; Ok(Self(Arc::new(EquationOfState::new(ideal_gas, residual)))) } /// Equation of state that only contains an ideal gas contribution. /// /// Returns /// ------- /// EquationOfState #[staticmethod] fn ideal_gas() -> Self { let residual = ResidualModel::NoResidual(NoResidual(0)); let ideal_gas = vec![IdealGasModel::NoModel; 0]; Self(Arc::new(EquationOfState::new(ideal_gas, residual))) } /// Ideal gas equation of state from a Python class. /// /// Parameters /// ---------- /// ideal_gas : Class /// A python class implementing the necessary methods /// to be used as an ideal gas model. /// /// Returns /// ------- /// EquationOfState fn python_ideal_gas<'py>( slf: Bound<'py, Self>, ideal_gas: Vec<Bound<'py, PyAny>>, ) -> PyResult<Bound<'py, Self>> { slf.borrow_mut().add_ideal_gas( ideal_gas .into_iter() .map(|i| Ok(IdealGasModel::Python(Arc::new(PyIdealGas::new(i)?)))) .collect::<PyResult<_>>()?, ); Ok(slf) } /// Ideal gas model of Joback and Reid. /// /// Parameters /// ---------- /// joback : Joback /// The parametrized Joback model. /// /// Returns /// ------- /// EquationOfState fn joback(slf: Bound<'_, Self>, joback: PyGcParameters) -> PyResult<Bound<'_, Self>> { slf.borrow_mut().add_ideal_gas( Joback::new(joback.try_convert_homosegmented()?) .into_iter() .map(IdealGasModel::Joback) .collect(), ); Ok(slf) } /// Ideal gas model based on DIPPR equations for the ideal /// gas heat capacity. /// /// Parameters /// ---------- /// dippr : Dippr /// The parametrized Dippr model. /// /// Returns /// ------- /// EquationOfState fn dippr(slf: Bound<'_, Self>, dippr: PyParameters) -> PyResult<Bound<'_, Self>> { slf.borrow_mut().add_ideal_gas( Dippr::new(dippr.try_convert()?) .into_iter() .map(IdealGasModel::Dippr) .collect(), ); Ok(slf) } }
Rust
3D
feos-org/feos
py-feos/src/eos/epcsaft.rs
.rs
2,683
70
use super::PyEquationOfState; use crate::error::PyFeosError; use crate::ideal_gas::IdealGasModel; use crate::parameter::PyParameters; use crate::residual::ResidualModel; use feos::epcsaft::{ElectrolytePcSaft, ElectrolytePcSaftOptions, ElectrolytePcSaftVariants}; use feos_core::{EquationOfState, ResidualDyn}; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use std::sync::Arc; #[pymethods] impl PyEquationOfState { /// ePC-SAFT equation of state. /// /// Parameters /// ---------- /// parameters : ElectrolytePcSaftParameters /// The parameters of the PC-SAFT equation of state to use. /// max_eta : float, optional /// Maximum packing fraction. Defaults to 0.5. /// max_iter_cross_assoc : unsigned integer, optional /// Maximum number of iterations for cross association. Defaults to 50. /// tol_cross_assoc : float, optional /// Tolerance for convergence of cross association. Defaults to 1e-10. /// epcsaft_variant : "advanced" | "revised", optional /// Variant of the ePC-SAFT equation of state. Defaults to "advanced" /// /// Returns /// ------- /// EquationOfState /// The ePC-SAFT equation of state that can be used to compute thermodynamic /// states. #[staticmethod] #[pyo3( signature = (parameters, max_eta=0.5, max_iter_cross_assoc=50, tol_cross_assoc=1e-10, epcsaft_variant="advanced"), text_signature = r#"(parameters, max_eta=0.5, max_iter_cross_assoc=50, tol_cross_assoc=1e-10, epcsaft_variant="advanced")"#, )] pub fn epcsaft( parameters: PyParameters, max_eta: f64, max_iter_cross_assoc: usize, tol_cross_assoc: f64, epcsaft_variant: &str, ) -> PyResult<Self> { let epcsaft_variant = match epcsaft_variant { "advanced" => ElectrolytePcSaftVariants::Advanced, "revised" => ElectrolytePcSaftVariants::Revised, _ => { return Err(PyErr::new::<PyValueError, _>( r#"epcsaft_variant must be "advanced" or "revised""#.to_string(), )) } }; let options = ElectrolytePcSaftOptions { max_eta, max_iter_cross_assoc, tol_cross_assoc, epcsaft_variant, }; let residual = ResidualModel::ElectrolytePcSaft( ElectrolytePcSaft::with_options(parameters.try_convert()?, options) .map_err(PyFeosError::from)?, ); let ideal_gas = vec![IdealGasModel::NoModel; residual.components()]; Ok(Self(Arc::new(EquationOfState::new(ideal_gas, residual)))) } }
Rust
3D
feos-org/feos
py-feos/src/eos/pets.rs
.rs
2,669
79
use super::PyEquationOfState; #[cfg(feature = "dft")] use crate::dft::{PyFMTVersion, PyHelmholtzEnergyFunctional}; use crate::{ideal_gas::IdealGasModel, parameter::PyParameters, residual::ResidualModel}; use feos::pets::{Pets, PetsOptions}; use feos_core::{EquationOfState, ResidualDyn}; use pyo3::prelude::*; use std::sync::Arc; #[pymethods] impl PyEquationOfState { /// PeTS equation of state. /// /// Parameters /// ---------- /// parameters : PetsParameters /// The parameters of the PeTS equation of state to use. /// max_eta : float, optional /// Maximum packing fraction. Defaults to 0.5. /// /// Returns /// ------- /// EquationOfState /// The PeTS equation of state that can be used to compute thermodynamic /// states. #[staticmethod] #[pyo3(signature = (parameters, max_eta=0.5), text_signature = "(parameters, max_eta=0.5)")] fn pets(parameters: PyParameters, max_eta: f64) -> PyResult<Self> { let options = PetsOptions { max_eta, ..Default::default() }; let residual = ResidualModel::Pets(Pets::with_options(parameters.try_convert()?, options)); let ideal_gas = vec![IdealGasModel::NoModel; residual.components()]; Ok(Self(Arc::new(EquationOfState::new(ideal_gas, residual)))) } } #[cfg(feature = "dft")] #[pymethods] impl PyHelmholtzEnergyFunctional { /// PeTS Helmholtz energy functional without simplifications /// for pure components. /// /// Parameters /// ---------- /// parameters: PetsParameters /// The set of PeTS parameters. /// fmt_version: FMTVersion, optional /// The specific variant of the FMT term. Defaults to FMTVersion.WhiteBear /// max_eta : float, optional /// Maximum packing fraction. Defaults to 0.5. /// /// Returns /// ------- /// HelmholtzEnergyFunctional #[staticmethod] #[pyo3( signature = (parameters, fmt_version=PyFMTVersion::WhiteBear, max_eta=0.5), text_signature = "(parameters, fmt_version, max_eta=0.5)" )] fn pets( parameters: PyParameters, fmt_version: PyFMTVersion, max_eta: f64, ) -> PyResult<PyEquationOfState> { let options = PetsOptions { max_eta, fmt_version: fmt_version.into(), }; let func = ResidualModel::PetsFunctional(Pets::with_options(parameters.try_convert()?, options)); let ideal_gas = vec![IdealGasModel::NoModel; func.components()]; Ok(PyEquationOfState(Arc::new(EquationOfState::new( ideal_gas, func, )))) } }
Rust
3D
feos-org/feos
py-feos/src/eos/saftvrqmie.rs
.rs
3,474
98
use super::PyEquationOfState; #[cfg(feature = "dft")] use crate::dft::{PyFMTVersion, PyHelmholtzEnergyFunctional}; use crate::error::PyFeosError; use crate::ideal_gas::IdealGasModel; use crate::parameter::PyParameters; use crate::residual::ResidualModel; use feos::saftvrqmie::{SaftVRQMie, SaftVRQMieOptions}; use feos_core::{EquationOfState, ResidualDyn}; use pyo3::prelude::*; use std::sync::Arc; #[pymethods] impl PyEquationOfState { /// SAFT-VRQ Mie equation of state. /// /// Parameters /// ---------- /// parameters : SaftVRQMieParameters /// The parameters of the SAFT-VRQ Mie equation of state to use. /// max_eta : float, optional /// Maximum packing fraction. Defaults to 0.5. /// inc_nonadd_term : bool, optional /// Include non-additive correction to the hard-sphere reference. Defaults to True. /// /// Returns /// ------- /// EquationOfState /// The SAFT-VRQ Mie equation of state that can be used to compute thermodynamic /// states. #[staticmethod] #[pyo3( signature = (parameters, max_eta=0.5, inc_nonadd_term=true), text_signature = "(parameters, max_eta=0.5, inc_nonadd_term=True)" )] fn saftvrqmie(parameters: PyParameters, max_eta: f64, inc_nonadd_term: bool) -> PyResult<Self> { let options = SaftVRQMieOptions { max_eta, inc_nonadd_term, ..Default::default() }; let residual = ResidualModel::SaftVRQMie( SaftVRQMie::with_options(parameters.try_convert()?, options) .map_err(PyFeosError::from)?, ); let ideal_gas = vec![IdealGasModel::NoModel; residual.components()]; Ok(Self(Arc::new(EquationOfState::new(ideal_gas, residual)))) } } #[cfg(feature = "dft")] #[pymethods] impl PyHelmholtzEnergyFunctional { /// SAFT-VRQ Mie Helmholtz energy functional. /// /// Parameters /// ---------- /// parameters : SaftVRQMieParameters /// The parameters of the SAFT-VRQ Mie Helmholtz energy functional to use. /// fmt_version: FMTVersion, optional /// The specific variant of the FMT term. Defaults to FMTVersion.WhiteBear /// max_eta : float, optional /// Maximum packing fraction. Defaults to 0.5. /// inc_nonadd_term : bool, optional /// Include non-additive correction to the hard-sphere reference. Defaults to True. /// /// Returns /// ------- /// HelmholtzEnergyFunctional #[staticmethod] #[pyo3( signature = (parameters, fmt_version=PyFMTVersion::WhiteBear, max_eta=0.5, inc_nonadd_term=true), text_signature = "(parameters, fmt_version, max_eta=0.5, inc_nonadd_term=True)" )] fn saftvrqmie( parameters: PyParameters, fmt_version: PyFMTVersion, max_eta: f64, inc_nonadd_term: bool, ) -> PyResult<PyEquationOfState> { use crate::error::PyFeosError; let options = SaftVRQMieOptions { max_eta, inc_nonadd_term, fmt_version: fmt_version.into(), }; let func = ResidualModel::SaftVRQMieFunctional( SaftVRQMie::with_options(parameters.try_convert()?, options) .map_err(PyFeosError::from)?, ); let ideal_gas = vec![IdealGasModel::NoModel; func.components()]; Ok(PyEquationOfState(Arc::new(EquationOfState::new( ideal_gas, func, )))) } }
Rust
3D
feos-org/feos
py-feos/src/eos/pcsaft.rs
.rs
5,346
142
use super::PyEquationOfState; #[cfg(feature = "dft")] use crate::dft::{PyFMTVersion, PyHelmholtzEnergyFunctional}; use crate::ideal_gas::IdealGasModel; use crate::parameter::{PyGcParameters, PyParameters}; use crate::residual::ResidualModel; #[cfg(feature = "dft")] use feos::pcsaft::PcSaftFunctional; use feos::pcsaft::{DQVariants, PcSaft, PcSaftOptions}; use feos_core::{EquationOfState, ResidualDyn}; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use std::sync::Arc; #[pymethods] impl PyEquationOfState { /// PC-SAFT equation of state. /// /// Parameters /// ---------- /// parameters : PcSaftParameters /// The parameters of the PC-SAFT equation of state to use. /// max_eta : float, optional /// Maximum packing fraction. Defaults to 0.5. /// max_iter_cross_assoc : unsigned integer, optional /// Maximum number of iterations for cross association. Defaults to 50. /// tol_cross_assoc : float, optional /// Tolerance for convergence of cross association. Defaults to 1e-10. /// dq_variant : "dq35" | "dq44", optional /// Combination rule used in the dipole/quadrupole term. Defaults to "dq35" /// /// Returns /// ------- /// EquationOfState /// The PC-SAFT equation of state that can be used to compute thermodynamic /// states. #[staticmethod] #[pyo3( signature = (parameters, max_eta=0.5, max_iter_cross_assoc=50, tol_cross_assoc=1e-10, dq_variant="dq35"), text_signature = r#"(parameters, max_eta=0.5, max_iter_cross_assoc=50, tol_cross_assoc=1e-10, dq_variant="dq35")"# )] pub fn pcsaft( parameters: &Bound<'_, PyAny>, max_eta: f64, max_iter_cross_assoc: usize, tol_cross_assoc: f64, dq_variant: &str, ) -> PyResult<Self> { let dq_variant = match dq_variant { "dq35" => DQVariants::DQ35, "dq44" => DQVariants::DQ44, _ => { return Err(PyErr::new::<PyValueError, _>( r#"dq_variant must be "dq35" or "dq44""#, )) } }; let options = PcSaftOptions { max_eta, max_iter_cross_assoc, tol_cross_assoc, dq_variant, }; let parameters = if let Ok(parameters) = parameters.extract::<PyParameters>() { parameters.try_convert() } else if let Ok(parameters) = parameters.extract::<PyGcParameters>() { parameters.try_convert_homosegmented() } else { return Err(PyErr::new::<PyValueError, _>( "Argument `parameters` must by Parameters or GcParameters", )); }?; let residual = ResidualModel::PcSaft(PcSaft::with_options(parameters, options)); let ideal_gas = vec![IdealGasModel::NoModel; residual.components()]; Ok(Self(Arc::new(EquationOfState::new(ideal_gas, residual)))) } } #[cfg(feature = "dft")] #[pymethods] impl PyHelmholtzEnergyFunctional { /// PC-SAFT Helmholtz energy functional. /// /// Parameters /// ---------- /// parameters: PcSaftParameters /// The set of PC-SAFT parameters. /// fmt_version: FMTVersion, optional /// The specific variant of the FMT term. Defaults to FMTVersion.WhiteBear /// max_eta : float, optional /// Maximum packing fraction. Defaults to 0.5. /// max_iter_cross_assoc : unsigned integer, optional /// Maximum number of iterations for cross association. Defaults to 50. /// tol_cross_assoc : float /// Tolerance for convergence of cross association. Defaults to 1e-10. /// dq_variant : DQVariants, optional /// Combination rule used in the dipole/quadrupole term. Defaults to 'DQVariants.DQ35' /// /// Returns /// ------- /// HelmholtzEnergyFunctional #[cfg(feature = "pcsaft")] #[staticmethod] #[pyo3( signature = (parameters, fmt_version=PyFMTVersion::WhiteBear, max_eta=0.5, max_iter_cross_assoc=50, tol_cross_assoc=1e-10, dq_variant="dq35"), text_signature = r#"(parameters, fmt_version, max_eta=0.5, max_iter_cross_assoc=50, tol_cross_assoc=1e-10, dq_variant="dq35")"# )] fn pcsaft( parameters: crate::parameter::PyParameters, fmt_version: PyFMTVersion, max_eta: f64, max_iter_cross_assoc: usize, tol_cross_assoc: f64, dq_variant: &str, ) -> PyResult<PyEquationOfState> { let dq_variant = match dq_variant { "dq35" => DQVariants::DQ35, "dq44" => DQVariants::DQ44, _ => { return Err(PyErr::new::<PyValueError, _>( r#"dq_variant must be "dq35" or "dq44""#.to_string(), )) } }; let options = PcSaftOptions { max_eta, max_iter_cross_assoc, tol_cross_assoc, dq_variant, }; let func = ResidualModel::PcSaftFunctional(PcSaftFunctional::with_options( parameters.try_convert()?, fmt_version.into(), options, )); let ideal_gas = vec![IdealGasModel::NoModel; func.components()]; Ok(PyEquationOfState(Arc::new(EquationOfState::new( ideal_gas, func, )))) } }
Rust
3D
feos-org/feos
py-feos/src/eos/gc_pcsaft.rs
.rs
3,969
108
use super::PyEquationOfState; #[cfg(feature = "dft")] use crate::dft::{PyFMTVersion, PyHelmholtzEnergyFunctional}; use crate::{ideal_gas::IdealGasModel, parameter::PyGcParameters, residual::ResidualModel}; #[cfg(feature = "dft")] use feos::gc_pcsaft::GcPcSaftFunctional; use feos::gc_pcsaft::{GcPcSaft, GcPcSaftOptions}; use feos_core::{EquationOfState, ResidualDyn}; use pyo3::prelude::*; use std::sync::Arc; #[pymethods] impl PyEquationOfState { /// (heterosegmented) group contribution PC-SAFT equation of state. /// /// Parameters /// ---------- /// parameters : GcPcSaftEosParameters /// The parameters of the PC-SAFT equation of state to use. /// max_eta : float, optional /// Maximum packing fraction. Defaults to 0.5. /// max_iter_cross_assoc : unsigned integer, optional /// Maximum number of iterations for cross association. Defaults to 50. /// tol_cross_assoc : float /// Tolerance for convergence of cross association. Defaults to 1e-10. /// /// Returns /// ------- /// EquationOfState /// The gc-PC-SAFT equation of state that can be used to compute thermodynamic /// states. #[cfg(feature = "gc_pcsaft")] #[staticmethod] #[pyo3( signature = (parameters, max_eta=0.5, max_iter_cross_assoc=50, tol_cross_assoc=1e-10), text_signature = "(parameters, max_eta=0.5, max_iter_cross_assoc=50, tol_cross_assoc=1e-10)" )] pub fn gc_pcsaft( parameters: PyGcParameters, max_eta: f64, max_iter_cross_assoc: usize, tol_cross_assoc: f64, ) -> PyResult<Self> { let options = GcPcSaftOptions { max_eta, max_iter_cross_assoc, tol_cross_assoc, }; let residual = ResidualModel::GcPcSaft(GcPcSaft::with_options( parameters.try_convert_heterosegmented()?, options, )); let ideal_gas = vec![IdealGasModel::NoModel; residual.components()]; Ok(Self(Arc::new(EquationOfState::new(ideal_gas, residual)))) } } #[cfg(feature = "dft")] #[pymethods] impl PyHelmholtzEnergyFunctional { /// (heterosegmented) group contribution PC-SAFT Helmholtz energy functional. /// /// Parameters /// ---------- /// parameters: GcPcSaftFunctionalParameters /// The set of PC-SAFT parameters. /// fmt_version: FMTVersion, optional /// The specific variant of the FMT term. Defaults to FMTVersion.WhiteBear /// max_eta : float, optional /// Maximum packing fraction. Defaults to 0.5. /// max_iter_cross_assoc : unsigned integer, optional /// Maximum number of iterations for cross association. Defaults to 50. /// tol_cross_assoc : float /// Tolerance for convergence of cross association. Defaults to 1e-10. /// /// Returns /// ------- /// HelmholtzEnergyFunctional #[cfg(feature = "gc_pcsaft")] #[staticmethod] #[pyo3( signature = (parameters, fmt_version=PyFMTVersion::WhiteBear, max_eta=0.5, max_iter_cross_assoc=50, tol_cross_assoc=1e-10), text_signature = "(parameters, fmt_version, max_eta=0.5, max_iter_cross_assoc=50, tol_cross_assoc=1e-10)" )] fn gc_pcsaft( parameters: PyGcParameters, fmt_version: PyFMTVersion, max_eta: f64, max_iter_cross_assoc: usize, tol_cross_assoc: f64, ) -> PyResult<PyEquationOfState> { let options = GcPcSaftOptions { max_eta, max_iter_cross_assoc, tol_cross_assoc, }; let func = ResidualModel::GcPcSaftFunctional(GcPcSaftFunctional::with_options( parameters.try_convert_heterosegmented()?, fmt_version.into(), options, )); let ideal_gas = vec![IdealGasModel::NoModel; func.components()]; Ok(PyEquationOfState(Arc::new(EquationOfState::new( ideal_gas, func, )))) } }
Rust
3D
feos-org/feos
py-feos/src/eos/saftvrmie.rs
.rs
1,822
50
use super::PyEquationOfState; use crate::{ideal_gas::IdealGasModel, parameter::PyParameters, residual::ResidualModel}; use feos::saftvrmie::{SaftVRMie, SaftVRMieOptions}; use feos_core::{EquationOfState, ResidualDyn}; use pyo3::prelude::*; use std::sync::Arc; #[pymethods] impl PyEquationOfState { /// SAFT-VR Mie equation of state. /// /// Parameters /// ---------- /// parameters : SaftVRMieParameters /// The parameters of the PC-SAFT equation of state to use. /// max_eta : float, optional /// Maximum packing fraction. Defaults to 0.5. /// max_iter_cross_assoc : unsigned integer, optional /// Maximum number of iterations for cross association. Defaults to 50. /// tol_cross_assoc : float /// Tolerance for convergence of cross association. Defaults to 1e-10. /// /// Returns /// ------- /// EquationOfState /// The SAFT-VR Mie equation of state that can be used to compute thermodynamic /// states. #[staticmethod] #[pyo3( signature = (parameters, max_eta=0.5, max_iter_cross_assoc=50, tol_cross_assoc=1e-10), text_signature = "(parameters, max_eta=0.5, max_iter_cross_assoc=50, tol_cross_assoc=1e-10)" )] pub fn saftvrmie( parameters: PyParameters, max_eta: f64, max_iter_cross_assoc: usize, tol_cross_assoc: f64, ) -> PyResult<Self> { let options = SaftVRMieOptions { max_eta, max_iter_cross_assoc, tol_cross_assoc, }; let residual = ResidualModel::SaftVRMie(SaftVRMie::with_options(parameters.try_convert()?, options)); let ideal_gas = vec![IdealGasModel::NoModel; residual.components()]; Ok(Self(Arc::new(EquationOfState::new(ideal_gas, residual)))) } }
Rust
3D
feos-org/feos
py-feos/src/eos/uvtheory.rs
.rs
2,017
55
use super::PyEquationOfState; use crate::ideal_gas::IdealGasModel; use crate::parameter::PyParameters; use crate::residual::ResidualModel; use feos::uvtheory::{Perturbation, UVTheory, UVTheoryOptions}; use feos_core::{EquationOfState, ResidualDyn}; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use std::sync::Arc; #[pymethods] impl PyEquationOfState { /// UV-Theory equation of state. /// /// Parameters /// ---------- /// parameters : UVTheoryParameters /// The parameters of the UV-theory equation of state to use. /// max_eta : float, optional /// Maximum packing fraction. Defaults to 0.5. /// perturbation : "BH" | "WCA" | "WCA_B3", optional /// Division type of the Mie potential. Defaults to "WCA". /// /// Returns /// ------- /// EquationOfState /// The UV-Theory equation of state that can be used to compute thermodynamic /// states. #[staticmethod] #[pyo3( signature = (parameters, max_eta=0.5, perturbation="WCA"), text_signature = r#"(parameters, max_eta=0.5, perturbation="WCA")"# )] fn uvtheory(parameters: PyParameters, max_eta: f64, perturbation: &str) -> PyResult<Self> { let perturbation = match perturbation { "BH" => Perturbation::BarkerHenderson, "WCA" => Perturbation::WeeksChandlerAndersen, "WCA_B3" => Perturbation::WeeksChandlerAndersenB3, _ => { return Err(PyErr::new::<PyValueError, _>( r#"perturbation must be "BH", "WCA" or "WCA_B3""#.to_string(), )) } }; let options = UVTheoryOptions { max_eta, perturbation, }; let residual = ResidualModel::UVTheory(UVTheory::with_options(parameters.try_convert()?, options)); let ideal_gas = vec![IdealGasModel::NoModel; residual.components()]; Ok(Self(Arc::new(EquationOfState::new(ideal_gas, residual)))) } }
Rust
3D
feos-org/feos
py-feos/src/eos/multiparameter.rs
.rs
1,756
58
use super::PyEquationOfState; use crate::ideal_gas::IdealGasModel; use crate::parameter::PyParameters; use crate::residual::ResidualModel; use feos::multiparameter::MultiParameter; use feos_core::EquationOfState; use pyo3::prelude::*; use std::sync::Arc; #[pymethods] impl PyEquationOfState { /// Multiparameter Helmholtz energy equations of state. /// /// Parameters /// ---------- /// parameters : Parameters /// The parameters of the multiparameter Helmholtz equation of state. /// /// Returns /// ------- /// EquationOfState #[staticmethod] pub fn multiparameter(parameters: PyParameters) -> PyResult<Self> { let eos = MultiParameter::new(parameters.try_convert()?); let residual = ResidualModel::MultiParameter(eos.residual); let ideal_gas = eos .ideal_gas .into_iter() .map(IdealGasModel::MultiParameter) .collect(); Ok(Self(Arc::new(EquationOfState::new(ideal_gas, residual)))) } /// Ideal gas model used in multiparameter Helmholtz energy equations of state. /// /// Parameters /// ---------- /// parameters : Parameters /// The parameters of the multiparameter Helmholtz equation of state. /// /// Returns /// ------- /// EquationOfState pub fn multiparameter_ideal_gas( slf: Bound<'_, Self>, parameters: PyParameters, ) -> PyResult<Bound<'_, Self>> { let eos = MultiParameter::new(parameters.try_convert()?); let ideal_gas = eos .ideal_gas .into_iter() .map(IdealGasModel::MultiParameter) .collect(); slf.borrow_mut().add_ideal_gas(ideal_gas); Ok(slf) } }
Rust
3D
feos-org/feos
py-feos/src/parameter/model_record.rs
.rs
6,230
206
//! Structs for parameter objects. //! //! - PyPureRecord //! - PyBinaryRecord use super::identifier::{PyIdentifier, PyIdentifierOption}; use crate::error::PyFeosError; use feos_core::parameter::*; use pyo3::types::PyDict; use pyo3::{exceptions::PyValueError, prelude::*}; use pythonize::{depythonize, pythonize}; use serde::{Deserialize, Serialize}; use serde_json::Value; /// Parameters that describe a pure component. #[derive(Serialize, Deserialize, Clone)] #[serde(from = "PureRecord<Value, Value>")] #[serde(into = "PureRecord<Value, Value>")] #[pyclass(name = "PureRecord")] pub struct PyPureRecord { #[pyo3(get)] pub identifier: PyIdentifier, #[pyo3(get)] pub molarweight: f64, pub model_record: Value, pub association_sites: Vec<AssociationRecord<Value>>, } impl From<PyPureRecord> for PureRecord<Value, Value> { fn from(value: PyPureRecord) -> Self { Self { identifier: value.identifier.0, molarweight: value.molarweight, model_record: value.model_record, association_sites: value.association_sites, } } } impl From<PureRecord<Value, Value>> for PyPureRecord { fn from(value: PureRecord<Value, Value>) -> Self { Self { identifier: PyIdentifier(value.identifier), molarweight: value.molarweight, model_record: value.model_record, association_sites: value.association_sites, } } } #[pymethods] impl PyPureRecord { #[new] #[pyo3(signature = (identifier, molarweight, **parameters))] fn new( py: Python, identifier: PyIdentifier, molarweight: f64, parameters: Option<&Bound<'_, PyDict>>, ) -> PyResult<Self> { let Some(parameters) = parameters else { return Err(PyErr::new::<PyValueError, _>( "No model parameters provided for PureRecord", )); }; parameters.set_item("identifier", pythonize(py, &identifier)?)?; parameters.set_item("molarweight", molarweight)?; Ok(depythonize(parameters)?) } #[getter] fn get_model_record<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> { pythonize(py, &self.model_record).map_err(PyErr::from) } #[getter] fn get_association_sites<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> { pythonize(py, &self.association_sites).map_err(PyErr::from) } pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> { pythonize(py, &self).map_err(PyErr::from) } #[staticmethod] pub fn from_json_str(s: &str) -> PyResult<Self> { Ok(serde_json::from_str(s).map_err(PyFeosError::from)?) } pub fn to_json_str(&self) -> PyResult<String> { Ok(serde_json::to_string(&self).map_err(PyFeosError::from)?) } /// Read a list of [PureRecord]s from a JSON file. /// /// Parameters /// ---------- /// substances : list[str] /// List of component identifiers. /// path : str /// Path to file containing the segment records. /// identifier_option : IdentifierOption /// The type of identifier used in the substance list. /// /// Returns /// ------- /// [SegmentRecord] #[staticmethod] pub fn from_json( substances: Vec<String>, file: &str, identifier_option: PyIdentifierOption, ) -> PyResult<Vec<Self>> { Ok( PureRecord::from_json(&substances, file, identifier_option.into()) .map_err(PyFeosError::from)? .into_iter() .map(|r| r.into()) .collect(), ) } fn __repr__(&self) -> String { PureRecord::from(self.clone()).to_string() } } /// Binary interaction parameters. #[derive(Serialize, Deserialize, Clone)] #[serde(from = "BinaryRecord<Identifier, Value, Value>")] #[serde(into = "BinaryRecord<Identifier, Value, Value>")] #[pyclass(name = "BinaryRecord")] pub struct PyBinaryRecord { #[pyo3(get)] pub id1: PyIdentifier, #[pyo3(get)] pub id2: PyIdentifier, pub model_record: Option<Value>, pub association_sites: Vec<BinaryAssociationRecord<Value>>, } impl From<PyBinaryRecord> for BinaryRecord<Identifier, Value, Value> { fn from(value: PyBinaryRecord) -> Self { Self { id1: value.id1.0, id2: value.id2.0, model_record: value.model_record, association_sites: value.association_sites, } } } impl From<BinaryRecord<Identifier, Value, Value>> for PyBinaryRecord { fn from(value: BinaryRecord<Identifier, Value, Value>) -> Self { Self { id1: PyIdentifier(value.id1), id2: PyIdentifier(value.id2), model_record: value.model_record, association_sites: value.association_sites, } } } #[pymethods] impl PyBinaryRecord { #[new] #[pyo3(signature = (id1, id2, **parameters))] fn new( py: Python, id1: PyIdentifier, id2: PyIdentifier, parameters: Option<&Bound<'_, PyDict>>, ) -> PyResult<Self> { let Some(parameters) = parameters else { return Err(PyFeosError::Error( "No model parameters provided for BinaryRecord".to_string(), ) .into()); }; parameters.set_item("id1", pythonize(py, &id1)?)?; parameters.set_item("id2", pythonize(py, &id2)?)?; Ok(depythonize(parameters)?) } #[getter] fn get_model_record<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> { pythonize(py, &self.model_record).map_err(PyErr::from) } pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> { pythonize(py, &self).map_err(PyErr::from) } #[staticmethod] pub fn from_json_str(s: &str) -> PyResult<Self> { Ok(serde_json::from_str(s).map_err(PyFeosError::from)?) } pub fn to_json_str(&self) -> PyResult<String> { Ok(serde_json::to_string(&self).map_err(PyFeosError::from)?) } fn __repr__(&self) -> String { BinaryRecord::from(self.clone()).to_string() } }
Rust
3D
feos-org/feos
py-feos/src/parameter/mod.rs
.rs
26,185
723
use crate::error::PyFeosError; use feos_core::parameter::*; use indexmap::IndexSet; use pyo3::prelude::*; use pyo3::types::PyDict; use pythonize::depythonize; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::fmt::Write; mod chemical_record; mod fragmentation; mod identifier; mod model_record; mod segment; // Export for wheel. pub(crate) use chemical_record::PyChemicalRecord; pub(crate) use fragmentation::PySmartsRecord; pub(crate) use identifier::{PyIdentifier, PyIdentifierOption}; pub(crate) use model_record::{PyBinaryRecord, PyPureRecord}; pub(crate) use segment::{PyBinarySegmentRecord, PySegmentRecord}; /// Set of parameters that fully characterizes a mixture. #[pyclass(name = "Parameters")] #[derive(Clone, Serialize, Deserialize)] pub struct PyParameters { pub pure_records: Vec<PureRecord<Value, Value>>, pub binary_records: Vec<BinaryRecord<usize, Value, Value>>, } impl PyParameters { pub fn try_convert<P, B, A>(self) -> PyResult<Parameters<P, B, A>> where for<'de> P: Deserialize<'de> + Clone, for<'de> B: Deserialize<'de> + Clone, for<'de> A: Deserialize<'de> + CombiningRule<P> + Clone, { let pure_records = self .pure_records .into_iter() .map(|r| Ok(serde_json::from_value(serde_json::to_value(r)?)?)) .collect::<Result<_, PyFeosError>>()?; let binary_records = self .binary_records .into_iter() .map(|r| Ok(serde_json::from_value(serde_json::to_value(r)?)?)) .collect::<Result<_, PyFeosError>>()?; Ok(Parameters::new(pure_records, binary_records).map_err(PyFeosError::from)?) } } #[pymethods] impl PyParameters { /// Creates parameters from records. /// /// Parameters /// ---------- /// pure_records : List[PureRecord] /// A list of pure component parameters. /// binary_records : List[BinaryRecord], optional, defaults to [] /// A list containing records for binary interactions. /// identifier_option : IdentifierOption, optional, defaults to IdentifierOption.Name /// Identifier that is used to search binary records. #[staticmethod] #[pyo3( signature = (pure_records, binary_records=vec![], identifier_option=PyIdentifierOption::Name), text_signature = "(pure_records, binary_records=[], identifier_option=IdentifierOption.Name)" )] fn from_records( pure_records: Vec<PyPureRecord>, binary_records: Vec<PyBinaryRecord>, identifier_option: PyIdentifierOption, ) -> PyResult<Self> { let pure_records: Vec<_> = pure_records.into_iter().map(PureRecord::from).collect(); let binary_records: Vec<_> = binary_records.into_iter().map(BinaryRecord::from).collect(); let binary_records = Parameters::binary_matrix_from_records( &pure_records, &binary_records, identifier_option.into(), ) .map_err(PyFeosError::from)?; Ok(Self { pure_records, binary_records, }) } /// Creates parameters for a pure component from a pure record. /// /// Parameters /// ---------- /// pure_record : PureRecord /// The pure component parameters. #[staticmethod] fn new_pure(pure_record: PyPureRecord) -> Self { Self { pure_records: vec![pure_record.into()], binary_records: vec![], } } /// Creates parameters for a binary system from pure records and an optional /// binary interaction parameter or binary interaction parameter record. /// /// Parameters /// ---------- /// pure_records : [PureRecord] /// A list of pure component parameters. /// binary_parameters : float or BinaryRecord, optional /// The binary interaction parameter or binary interaction record. #[staticmethod] #[pyo3(signature = (pure_records, **binary_parameters))] fn new_binary( pure_records: [PyPureRecord; 2], binary_parameters: Option<&Bound<'_, PyDict>>, ) -> PyResult<Self> { let pure_records = pure_records.into_iter().map(|r| r.into()).collect(); let binary_records = binary_parameters .iter() .map(|binary_parameters| { binary_parameters.set_item("id1", 0)?; binary_parameters.set_item("id2", 1)?; depythonize(binary_parameters) }) .collect::<Result<_, _>>()?; Ok(Self { pure_records, binary_records, }) } /// Creates parameters from json files. /// /// Parameters /// ---------- /// substances : List[str] /// The substances to search. /// pure_path : str /// Path to file containing pure substance parameters. /// binary_path : str, optional /// Path to file containing binary substance parameters. /// identifier_option : IdentifierOption, optional, defaults to IdentifierOption.Name /// Identifier that is used to search substance. #[staticmethod] #[pyo3( signature = (substances, pure_path, binary_path=None, identifier_option=PyIdentifierOption::Name), text_signature = "(substances, pure_path, binary_path=None, identifier_option)" )] fn from_json( substances: Vec<String>, pure_path: String, binary_path: Option<String>, identifier_option: PyIdentifierOption, ) -> PyResult<Self> { Self::from_multiple_json( vec![(substances, pure_path)], binary_path, identifier_option, ) } /// Creates parameters from json files. /// /// Parameters /// ---------- /// input : List[Tuple[List[str], str]] /// The substances to search and their respective parameter files. /// E.g. [(["methane", "propane"], "parameters/alkanes.json"), (["methanol"], "parameters/alcohols.json")] /// binary_path : str, optional /// Path to file containing binary substance parameters. /// identifier_option : IdentifierOption, optional, defaults to IdentifierOption.Name /// Identifier that is used to search substance. #[staticmethod] #[pyo3( signature = (input, binary_path=None, identifier_option=PyIdentifierOption::Name), text_signature = "(input, binary_path=None, identifier_option)" )] fn from_multiple_json( input: Vec<(Vec<String>, String)>, binary_path: Option<String>, identifier_option: PyIdentifierOption, ) -> PyResult<Self> { let pure_records = PureRecord::from_multiple_json(&input, identifier_option.into()) .map_err(PyFeosError::from)?; let binary_records: Vec<_> = binary_path .map_or_else(|| Ok(Vec::new()), BinaryRecord::from_json) .map_err(PyFeosError::from)?; let binary_records = Parameters::binary_matrix_from_records( &pure_records, &binary_records, identifier_option.into(), ) .map_err(PyFeosError::from)?; Ok(Self { pure_records, binary_records, }) } /// Generates JSON-formatted string for pure and binary records (if initialized). /// /// Parameters /// ---------- /// pretty : bool /// Whether to use pretty (True) or dense (False) formatting. Defaults to True. /// /// Returns /// ------- /// str : The JSON-formatted string. #[pyo3( signature = (pretty=true), text_signature = "(pretty=True)" )] fn to_json_str(&self, pretty: bool) -> PyResult<(String, Option<String>)> { let pr_json = if pretty { serde_json::to_string_pretty(&self.pure_records) } else { serde_json::to_string(&self.pure_records) } .map_err(PyFeosError::from)?; let br_json = (!self.binary_records.is_empty()) .then(|| { if pretty { serde_json::to_string_pretty(&self.binary_records) } else { serde_json::to_string(&self.binary_records) } }) .transpose() .map_err(PyFeosError::from)?; Ok((pr_json, br_json)) } #[getter] fn get_pure_records(&self) -> Vec<PyPureRecord> { self.pure_records .iter() .map(|pr| PyPureRecord::from(pr.clone())) .collect() } fn __repr__(&self) -> PyResult<String> { let (mut pr, br) = self.to_json_str(true)?; if let Some(br) = br { pr += "\n\n"; pr += &br; } Ok(pr) } fn _repr_markdown_(&self) -> String { // crate consistent list of component names let component_names: Vec<_> = self .pure_records .iter() .enumerate() .map(|(i, r)| { r.identifier .as_readable_str() .map_or_else(|| format!("Component {}", i + 1), |s| s.to_owned()) }) .collect(); let format_optional = |o: &mut String, val| { if let Some(val) = val { write!(o, "{val}|") } else { write!(o, "|") } .unwrap(); }; // collect all pure component parameters let params: IndexSet<_> = self .pure_records .iter() .flat_map(|r| r.model_record.as_object().unwrap().keys()) .collect(); // collect association parameters and count the association sites let [mut na, mut nb, mut nc] = [0.0; 3]; let mut assoc_params = IndexSet::new(); let mut site_names = false; for r in &self.pure_records { for s in &r.association_sites { site_names |= !s.id.is_empty(); na += s.na; nb += s.nb; nc += s.nc; if let Some(p) = &s.parameters { assoc_params.extend(p.as_object().unwrap().keys()); } } } let mut output = String::new(); let o = &mut output; // print pure component parameters in a table write!(o, "|component|molarweight|").unwrap(); for p in &params { write!(o, "{p}|").unwrap(); } if na + nb + nc > 0.0 { if site_names { write!(o, "sites|").unwrap(); } if na > 0.0 { write!(o, "na|").unwrap(); } if nb > 0.0 { write!(o, "nb|").unwrap(); } if nc > 0.0 { write!(o, "nc|").unwrap(); } for p in &assoc_params { write!(o, "{p}|").unwrap(); } } write!(o, "\n|-|-|").unwrap(); for _ in &params { write!(o, "-|").unwrap(); } if na + nb + nc > 0.0 { if site_names { write!(o, "-|").unwrap(); } if na > 0.0 { write!(o, "-|").unwrap(); } if nb > 0.0 { write!(o, "-|").unwrap(); } if nc > 0.0 { write!(o, "-|").unwrap(); } for _ in &assoc_params { write!(o, "-|").unwrap(); } } for (record, comp) in self.pure_records.iter().zip(&component_names) { write!(o, "\n|{}|{}|", comp, record.molarweight).unwrap(); let model_record = record.model_record.as_object().unwrap(); for &p in &params { format_optional(o, model_record.get(p)); } if !record.association_sites.is_empty() { let s = &record.association_sites[0]; if na + nb + nc > 0.0 { if site_names { write!(o, "{}|", s.id).unwrap(); } if na > 0.0 { if s.na > 0.0 { write!(o, "{}|", s.na).unwrap(); } else { write!(o, "|").unwrap(); } } if nb > 0.0 { if s.nb > 0.0 { write!(o, "{}|", s.nb).unwrap(); } else { write!(o, "|").unwrap(); } } if nc > 0.0 { if s.nc > 0.0 { write!(o, "{}|", s.nc).unwrap(); } else { write!(o, "|").unwrap(); } } for &p in &assoc_params { if let Some(par) = &s.parameters { let assoc_record = par.as_object().unwrap(); format_optional(o, assoc_record.get(p)); } } } } for s in record.association_sites.iter().skip(1) { write!(o, "\n|||").unwrap(); for &_ in &params { write!(o, "|").unwrap(); } if na + nb + nc > 0.0 { if site_names { write!(o, "{}|", s.id).unwrap(); } if na > 0.0 { write!(o, "{}|", s.na).unwrap(); } if nb > 0.0 { write!(o, "{}|", s.nb).unwrap(); } if nc > 0.0 { write!(o, "{}|", s.nc).unwrap(); } for &p in &assoc_params { if let Some(par) = &s.parameters { let assoc_record = par.as_object().unwrap(); format_optional(o, assoc_record.get(p)); } } } } } if !self.binary_records.is_empty() { // collect all binary interaction parameters let params: IndexSet<_> = self .binary_records .iter() .flat_map(|r| { r.model_record .iter() .flat_map(|r| r.as_object().unwrap().keys()) }) .collect(); // collect all binary association parameters let assoc_params: IndexSet<_> = self .binary_records .iter() .flat_map(|r| { r.association_sites .iter() .flat_map(|s| s.parameters.as_object().unwrap().keys()) }) .collect(); // print binary interaction parameters write!(o, "\n\n|component 1|component 2|").unwrap(); for p in &params { write!(o, "{p}|").unwrap(); } if !assoc_params.is_empty() { if site_names { write!(o, "site 1| site 2|").unwrap(); } for p in &assoc_params { write!(o, "{p}|").unwrap(); } } write!(o, "\n|-|-|").unwrap(); for _ in &params { write!(o, "-|").unwrap(); } if !assoc_params.is_empty() { if site_names { write!(o, "-|-|").unwrap(); } for _ in &assoc_params { write!(o, "-|").unwrap(); } } for r in &self.binary_records { write!(o, "\n|{}|", component_names[r.id1]).unwrap(); write!(o, "{}|", component_names[r.id2]).unwrap(); if let Some(m) = &r.model_record { let model_record = m.as_object().unwrap(); for &p in &params { format_optional(o, model_record.get(p)); } } if !r.association_sites.is_empty() { let s = &r.association_sites[0]; if site_names { write!(o, "{}|{}|", s.id1, s.id2).unwrap(); } for &p in &assoc_params { let assoc_record = s.parameters.as_object().unwrap(); format_optional(o, assoc_record.get(p)); } } for s in r.association_sites.iter().skip(1) { write!(o, "\n|||").unwrap(); for &_ in &params { write!(o, "|").unwrap(); } if site_names { write!(o, "{}|{}|", s.id1, s.id2).unwrap(); } for &p in &assoc_params { let assoc_record = s.parameters.as_object().unwrap(); format_optional(o, assoc_record.get(p)); } } } } output } } /// Combination of chemical information and segment parameters that is used to /// parametrize a group-contribution model. #[pyclass(name = "GcParameters")] #[derive(Clone, Serialize, Deserialize)] pub struct PyGcParameters { chemical_records: Vec<ChemicalRecord>, segment_records: Vec<SegmentRecord<Value, Value>>, binary_segment_records: Option<Vec<BinaryRecord<String, Value, Value>>>, } impl PyGcParameters { pub fn try_convert_homosegmented<P, B, A>(self) -> PyResult<Parameters<P, B, A>> where for<'de> P: Deserialize<'de> + Clone + FromSegments, for<'de> B: Deserialize<'de> + Clone + FromSegmentsBinary + Default, for<'de> A: Deserialize<'de> + Clone + CombiningRule<P>, { let segment_records: Vec<_> = self .segment_records .into_iter() .map(|r| Ok(serde_json::from_value(serde_json::to_value(r)?)?)) .collect::<Result<_, PyFeosError>>()?; let binary_segment_records = self .binary_segment_records .map(|bsr| { bsr.into_iter() .map(|r| Ok(serde_json::from_value(serde_json::to_value(r)?)?)) .collect::<Result<Vec<_>, PyFeosError>>() }) .transpose()?; Ok(Parameters::from_segments( self.chemical_records, &segment_records, binary_segment_records.as_deref(), ) .map_err(PyFeosError::from)?) } pub fn try_convert_heterosegmented<P, B, A, C: GroupCount + Default>( self, ) -> PyResult<GcParameters<P, B, A, (), C>> where for<'de> P: Deserialize<'de> + Clone, for<'de> B: Deserialize<'de> + Clone, for<'de> A: Deserialize<'de> + CombiningRule<P> + Clone, { let segment_records = self .segment_records .into_iter() .map(|r| Ok(serde_json::from_value(serde_json::to_value(r)?)?)) .collect::<Result<Vec<_>, PyFeosError>>()?; let binary_segment_records = self .binary_segment_records .map(|bsr| { bsr.into_iter() .map(|r| Ok(serde_json::from_value(serde_json::to_value(r)?)?)) .collect::<Result<Vec<_>, PyFeosError>>() }) .transpose()?; Ok(GcParameters::<P, B, A, (), C>::from_segments_hetero( self.chemical_records, &segment_records, binary_segment_records.as_deref(), ) .map_err(PyFeosError::from)?) } } #[pymethods] impl PyGcParameters { /// Creates parameters from segment records. /// /// Parameters /// ---------- /// chemical_records : [ChemicalRecord] /// A list of pure component chemical records. /// segment_records : [SegmentRecord] /// A list of records containing the parameters of /// all individual segments. /// binary_segment_records : [BinarySegmentRecord], optional /// A list of binary segment-segment parameters. #[staticmethod] #[pyo3(text_signature = "(chemical_records, segment_records, binary_segment_records=None)", signature = (chemical_records, segment_records, binary_segment_records=None))] fn from_segments( chemical_records: Vec<PyChemicalRecord>, segment_records: Vec<PySegmentRecord>, binary_segment_records: Option<Vec<PyBinarySegmentRecord>>, ) -> Self { let chemical_records = chemical_records.into_iter().map(|r| r.into()).collect(); let segment_records = segment_records.into_iter().map(|r| r.into()).collect(); let binary_segment_records = binary_segment_records.map(|bsr| bsr.into_iter().map(|r| r.into()).collect()); Self { chemical_records, segment_records, binary_segment_records, } } /// Creates parameters using segments from json file. /// /// Parameters /// ---------- /// substances : List[str] /// The substances to search. /// pure_path : str /// Path to file containing pure substance parameters. /// segments_path : str /// Path to file containing segment parameters. /// binary_path : str, optional /// Path to file containing binary segment-segment parameters. /// identifier_option : IdentifierOption, optional, defaults to IdentifierOption.Name /// Identifier that is used to search substance. #[staticmethod] #[pyo3( signature = (substances, pure_path, segments_path, binary_path=None, identifier_option=PyIdentifierOption::Name), text_signature = "(substances, pure_path, segments_path, binary_path=None, identifier_option=IdentiferOption.Name)" )] fn from_json_segments( substances: Vec<String>, pure_path: &str, segments_path: &str, binary_path: Option<&str>, identifier_option: PyIdentifierOption, ) -> PyResult<Self> { let chemical_records = PyChemicalRecord::from_json(substances, pure_path, identifier_option)?; let segment_records = PySegmentRecord::from_json(segments_path)?; let binary_segment_records = binary_path .as_ref() .map(|p| { BinarySegmentRecord::from_json(p as &str) .map(|brs| brs.into_iter().map(|r| r.into()).collect()) }) .transpose() .map_err(PyFeosError::from)?; Ok(Self::from_segments( chemical_records, segment_records, binary_segment_records, )) } /// Creates parameters from SMILES and segment records. /// /// Requires an installation of rdkit. /// /// Parameters /// ---------- /// identifier : [str | Identifier] /// A list of SMILES codes or [Identifier] objects. /// smarts_records : [SmartsRecord] /// A list of records containing the SMARTS codes used /// to fragment the molecule. /// segment_records : [SegmentRecord] /// A list of records containing the parameters of /// all individual segments. /// binary_segment_records : [BinarySegmentRecord], optional /// A list of binary segment-segment parameters. #[staticmethod] #[pyo3( text_signature = "(identifier, smarts_records, segment_records, binary_segment_records=None)" )] #[pyo3(signature = (identifier, smarts_records, segment_records, binary_segment_records=None))] fn from_smiles( identifier: Vec<Bound<'_, PyAny>>, smarts_records: Vec<PySmartsRecord>, segment_records: Vec<PySegmentRecord>, binary_segment_records: Option<Vec<PyBinarySegmentRecord>>, ) -> PyResult<Self> { let chemical_records: Vec<_> = identifier .into_iter() .map(|i| PyChemicalRecord::from_smiles(&i, smarts_records.clone())) .collect::<PyResult<_>>()?; Ok(Self::from_segments( chemical_records, segment_records, binary_segment_records, )) } /// Creates parameters from SMILES using segments from json file. /// /// Requires an installation of rdkit. /// /// Parameters /// ---------- /// identifier : list[str | Identifier] /// A list of SMILES codes or [Identifier] objects. /// smarts_path : str /// Path to file containing SMARTS records. /// segments_path : str /// Path to file containing segment parameters. /// binary_path : str, optional /// Path to file containing binary segment-segment parameters. #[staticmethod] #[pyo3( signature = (identifier, smarts_path, segments_path, binary_path=None), text_signature = "(identifier, smarts_path, segments_path, binary_path=None)" )] fn from_json_smiles( identifier: Vec<Bound<'_, PyAny>>, smarts_path: &str, segments_path: &str, binary_path: Option<&str>, ) -> PyResult<Self> { let smarts_records = PySmartsRecord::from_json(smarts_path)?; let segment_records = PySegmentRecord::from_json(segments_path)?; let binary_segment_records = binary_path .as_ref() .map(|p| { BinarySegmentRecord::from_json(p as &str) .map(|brs| brs.into_iter().map(|r| r.into()).collect()) }) .transpose() .map_err(PyFeosError::from)?; Self::from_smiles( identifier, smarts_records, segment_records, binary_segment_records, ) } }
Rust
3D
feos-org/feos
py-feos/src/parameter/chemical_record.rs
.rs
3,689
121
use super::fragmentation::{fragment_molecule, PySmartsRecord}; use super::identifier::{PyIdentifier, PyIdentifierOption}; use crate::error::PyFeosError; use feos_core::parameter::{ChemicalRecord, Identifier}; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use serde::{Deserialize, Serialize}; /// Information about segments and bonds of a molecule. #[pyclass(name = "ChemicalRecord")] #[derive(Deserialize, Serialize, Debug, Clone)] pub(crate) struct PyChemicalRecord(ChemicalRecord); impl From<ChemicalRecord> for PyChemicalRecord { fn from(value: ChemicalRecord) -> Self { Self(value) } } impl From<PyChemicalRecord> for ChemicalRecord { fn from(value: PyChemicalRecord) -> Self { value.0 } } #[pymethods] impl PyChemicalRecord { #[new] #[pyo3(text_signature = "(identifier, segments, bonds=None)", signature = (identifier, segments, bonds=None))] fn py_new( identifier: PyIdentifier, segments: Vec<String>, bonds: Option<Vec<[usize; 2]>>, ) -> Self { Self(ChemicalRecord::new(identifier.0, segments, bonds)) } fn __repr__(&self) -> PyResult<String> { Ok(self.0.to_string()) } #[getter] fn get_identifier(&self) -> PyIdentifier { PyIdentifier(self.0.identifier.clone()) } #[getter] fn get_segments(&self) -> Vec<String> { self.0.segments.clone() } #[getter] fn get_bonds(&self) -> Vec<[usize; 2]> { self.0.bonds.clone() } /// Read a list of [ChemicalRecord]s from a JSON file. /// /// Parameters /// ---------- /// substances : list[str] /// List of component identifiers. /// path : str /// Path to file containing the segment records. /// identifier_option : IdentifierOption /// The type of identifier used in the substance list. /// /// Returns /// ------- /// [SegmentRecord] #[staticmethod] pub fn from_json( substances: Vec<String>, file: &str, identifier_option: PyIdentifierOption, ) -> PyResult<Vec<Self>> { Ok( ChemicalRecord::from_json(&substances, file, identifier_option.into()) .map_err(PyFeosError::from)? .into_iter() .map(|r| r.into()) .collect(), ) } #[staticmethod] pub fn from_smiles( identifier: &Bound<'_, PyAny>, smarts: Vec<PySmartsRecord>, ) -> PyResult<Self> { let py = identifier.py(); let identifier = if let Ok(smiles) = identifier.extract::<String>() { Identifier::new(None, None, None, Some(&smiles), None, None) } else if let Ok(identifier) = identifier.extract::<PyIdentifier>() { identifier.0 } else { return Err(PyErr::new::<PyValueError, _>( "`identifier` must be a SMILES code or `Identifier` object.".to_string(), )); }; let smiles = identifier .smiles .as_ref() .expect("Missing SMILES in `Identifier`"); let (segments, bonds) = fragment_molecule(py, smiles, smarts)?; let segments = segments.into_iter().map(|s| s.to_owned()).collect(); Ok(Self(ChemicalRecord::new(identifier, segments, Some(bonds)))) } /// Creates record from json string. #[staticmethod] fn from_json_str(json: &str) -> PyResult<Self> { Ok(serde_json::from_str(json).map_err(PyFeosError::from)?) } /// Creates a json string from record. fn to_json_str(&self) -> PyResult<String> { Ok(serde_json::to_string(&self).map_err(PyFeosError::from)?) } }
Rust
3D
feos-org/feos
py-feos/src/parameter/fragmentation.rs
.rs
5,981
184
use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; use std::fs::File; use std::io::BufReader; use crate::error::PyFeosError; /// SMARTS code, required to fragmentize molecules into segments. #[derive(Clone, Serialize, Deserialize)] #[pyclass(name = "SmartsRecord")] pub(crate) struct PySmartsRecord { group: String, smarts: String, #[serde(skip_serializing_if = "Option::is_none")] max: Option<usize>, } #[pymethods] impl PySmartsRecord { #[new] #[pyo3(text_signature = "(group, smarts, max=None)", signature = (group, smarts, max=None))] fn new(group: String, smarts: String, max: Option<usize>) -> Self { Self { group, smarts, max } } fn __repr__(&self) -> PyResult<String> { Ok(self.to_string()) } /// Creates record from json string. #[staticmethod] fn from_json_str(json: &str) -> PyResult<Self> { Ok(serde_json::from_str(json).map_err(PyFeosError::from)?) } /// Creates a json string from record. fn to_json_str(&self) -> PyResult<String> { Ok(serde_json::to_string(&self).map_err(PyFeosError::from)?) } /// Read a list of [SmartsRecord]s from a JSON file. /// /// Parameters /// ---------- /// path : str /// Path to file containing the SMARTS records. /// /// Returns /// ------- /// [SmartsRecord] #[staticmethod] #[pyo3(text_signature = "(path)")] pub fn from_json(path: &str) -> PyResult<Vec<Self>> { Ok( serde_json::from_reader(BufReader::new(File::open(path)?)) .map_err(PyFeosError::from)?, ) } } impl std::fmt::Display for PySmartsRecord { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, "SmartsRecord(group={}, smarts={}", self.group, self.smarts )?; if let Some(max) = self.max { write!(f, ", max={max}")?; } write!(f, ")") } } pub(crate) fn fragment_molecule( py: Python<'_>, smiles: &str, smarts: Vec<PySmartsRecord>, ) -> PyResult<(Vec<String>, Vec<[usize; 2]>)> { let chem = py.import("rdkit.Chem")?; let mol = chem.call_method1("MolFromSmiles", (smiles,))?; let atoms = mol.call_method0("GetNumHeavyAtoms")?.extract::<usize>()?; // find the location of all fragment using the given smarts let mut matches: HashMap<_, _> = smarts .into_iter() .map(|s| { let m = chem.call_method1("MolFromSmarts", (s.smarts,))?; let matches = mol .call_method1("GetSubstructMatches", (m,))? .extract::<Vec<Bound<'_, PyAny>>>()?; let mut matches: Vec<_> = matches .into_iter() .map(|m| m.extract::<Vec<usize>>()) .collect::<PyResult<_>>()?; // Instead of just throwing an error at this point, just try to continue with the first max // occurrences. For some cases (the ethers) this just means that the symetry of C-O-C is broken. // If a necessary segment is eliminated the error will be thrown later. if let Some(max) = s.max && matches.len() > max { matches = matches[..max].to_vec(); } Ok((s.group, matches)) }) .collect::<PyResult<_>>()?; // Filter small segments that are covered by larger segments (also only required by the weird // ether groups of Sauer et al.) let large_segments: HashSet<_> = matches .values() .flatten() .filter(|m| m.len() > 1) .flatten() .copied() .collect(); matches .iter_mut() .for_each(|(_, m)| m.retain(|m| !(m.len() == 1 && large_segments.contains(&m[0])))); let bonds = mol.call_method0("GetBonds")?; let builtins = py.import("builtins")?; let bonds = builtins .call_method1("list", (bonds,))? .extract::<Vec<Bound<'_, PyAny>>>()?; let bonds: Vec<_> = bonds .into_iter() .map(|b| { Ok([ b.call_method0("GetBeginAtomIdx")?.extract::<usize>()?, b.call_method0("GetEndAtomIdx")?.extract::<usize>()?, ]) }) .collect::<PyResult<_>>()?; convert_matches(atoms, matches, bonds) } pub(crate) fn convert_matches( atoms: usize, matches: HashMap<String, Vec<Vec<usize>>>, bonds: Vec<[usize; 2]>, ) -> PyResult<(Vec<String>, Vec<[usize; 2]>)> { // check if every atom is captured by exactly one fragment let identified_atoms: Vec<_> = matches .values() .flat_map(|v| v.iter().flat_map(|l| l.iter())) .collect(); let unique_atoms: HashSet<_> = identified_atoms.iter().collect(); if unique_atoms.len() == identified_atoms.len() && unique_atoms.len() == atoms { // Translate the atom indices to segment indices (some segments contain more than one atom) let mut segment_indices: Vec<_> = matches .into_iter() .flat_map(|(group, l)| { l.into_iter().map(move |mut k| { k.sort(); (k, group.clone()) }) }) .collect(); segment_indices.sort(); let segment_map: Vec<_> = segment_indices .iter() .enumerate() .flat_map(|(i, (k, _))| k.iter().map(move |_| i)) .collect(); let segments: Vec<_> = segment_indices.into_iter().map(|(_, g)| g).collect(); let bonds: Vec<_> = bonds .into_iter() .map(|[a, b]| [segment_map[a], segment_map[b]]) .filter(|[a, b]| a != b) .collect(); return Ok((segments, bonds)); } Err(PyErr::new::<PyValueError, _>( "Molecule cannot be built from groups!", )) }
Rust
3D
feos-org/feos
py-feos/src/parameter/identifier.rs
.rs
2,574
104
use feos_core::parameter::{Identifier, IdentifierOption}; use pyo3::prelude::*; use serde::{Deserialize, Serialize}; /// Identifier to match on while reading parameters from files. #[pyclass(name = "IdentifierOption", eq, eq_int)] #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)] pub enum PyIdentifierOption { Cas, Name, IupacName, Smiles, Inchi, Formula, } impl From<IdentifierOption> for PyIdentifierOption { fn from(value: IdentifierOption) -> Self { use IdentifierOption::*; match value { Cas => Self::Cas, Name => Self::Name, IupacName => Self::IupacName, Smiles => Self::Smiles, Inchi => Self::Inchi, Formula => Self::Formula, } } } impl From<PyIdentifierOption> for IdentifierOption { fn from(value: PyIdentifierOption) -> Self { use PyIdentifierOption::*; match value { Cas => Self::Cas, Name => Self::Name, IupacName => Self::IupacName, Smiles => Self::Smiles, Inchi => Self::Inchi, Formula => Self::Formula, } } } /// Different common identifiers for chemicals. #[pyclass(name = "Identifier")] #[derive(Debug, Clone, Serialize, Deserialize)] pub struct PyIdentifier(pub Identifier); #[pymethods] impl PyIdentifier { #[new] #[pyo3( text_signature = "(cas=None, name=None, iupac_name=None, smiles=None, inchi=None, formula=None)", signature = (cas=None, name=None, iupac_name=None, smiles=None, inchi=None, formula=None) )] fn py_new( cas: Option<&str>, name: Option<&str>, iupac_name: Option<&str>, smiles: Option<&str>, inchi: Option<&str>, formula: Option<&str>, ) -> Self { Self(Identifier::new( cas, name, iupac_name, smiles, inchi, formula, )) } #[getter] fn get_cas(&self) -> Option<String> { self.0.cas.clone() } #[getter] fn get_name(&self) -> Option<String> { self.0.name.clone() } #[getter] fn get_iupac_name(&self) -> Option<String> { self.0.iupac_name.clone() } #[getter] fn get_smiles(&self) -> Option<String> { self.0.smiles.clone() } #[getter] fn get_inchi(&self) -> Option<String> { self.0.inchi.clone() } #[getter] fn get_formula(&self) -> Option<String> { self.0.formula.clone() } fn __repr__(&self) -> String { self.0.to_string() } }
Rust
3D
feos-org/feos
py-feos/src/parameter/segment.rs
.rs
5,591
186
use crate::error::PyFeosError; use feos_core::parameter::*; use pyo3::prelude::*; use pyo3::types::PyDict; use pythonize::{depythonize, pythonize}; use serde::{Deserialize, Serialize}; use serde_json::Value; /// Parameters describing individual segments. #[derive(Serialize, Deserialize, Clone)] #[serde(from = "SegmentRecord<Value, Value>")] #[serde(into = "SegmentRecord<Value, Value>")] #[pyclass(name = "SegmentRecord")] pub struct PySegmentRecord { #[pyo3(get)] identifier: String, #[pyo3(get)] molarweight: f64, model_record: Value, association_sites: Vec<AssociationRecord<Value>>, } impl From<PySegmentRecord> for SegmentRecord<Value, Value> { fn from(value: PySegmentRecord) -> Self { Self { identifier: value.identifier, molarweight: value.molarweight, model_record: value.model_record, association_sites: value.association_sites, } } } impl From<SegmentRecord<Value, Value>> for PySegmentRecord { fn from(value: SegmentRecord<Value, Value>) -> Self { Self { identifier: value.identifier, molarweight: value.molarweight, model_record: value.model_record, association_sites: value.association_sites, } } } #[pymethods] impl PySegmentRecord { #[new] #[pyo3(signature = (identifier, molarweight, **parameters))] fn new( identifier: String, molarweight: f64, parameters: Option<&Bound<'_, PyDict>>, ) -> PyResult<Self> { let Some(parameters) = parameters else { return Err(PyFeosError::Error( "No model parameters provided for SegmentRecord".to_string(), ) .into()); }; parameters.set_item("identifier", identifier)?; parameters.set_item("molarweight", molarweight)?; Ok(depythonize(parameters)?) } #[getter] fn get_model_record<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> { pythonize(py, &self.model_record).map_err(PyErr::from) } #[getter] fn get_association_sites<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> { pythonize(py, &self.association_sites).map_err(PyErr::from) } pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> { pythonize(py, &self).map_err(PyErr::from) } #[staticmethod] pub fn from_json_str(s: &str) -> PyResult<Self> { Ok(serde_json::from_str(s).map_err(PyFeosError::from)?) } pub fn to_json_str(&self) -> PyResult<String> { Ok(serde_json::to_string(&self).map_err(PyFeosError::from)?) } /// Read a list of [SegmentRecord]s from a JSON file. /// /// Parameters /// ---------- /// path : str /// Path to file containing the segment records. /// /// Returns /// ------- /// [SegmentRecord] #[staticmethod] pub fn from_json(path: &str) -> PyResult<Vec<Self>> { Ok(SegmentRecord::from_json(path) .map_err(PyFeosError::from)? .into_iter() .map(|r| r.into()) .collect()) } fn __repr__(&self) -> String { SegmentRecord::from(self.clone()).to_string() } } /// Binary segment/segment interaction parameters. #[derive(Serialize, Deserialize, Clone)] #[serde(from = "BinaryRecord<String, Value, Value>")] #[serde(into = "BinaryRecord<String, Value, Value>")] #[pyclass(name = "BinarySegmentRecord")] pub struct PyBinarySegmentRecord { #[pyo3(get)] pub id1: String, #[pyo3(get)] pub id2: String, pub model_record: Option<Value>, pub association_sites: Vec<BinaryAssociationRecord<Value>>, } impl From<PyBinarySegmentRecord> for BinaryRecord<String, Value, Value> { fn from(value: PyBinarySegmentRecord) -> Self { Self { id1: value.id1, id2: value.id2, model_record: value.model_record, association_sites: value.association_sites, } } } impl From<BinaryRecord<String, Value, Value>> for PyBinarySegmentRecord { fn from(value: BinaryRecord<String, Value, Value>) -> Self { Self { id1: value.id1, id2: value.id2, model_record: value.model_record, association_sites: value.association_sites, } } } #[pymethods] impl PyBinarySegmentRecord { #[new] #[pyo3(signature = (id1, id2, **parameters))] fn new(id1: String, id2: String, parameters: Option<&Bound<'_, PyDict>>) -> PyResult<Self> { let Some(parameters) = parameters else { return Err(PyFeosError::Error( "No model parameters provided for BinaryRecord".to_string(), ) .into()); }; parameters.set_item("id1", id1)?; parameters.set_item("id2", id2)?; Ok(depythonize(parameters)?) } #[getter] fn get_model_record<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> { pythonize(py, &self.model_record).map_err(PyErr::from) } pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> { pythonize(py, &self).map_err(PyErr::from) } #[staticmethod] pub fn from_json_str(s: &str) -> PyResult<Self> { Ok(serde_json::from_str(s).map_err(PyFeosError::from)?) } pub fn to_json_str(&self) -> PyResult<String> { Ok(serde_json::to_string(&self).map_err(PyFeosError::from)?) } fn __repr__(&self) -> String { BinaryRecord::from(self.clone()).to_string() } }
Rust
3D
feos-org/feos
py-feos/src/dft/mod.rs
.rs
4,785
138
use crate::eos::{parse_molefracs, PyEquationOfState}; use crate::ideal_gas::IdealGasModel; use crate::residual::ResidualModel; use feos::hard_sphere::{FMTFunctional, FMTVersion}; use feos_core::{EquationOfState, ResidualDyn}; use feos_dft::Geometry; use numpy::PyReadonlyArray1; use pyo3::prelude::*; use pyo3::pyclass; use std::sync::Arc; mod adsorption; mod interface; mod profile; mod solvation; mod solver; pub(crate) use adsorption::{ PyAdsorption1D, PyAdsorption3D, PyExternalPotential, PyPore1D, PyPore2D, PyPore3D, }; pub(crate) use interface::{PyPlanarInterface, PySurfaceTensionDiagram}; pub(crate) use solvation::{PyPairCorrelation, PySolvationProfile}; pub(crate) use solver::{PyDFTSolver, PyDFTSolverLog}; /// Geometries of individual axes. #[derive(Clone, Copy, PartialEq)] #[pyclass(name = "Geometry", eq, eq_int)] pub enum PyGeometry { Cartesian, Cylindrical, Spherical, } impl From<Geometry> for PyGeometry { fn from(geometry: Geometry) -> Self { match geometry { Geometry::Cartesian => PyGeometry::Cartesian, Geometry::Cylindrical => PyGeometry::Cylindrical, Geometry::Spherical => PyGeometry::Spherical, } } } impl From<PyGeometry> for Geometry { fn from(geometry: PyGeometry) -> Self { match geometry { PyGeometry::Cartesian => Geometry::Cartesian, PyGeometry::Cylindrical => Geometry::Cylindrical, PyGeometry::Spherical => Geometry::Spherical, } } } /// Different versions of fundamental measure theory. #[derive(Clone, Copy, PartialEq)] #[pyclass(name = "FMTVersion", eq, eq_int)] pub enum PyFMTVersion { /// White Bear ([Roth et al., 2002](https://doi.org/10.1088/0953-8984/14/46/313)) or modified ([Yu and Wu, 2002](https://doi.org/10.1063/1.1520530)) fundamental measure theory WhiteBear, /// Scalar fundamental measure theory by [Kierlik and Rosinberg, 1990](https://doi.org/10.1103/PhysRevA.42.3382) KierlikRosinberg, /// Anti-symmetric White Bear fundamental measure theory ([Rosenfeld et al., 1997](https://doi.org/10.1103/PhysRevE.55.4245)) and SI of ([Kessler et al., 2021](https://doi.org/10.1016/j.micromeso.2021.111263)) AntiSymWhiteBear, } impl From<FMTVersion> for PyFMTVersion { fn from(fmt_version: FMTVersion) -> Self { match fmt_version { FMTVersion::WhiteBear => PyFMTVersion::WhiteBear, FMTVersion::KierlikRosinberg => PyFMTVersion::KierlikRosinberg, FMTVersion::AntiSymWhiteBear => PyFMTVersion::AntiSymWhiteBear, } } } impl From<PyFMTVersion> for FMTVersion { fn from(fmt_version: PyFMTVersion) -> Self { match fmt_version { PyFMTVersion::WhiteBear => FMTVersion::WhiteBear, PyFMTVersion::KierlikRosinberg => FMTVersion::KierlikRosinberg, PyFMTVersion::AntiSymWhiteBear => FMTVersion::AntiSymWhiteBear, } } } /// Collection of Helmholtz energy functionals. #[pyclass(name = "HelmholtzEnergyFunctional")] #[derive(Clone)] pub struct PyHelmholtzEnergyFunctional; #[pymethods] impl PyHelmholtzEnergyFunctional { /// Helmholtz energy functional for hard sphere systems. /// /// Parameters /// ---------- /// sigma : numpy.ndarray[float] /// The diameters of the hard spheres in Angstrom. /// fmt_version : FMTVersion /// The specific variant of the FMT term. /// /// Returns /// ------- /// HelmholtzEnergyFunctional #[staticmethod] fn fmt(sigma: PyReadonlyArray1<f64>, fmt_version: PyFMTVersion) -> PyResult<PyEquationOfState> { let func = ResidualModel::FmtFunctional(FMTFunctional::new( parse_molefracs(Some(sigma)).unwrap(), fmt_version.into(), )); let ideal_gas = vec![IdealGasModel::NoModel; func.components()]; Ok(PyEquationOfState(Arc::new(EquationOfState::new( ideal_gas, func, )))) } } // #[pymodule] // pub fn dft(m: &Bound<'_, PyModule>) -> PyResult<()> { // m.add_class::<PyFMTVersion>()?; // m.add_class::<PyHelmholtzEnergyFunctional>()?; // m.add_class::<PyPlanarInterface>()?; // m.add_class::<PyGeometry>()?; // m.add_class::<PyPore1D>()?; // m.add_class::<PyPore2D>()?; // m.add_class::<PyPore3D>()?; // m.add_class::<PyPairCorrelation>()?; // m.add_class::<PyExternalPotential>()?; // m.add_class::<PyAdsorption1D>()?; // m.add_class::<PyAdsorption3D>()?; // m.add_class::<PySurfaceTensionDiagram>()?; // m.add_class::<PyDFTSolver>()?; // m.add_class::<PySolvationProfile>()?; // Ok(()) // }
Rust
3D
feos-org/feos
py-feos/src/dft/solver.rs
.rs
5,027
184
use crate::PyVerbosity; use feos_dft::{DFTSolver, DFTSolverLog}; use ndarray::Array1; use numpy::{PyArray1, ToPyArray}; use pyo3::prelude::*; use quantity::Time; /// Settings for the DFT solver. /// /// Parameters /// ---------- /// verbosity: Verbosity, optional /// The verbosity level of the solver. /// Defaults to Verbosity.None. /// /// Returns /// ------- /// DFTSolver #[pyclass(name = "DFTSolver")] #[derive(Clone)] pub struct PyDFTSolver(pub DFTSolver); #[pymethods] impl PyDFTSolver { #[new] #[pyo3(text_signature = "(verbosity=None)", signature = (verbosity=None))] fn new(verbosity: Option<PyVerbosity>) -> Self { Self(DFTSolver::new(verbosity.map(|v| v.into()))) } /// The default solver. /// /// Returns /// ------- /// DFTSolver #[classattr] fn default() -> Self { Self(DFTSolver::default()) } /// Add a picard iteration to the solver object. /// /// Parameters /// ---------- /// log: bool, optional /// Iterate the logarithm of the density profile. /// Defaults to False. /// max_iter: int, optional /// The maximum number of iterations. /// Defaults to 500. /// tol: float, optional /// The tolerance. /// Defaults to 1e-11. /// damping_coefficient: float, optional /// Constant damping coefficient. /// If no damping coefficient is provided, a line /// search is used to determine the step size. /// /// Returns /// ------- /// DFTSolver #[pyo3(text_signature = "($self, log=None, max_iter=None, tol=None, damping_coefficient=None)")] #[pyo3(signature = (log=None, max_iter=None, tol=None, damping_coefficient=None))] fn picard_iteration( &self, log: Option<bool>, max_iter: Option<usize>, tol: Option<f64>, damping_coefficient: Option<f64>, ) -> Self { Self( self.0 .clone() .picard_iteration(log, max_iter, tol, damping_coefficient), ) } /// Add Anderson mixing to the solver object. /// /// Parameters /// ---------- /// log: bool, optional /// Iterate the logarithm of the density profile /// Defaults to False. /// max_iter: int, optional /// The maximum number of iterations. /// Defaults to 150. /// tol: float, optional /// The tolerance. /// Defaults to 1e-11. /// damping_coefficient: float, optional /// The damping coefficient. /// Defaults to 0.15. /// mmax: int, optional /// The maximum number of old solutions that are used. /// Defaults to 100. /// /// Returns /// ------- /// DFTSolver #[pyo3( text_signature = "($self, log=None, max_iter=None, tol=None, damping_coefficient=None, mmax=None)", signature = (log=None, max_iter=None, tol=None, damping_coefficient=None, mmax=None) )] fn anderson_mixing( &self, log: Option<bool>, max_iter: Option<usize>, tol: Option<f64>, damping_coefficient: Option<f64>, mmax: Option<usize>, ) -> Self { Self( self.0 .clone() .anderson_mixing(log, max_iter, tol, damping_coefficient, mmax), ) } /// Add Newton solver to the solver object. /// /// Parameters /// ---------- /// log: bool, optional /// Iterate the logarithm of the density profile /// Defaults to False. /// max_iter: int, optional /// The maximum number of iterations. /// Defaults to 50. /// max_iter_gmres: int, optional /// The maximum number of iterations for the GMRES solver. /// Defaults to 200. /// tol: float, optional /// The tolerance. /// Defaults to 1e-11. /// /// Returns /// ------- /// DFTSolver #[pyo3( text_signature = "($self, log=None, max_iter=None, max_iter_gmres=None, tol=None)", signature = (log=None, max_iter=None, max_iter_gmres=None, tol=None) )] fn newton( &self, log: Option<bool>, max_iter: Option<usize>, max_iter_gmres: Option<usize>, tol: Option<f64>, ) -> Self { Self(self.0.clone().newton(log, max_iter, max_iter_gmres, tol)) } fn _repr_markdown_(&self) -> String { self.0._repr_markdown_() } fn __repr__(&self) -> PyResult<String> { Ok(self.0.to_string()) } } #[pyclass(name = "DFTSolverLog")] #[derive(Clone)] pub struct PyDFTSolverLog(pub DFTSolverLog); #[pymethods] impl PyDFTSolverLog { #[getter] fn get_residual<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1<f64>> { self.0.residual().to_pyarray(py) } #[getter] fn get_time(&self) -> Time<Array1<f64>> { self.0.time() } #[getter] fn get_solver(&self) -> Vec<&'static str> { self.0.solver().to_vec() } }
Rust
3D
feos-org/feos
py-feos/src/dft/solvation.rs
.rs
4,416
143
use super::profile::{impl_1d_profile, impl_3d_profile, impl_profile}; use super::{PyDFTSolver, PyDFTSolverLog}; use crate::residual::ResidualModel; use crate::state::{PyContributions, PyState}; use crate::{error::PyFeosError, ideal_gas::IdealGasModel}; use feos_core::{EquationOfState, ReferenceSystem}; use feos_dft::solvation::{PairCorrelation, SolvationProfile}; use nalgebra::{DMatrix, DVector}; use ndarray::*; use numpy::*; use pyo3::*; use quantity::*; use std::sync::Arc; /// Density profile and properties of a solute in an inhomogeneous fluid. /// /// Parameters /// ---------- /// bulk : State /// The bulk state of the surrounding solvent. /// n_grid : [int, int, int] /// The number of grid points in x-, y- and z-direction. /// coordinates : SIArray2 /// The cartesian coordinates of all N interaction sites. /// sigma : numpy.ndarray[float] /// The size parameters of all N interaction sites in units of Angstrom. /// epsilon_k : numpy.ndarray[float] /// The reduced energy parameters epsilon / kB of all N interaction sites in units of Kelvin. /// system_size : [SINumber, SINumber, SINumber], optional /// The box length in x-, y- and z-direction (default: [40.0 * ANGSTROM, 40.0 * ANGSTROM, 40.0 * ANGSTROM]). /// cutoff_radius : SINumber, optional /// The cut-off radius up to which the dispersive solute-solvent interactions are evaluated (default: 14.0 * ANGSTROM). /// potential_cutoff: float, optional /// Maximum value for the external potential. /// /// Returns /// ------- /// SolvationProfile /// #[pyclass(name = "SolvationProfile")] pub struct PySolvationProfile( SolvationProfile<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>, ); impl_3d_profile!(PySolvationProfile, get_x, get_y, get_z); #[pymethods] impl PySolvationProfile { #[new] #[pyo3( text_signature = "(bulk, n_grid, coordinates, sigma, epsilon_k, system_size=None, cutoff_radius=None, potential_cutoff=None)" )] #[pyo3(signature = (bulk, n_grid, coordinates, sigma, epsilon_k, system_size=None, cutoff_radius=None, potential_cutoff=None))] #[expect(clippy::too_many_arguments)] fn new<'py>( bulk: &PyState, n_grid: [usize; 3], coordinates: Length<Array2<f64>>, sigma: &Bound<'py, PyArray1<f64>>, epsilon_k: &Bound<'py, PyArray1<f64>>, system_size: Option<[Length; 3]>, cutoff_radius: Option<Length>, potential_cutoff: Option<f64>, ) -> PyResult<Self> { Ok(Self( SolvationProfile::new( &bulk.0, n_grid, coordinates, sigma.to_owned_array(), epsilon_k.to_owned_array(), system_size, cutoff_radius, potential_cutoff, ) .map_err(PyFeosError::from)?, )) } #[getter] fn get_grand_potential(&self) -> Option<Energy> { self.0.grand_potential } #[getter] fn get_solvation_free_energy(&self) -> Option<MolarEnergy> { self.0.solvation_free_energy } } /// Density profile and properties of a test particle system. /// /// Parameters /// ---------- /// bulk : State /// The bulk state in equilibrium with the profile. /// test_particle : int /// The index of the test particle. /// n_grid : int /// The number of grid points. /// width: SINumber /// The width of the system. /// /// Returns /// ------- /// PairCorrelation /// #[pyclass(name = "PairCorrelation")] pub struct PyPairCorrelation( PairCorrelation<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>, ); impl_1d_profile!(PyPairCorrelation, [get_r]); #[pymethods] impl PyPairCorrelation { #[new] fn new(bulk: PyState, test_particle: usize, n_grid: usize, width: Length) -> Self { Self(PairCorrelation::new(&bulk.0, test_particle, n_grid, width)) } #[getter] fn get_pair_correlation_function<'py>( &self, py: Python<'py>, ) -> Option<Bound<'py, PyArray2<f64>>> { self.0 .pair_correlation_function .as_ref() .map(|g| g.view().to_pyarray(py)) } #[getter] fn get_self_solvation_free_energy(&self) -> Option<Energy> { self.0.self_solvation_free_energy } #[getter] fn get_structure_factor(&self) -> Option<f64> { self.0.structure_factor } }
Rust
3D
feos-org/feos
py-feos/src/dft/profile.rs
.rs
9,507
274
macro_rules! impl_profile { ($struct:ident, $arr:ident, $arr2:ident, $si_arr:ident, $si_arr2:ident, $py_arr2:ident, [$([$ind:expr, $ax:ident]),+]$(, $si_arr3:ident)?) => { #[pymethods] impl $struct { /// Calculate the residual for the given profile. /// /// Parameters /// ---------- /// log: bool, optional /// calculate the logarithmic residual (default: False). /// /// Returns /// ------- /// (numpy.ndarray[float], numpy.ndarray[float]) /// #[pyo3(signature = (log=false), text_signature = "($self, log=False)")] fn residual<'py>( &self, log: bool, py: Python<'py>, ) -> PyResult<(Bound<'py, $arr2<f64>>, Bound<'py, PyArray1<f64>>, f64)> { let (res_rho, res_mu, res_norm) = self.0.profile.residual(log).map_err(PyFeosError::from)?; Ok((res_rho.view().to_pyarray(py), res_mu.view().to_pyarray(py), res_norm)) } /// Solve the profile in-place. A non-default solver can be provided /// optionally. /// /// Parameters /// ---------- /// solver : DFTSolver, optional /// The solver used to solve the profile. /// debug: bool, optional /// If True, do not check for convergence. /// /// Returns /// ------- /// $struct /// #[pyo3(signature = (solver=None, debug=false), text_signature = "($self, solver=None, debug=False)")] fn solve(slf: Bound<'_, Self>, solver: Option<PyDFTSolver>, debug: bool) -> PyResult<Bound<'_, Self>> { slf.borrow_mut() .0 .solve_inplace(solver.map(|s| s.0).as_ref(), debug).map_err(PyFeosError::from)?; Ok(slf) } $( #[getter] fn $ax(&self) -> Length<Array1<f64>> { Length::from_reduced(self.0.profile.grid.grids()[$ind].clone()) })+ #[getter] fn get_temperature(&self) -> Temperature { self.0.profile.temperature } #[getter] fn get_density(&self) -> Density<$si_arr2<f64>> { self.0.profile.density.clone() } #[getter] fn get_moles(&self) -> Moles<DVector<f64>> { self.0.profile.moles() } #[getter] fn get_total_moles(&self) -> Moles { self.0.profile.total_moles() } #[getter] fn get_external_potential<'py>(&self, py: Python<'py>) -> Bound<'py, $py_arr2<f64>> { self.0.profile.external_potential.view().to_pyarray(py) } #[getter] fn get_bulk(&self) -> PyState { PyState(self.0.profile.bulk.clone()) } #[getter] fn get_solver_log(&self) -> Option<PyDFTSolverLog> { self.0.profile.solver_log.clone().map(PyDFTSolverLog) } #[getter] fn get_weighted_densities<'py>( &self, py: Python<'py>, ) -> PyResult<Vec<Bound<'py, $arr2<f64>>>> { let n = self.0.profile.weighted_densities().map_err(PyFeosError::from)?; Ok(n.into_iter().map(|n| n.view().to_pyarray(py)).collect()) } #[getter] fn get_functional_derivative<'py>( &self, py: Python<'py>, ) -> PyResult<Bound<'py, $arr2<f64>>> { Ok(self.0.profile.functional_derivative().map_err(PyFeosError::from)?.view().to_pyarray(py)) } /// Calculate the entropy density of the inhomogeneous system. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SIArray #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn entropy_density( &mut self, contributions: PyContributions, ) -> PyResult<<Entropy<$si_arr<f64>> as std::ops::Div<Volume>>::Output> { Ok(self.0.profile.entropy_density(contributions.into()).map_err(PyFeosError::from)?) } /// Calculate the entropy of the inhomogeneous system. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn entropy( &mut self, contributions: PyContributions, ) -> PyResult<Entropy> { Ok(self.0.profile.entropy(contributions.into()).map_err(PyFeosError::from)?) } /// Calculate the internal energy of the inhomogeneous system. /// /// Parameters /// ---------- /// contributions: Contributions, optional /// the contributions of the helmholtz energy. /// Defaults to Contributions.Total. /// /// Returns /// ------- /// SINumber #[pyo3(signature = (contributions=PyContributions::Total), text_signature = "($self, contributions)")] fn internal_energy( &mut self, contributions: PyContributions, ) -> PyResult<Energy> { Ok(self.0.profile.internal_energy(contributions.into()).map_err(PyFeosError::from)?) } #[getter] fn get_grand_potential_density(&self) -> PyResult<Pressure<$si_arr<f64>>> { Ok(self.0.profile.grand_potential_density().map_err(PyFeosError::from)?) } $( #[getter] fn get_drho_dmu(&self) -> PyResult<<Density<$si_arr3<f64>> as std::ops::Div<MolarEnergy>>::Output> { Ok(self.0.profile.drho_dmu().map_err(PyFeosError::from)?) } )? #[getter] fn get_dn_dmu(&self) -> PyResult<<Moles<DMatrix<f64>> as std::ops::Div<MolarEnergy>>::Output> { Ok(self.0.profile.dn_dmu().map_err(PyFeosError::from)?) } #[getter] fn get_drho_dp(&self) -> PyResult<<Density<$si_arr2<f64>> as std::ops::Div<Pressure>>::Output> { Ok(self.0.profile.drho_dp().map_err(PyFeosError::from)?) } #[getter] fn get_dn_dp(&self) -> PyResult<<Moles<DVector<f64>> as std::ops::Div<Pressure>>::Output> { Ok(self.0.profile.dn_dp().map_err(PyFeosError::from)?) } #[getter] fn get_drho_dt(&self) -> PyResult<<Density<$si_arr2<f64>> as std::ops::Div<Temperature>>::Output> { Ok(self.0.profile.drho_dt().map_err(PyFeosError::from)?) } #[getter] fn get_dn_dt(&self) -> PyResult<<Moles<DVector<f64>> as std::ops::Div<Temperature>>::Output> { Ok(self.0.profile.dn_dt().map_err(PyFeosError::from)?) } } }; } macro_rules! impl_1d_profile { ($struct:ident, [$($ax:ident),+]) => { impl_profile!( $struct, PyArray1, PyArray2, Array1, Array2, PyArray2, [$([0, $ax]),+], Array3 ); }; } macro_rules! impl_2d_profile { ($struct:ident, $ax1:ident, $ax2:ident) => { impl_profile!( $struct, PyArray2, PyArray3, Array2, Array3, PyArray3, [[0, $ax1], [1, $ax2]] ); #[pymethods] impl $struct { #[getter] fn get_edges(&self) -> [Length<Array1<f64>>; 2] { self.0.profile.edges() } #[getter] fn get_meshgrid(&self) -> [Length<Array2<f64>>; 2] { self.0.profile.meshgrid() } } }; } macro_rules! impl_3d_profile { ($struct:ident, $ax1:ident, $ax2:ident, $ax3:ident) => { impl_profile!( $struct, PyArray3, PyArray4, Array3, Array4, PyArray4, [[0, $ax1], [1, $ax2], [2, $ax3]] ); #[pymethods] impl $struct { #[getter] fn get_edges(&self) -> [Length<Array1<f64>>; 3] { self.0.profile.edges() } #[getter] fn get_meshgrid(&self) -> [Length<Array3<f64>>; 3] { self.0.profile.meshgrid() } } }; } pub(crate) use {impl_1d_profile, impl_2d_profile, impl_3d_profile, impl_profile};
Rust
3D
feos-org/feos
py-feos/src/dft/interface/mod.rs
.rs
5,392
183
use super::profile::{impl_1d_profile, impl_profile}; use super::{PyDFTSolver, PyDFTSolverLog}; use crate::error::PyFeosError; use crate::ideal_gas::IdealGasModel; use crate::phase_equilibria::PyPhaseEquilibrium; use crate::residual::ResidualModel; use crate::state::{PyContributions, PyState}; use feos_core::{EquationOfState, ReferenceSystem}; use feos_dft::interface::PlanarInterface; use nalgebra::{DMatrix, DVector}; use ndarray::*; use numpy::*; use pyo3::*; use quantity::*; use std::sync::Arc; mod surface_tension_diagram; pub use surface_tension_diagram::PySurfaceTensionDiagram; /// A one-dimensional density profile of a vapor-liquid or liquid-liquid interface. #[pyclass(name = "PlanarInterface")] pub struct PyPlanarInterface( PlanarInterface<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>, ); impl_1d_profile!(PyPlanarInterface, [get_z]); #[pymethods] impl PyPlanarInterface { /// Initialize a planar interface with a hyperbolic tangent. /// /// Parameters /// ---------- /// vle : PhaseEquilibrium /// The bulk phase equilibrium. /// n_grid : int /// The number of grid points. /// l_grid: SINumber /// The width of the calculation domain. /// critical_temperature: SINumber /// An estimate for the critical temperature of the system. /// Used to guess the width of the interface. /// fix_equimolar_surface: bool, optional /// If True use additional constraints to fix the /// equimolar surface of the system. /// Defaults to False. /// /// Returns /// ------- /// PlanarInterface /// #[staticmethod] #[pyo3( text_signature = "(vle, n_grid, l_grid, critical_temperature, fix_equimolar_surface=None)" )] #[pyo3(signature = (vle, n_grid, l_grid, critical_temperature, fix_equimolar_surface=None))] fn from_tanh( vle: &PyPhaseEquilibrium, n_grid: usize, l_grid: Length, critical_temperature: Temperature, fix_equimolar_surface: Option<bool>, ) -> Self { let profile = PlanarInterface::from_tanh( &vle.0, n_grid, l_grid, critical_temperature, fix_equimolar_surface.unwrap_or(false), ); PyPlanarInterface(profile) } /// Initialize a planar interface with a pDGT calculation. /// /// Parameters /// ---------- /// vle : PhaseEquilibrium /// The bulk phase equilibrium. /// n_grid : int /// The number of grid points. /// fix_equimolar_surface: bool, optional /// If True use additional constraints to fix the /// equimolar surface of the system. /// Defaults to False. /// /// Returns /// ------- /// PlanarInterface /// #[staticmethod] #[pyo3(text_signature = "(vle, n_grid, fix_equimolar_surface=None)")] #[pyo3(signature = (vle, n_grid, fix_equimolar_surface=None))] fn from_pdgt( vle: &PyPhaseEquilibrium, n_grid: usize, fix_equimolar_surface: Option<bool>, ) -> PyResult<Self> { let profile = PlanarInterface::from_pdgt(&vle.0, n_grid, fix_equimolar_surface.unwrap_or(false)) .map_err(PyFeosError::from)?; Ok(PyPlanarInterface(profile)) } /// Initialize a planar interface with a provided density profile. /// /// Parameters /// ---------- /// vle : PhaseEquilibrium /// The bulk phase equilibrium. /// n_grid : int /// The number of grid points. /// l_grid: SINumber /// The width of the calculation domain. /// density_profile: SIArray2 /// Initial condition for the density profile iterations /// /// Returns /// ------- /// PlanarInterface /// #[staticmethod] fn from_density_profile( vle: &PyPhaseEquilibrium, n_grid: usize, l_grid: Length, density_profile: Density<Array2<f64>>, ) -> Self { let mut profile = PlanarInterface::new(&vle.0, n_grid, l_grid); profile.profile.density = density_profile; PyPlanarInterface(profile) } } #[pymethods] impl PyPlanarInterface { #[getter] fn get_surface_tension(&mut self) -> Option<SurfaceTension> { self.0.surface_tension } #[getter] fn get_equimolar_radius(&mut self) -> Option<Length> { self.0.equimolar_radius } #[getter] fn get_vle(&self) -> PyPhaseEquilibrium { PyPhaseEquilibrium(self.0.vle.clone()) } /// Calculates the Gibbs relative adsorption of component i with /// respect to j: \Gamma_i^(j) /// /// Returns /// ------- /// SIArray2 /// fn relative_adsorption(&self) -> Moles<Array2<f64>> { self.0.relative_adsorption() } /// Calculates the interfacial enrichment E_i. /// /// Returns /// ------- /// numpy.ndarray /// fn interfacial_enrichment<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1<f64>> { self.0.interfacial_enrichment().to_pyarray(py) } /// Calculates the interfacial thickness (90-10 number density difference) /// /// Returns /// ------- /// SINumber /// fn interfacial_thickness(&self) -> PyResult<Length> { Ok(self.0.interfacial_thickness().map_err(PyFeosError::from)?) } }
Rust
3D
feos-org/feos
py-feos/src/dft/interface/surface_tension_diagram.rs
.rs
3,660
121
use super::PyPlanarInterface; use crate::dft::PyDFTSolver; use crate::phase_equilibria::PyPhaseEquilibrium; use crate::state::PyStateVec; use crate::{ideal_gas::IdealGasModel, residual::ResidualModel}; use feos_core::EquationOfState; use feos_dft::interface::SurfaceTensionDiagram; use ndarray::*; use numpy::*; use pyo3::*; use quantity::*; use std::sync::Arc; /// Container structure for the efficient calculation of surface tension diagrams. /// /// Parameters /// ---------- /// dia : [PhaseEquilibrium] /// The underlying phase diagram given as a list of states /// for which surface tensions shall be calculated. /// init_densities : bool, optional /// None: Do not initialize densities with old results /// True: Initialize and scale densities /// False: Initialize without scaling /// n_grid : int, optional /// The number of grid points (default: 2048). /// l_grid : SINumber, optional /// The size of the calculation domain (default: 100 A) /// critical_temperature: SINumber, optional /// An estimate for the critical temperature, used to initialize /// density profile (default: 500 K) /// fix_equimolar_surface: bool, optional /// If True use additional constraints to fix the /// equimolar surface of the system. /// Defaults to False. /// solver: DFTSolver, optional /// Custom solver options /// /// Returns /// ------- /// SurfaceTensionDiagram #[pyclass(name = "SurfaceTensionDiagram")] pub struct PySurfaceTensionDiagram( SurfaceTensionDiagram<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>, ); #[pymethods] impl PySurfaceTensionDiagram { #[new] #[pyo3( text_signature = "(dia, init_densities=None, n_grid=None, l_grid=None, critical_temperature=None, fix_equimolar_surface=None, solver=None)" )] #[pyo3(signature = (dia, init_densities=None, n_grid=None, l_grid=None, critical_temperature=None, fix_equimolar_surface=None, solver=None))] pub fn isotherm( dia: Vec<PyPhaseEquilibrium>, init_densities: Option<bool>, n_grid: Option<usize>, l_grid: Option<Length>, critical_temperature: Option<Temperature>, fix_equimolar_surface: Option<bool>, solver: Option<PyDFTSolver>, ) -> PyResult<Self> { let x: Vec<_> = dia.into_iter().map(|vle| vle.0).collect(); Ok(Self(SurfaceTensionDiagram::new( &x, init_densities, n_grid, l_grid, critical_temperature, fix_equimolar_surface, solver.map(|s| s.0).as_ref(), ))) } #[getter] fn get_profiles(&self) -> Vec<PyPlanarInterface> { self.0 .profiles .iter() .map(|p| PyPlanarInterface(p.clone())) .collect() } #[getter] pub fn get_vapor(&self) -> PyStateVec { self.0.vapor().into() } #[getter] pub fn get_liquid(&self) -> PyStateVec { self.0.liquid().into() } #[getter] pub fn get_surface_tension(&mut self) -> SurfaceTension<Array1<f64>> { self.0.surface_tension() } #[getter] pub fn get_relative_adsorption(&self) -> Vec<Moles<Array2<f64>>> { self.0.relative_adsorption() } #[getter] pub fn get_interfacial_enrichment<'py>( &self, py: Python<'py>, ) -> Vec<Bound<'py, PyArray1<f64>>> { self.0 .interfacial_enrichment() .iter() .map(|i| i.to_pyarray(py)) .collect() } #[getter] pub fn interfacial_thickness(&self) -> Length<Array1<f64>> { self.0.interfacial_thickness() } }
Rust
3D
feos-org/feos
py-feos/src/dft/adsorption/mod.rs
.rs
11,147
274
use super::PyDFTSolver; use crate::eos::{parse_molefracs, PyEquationOfState}; use crate::error::PyFeosError; use crate::ideal_gas::IdealGasModel; use crate::residual::ResidualModel; use crate::PyVerbosity; use feos_core::EquationOfState; use feos_dft::adsorption::{Adsorption, Adsorption1D, Adsorption3D}; use nalgebra::DMatrix; use ndarray::*; use numpy::*; use pyo3::prelude::*; use quantity::*; use std::sync::Arc; mod external_potential; mod pore; pub use external_potential::PyExternalPotential; pub use pore::{PyPore1D, PyPore2D, PyPore3D, PyPoreProfile1D, PyPoreProfile3D}; /// Container structure for adsorption isotherms in 1D pores. #[pyclass(name = "Adsorption1D")] pub struct PyAdsorption1D(Adsorption1D<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>); /// Container structure for adsorption isotherms in 3D pores. #[pyclass(name = "Adsorption3D")] pub struct PyAdsorption3D(Adsorption3D<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>); macro_rules! impl_adsorption_isotherm { ($py_adsorption:ty, $py_pore:ty, $py_pore_profile:ident) => { #[pymethods] impl $py_adsorption { /// Calculate an adsorption isotherm for the given pressure range. /// The profiles are evaluated starting from the lowest pressure. /// The resulting density profiles can be metastable. /// /// Parameters /// ---------- /// functional : HelmholtzEnergyFunctional /// The Helmholtz energy functional. /// temperature : SINumber /// The temperature. /// pressure : SIArray1 /// The pressures for which the profiles are calculated. /// pore : Pore /// The pore parameters. /// molefracs: numpy.ndarray[float], optional /// For a mixture, the molefracs of the bulk system. /// solver: DFTSolver, optional /// Custom solver options. /// /// Returns /// ------- /// Adsorption /// #[staticmethod] #[pyo3(text_signature = "(functional, temperature, pressure, pore, molefracs=None, solver=None)")] #[pyo3(signature = (functional, temperature, pressure, pore, molefracs=None, solver=None))] fn adsorption_isotherm( functional: &PyEquationOfState, temperature: Temperature, pressure: Pressure<Array1<f64>>, pore: &$py_pore, molefracs: Option<PyReadonlyArray1<'_, f64>>, solver: Option<PyDFTSolver>, ) -> PyResult<Self> { Ok(Self(Adsorption::adsorption_isotherm( &functional.0, temperature, &pressure, &pore.0, &parse_molefracs(molefracs), solver.map(|s| s.0).as_ref(), ).map_err(PyFeosError::from)?)) } /// Calculate a desorption isotherm for the given pressure range. /// The profiles are evaluated starting from the highest pressure. /// The resulting density profiles can be metastable. /// /// Parameters /// ---------- /// functional : HelmholtzEnergyFunctional /// The Helmholtz energy functional. /// temperature : SINumber /// The temperature. /// pressure : SIArray1 /// The pressures for which the profiles are calculated. /// pore : Pore /// The pore parameters. /// molefracs: numpy.ndarray[float], optional /// For a mixture, the molefracs of the bulk system. /// solver: DFTSolver, optional /// Custom solver options. /// /// Returns /// ------- /// Adsorption /// #[staticmethod] #[pyo3(text_signature = "(functional, temperature, pressure, pore, molefracs=None, solver=None)")] #[pyo3(signature = (functional, temperature, pressure, pore, molefracs=None, solver=None))] fn desorption_isotherm( functional: &PyEquationOfState, temperature: Temperature, pressure: Pressure<Array1<f64>>, pore: &$py_pore, molefracs: Option<PyReadonlyArray1<'_, f64>>, solver: Option<PyDFTSolver>, ) -> PyResult<Self> { Ok(Self(Adsorption::desorption_isotherm( &functional.0, temperature, &pressure, &pore.0, &parse_molefracs(molefracs), solver.map(|s| s.0).as_ref(), ).map_err(PyFeosError::from)?)) } /// Calculate an equilibrium isotherm for the given pressure range. /// A phase equilibrium in the pore is calculated to determine the /// stable phases for every pressure. If no phase equilibrium can be /// calculated, the isotherm is calculated twice, one in the adsorption /// direction and once in the desorption direction to determine the /// stability of the profiles. /// /// Parameters /// ---------- /// functional : HelmholtzEnergyFunctional /// The Helmholtz energy functional. /// temperature : SINumber /// The temperature. /// pressure : SIArray1 /// The pressures for which the profiles are calculated. /// pore : Pore /// The pore parameters. /// molefracs: numpy.ndarray[float], optional /// For a mixture, the molefracs of the bulk system. /// solver: DFTSolver, optional /// Custom solver options. /// /// Returns /// ------- /// Adsorption /// #[staticmethod] #[pyo3(text_signature = "(functional, temperature, pressure, pore, molefracs=None, solver=None)")] #[pyo3(signature = (functional, temperature, pressure, pore, molefracs=None, solver=None))] fn equilibrium_isotherm( functional: &PyEquationOfState, temperature: Temperature, pressure: Pressure<Array1<f64>>, pore: &$py_pore, molefracs: Option<PyReadonlyArray1<'_, f64>>, solver: Option<PyDFTSolver>, ) -> PyResult<Self> { Ok(Self(Adsorption::equilibrium_isotherm( &functional.0, temperature, &pressure, &pore.0, &parse_molefracs(molefracs), solver.map(|s| s.0).as_ref(), ).map_err(PyFeosError::from)?)) } /// Calculate a phase equilibrium in a pore. /// /// Parameters /// ---------- /// functional : HelmholtzEnergyFunctional /// The Helmholtz energy functional. /// temperature : SINumber /// The temperature. /// p_min : SINumber /// A suitable lower limit for the pressure. /// p_max : SINumber /// A suitable upper limit for the pressure. /// pore : Pore /// The pore parameters. /// molefracs: numpy.ndarray[float], optional /// For a mixture, the molefracs of the bulk system. /// solver: DFTSolver, optional /// Custom solver options. /// max_iter : int, optional /// The maximum number of iterations of the phase equilibrium calculation. /// tol: float, optional /// The tolerance of the phase equilibrium calculation. /// verbosity: Verbosity, optional /// The verbosity of the phase equilibrium calculation. /// /// Returns /// ------- /// Adsorption /// #[staticmethod] #[pyo3(text_signature = "(functional, temperature, p_min, p_max, pore, molefracs=None, solver=None, max_iter=None, tol=None, verbosity=None)")] #[pyo3(signature = (functional, temperature, p_min, p_max, pore, molefracs=None, solver=None, max_iter=None, tol=None, verbosity=None))] #[expect(clippy::too_many_arguments)] fn phase_equilibrium( functional: &PyEquationOfState, temperature: Temperature, p_min: Pressure, p_max: Pressure, pore: &$py_pore, molefracs: Option<PyReadonlyArray1<'_, f64>>, solver: Option<PyDFTSolver>, max_iter: Option<usize>, tol: Option<f64>, verbosity: Option<PyVerbosity>, ) -> PyResult<Self> { Ok(Self(Adsorption::phase_equilibrium( &functional.0, temperature, p_min, p_max, &pore.0, &parse_molefracs(molefracs), solver.map(|s| s.0).as_ref(), (max_iter, tol, verbosity.map(|v| v.into())).into(), ).map_err(PyFeosError::from)?)) } #[getter] fn get_profiles(&self) -> Vec<$py_pore_profile> { self.0 .profiles .iter() .filter_map(|p| { p.as_ref() .ok() .map(|p| $py_pore_profile(p.clone())) }) .collect() } #[getter] fn get_pressure(&self) -> Pressure<Array1<f64>> { self.0.pressure() } #[getter] fn get_adsorption(&self) -> Moles<Array2<f64>> { self.0.adsorption() } #[getter] fn get_total_adsorption(&self) -> Moles<Array1<f64>> { self.0.total_adsorption() } #[getter] fn get_grand_potential(&mut self) -> Energy<Array1<f64>> { self.0.grand_potential() } #[getter] fn get_partial_molar_enthalpy_of_adsorption(&self) -> MolarEnergy<DMatrix<f64>> { self.0.partial_molar_enthalpy_of_adsorption() } #[getter] fn get_enthalpy_of_adsorption(&self) -> MolarEnergy<Array1<f64>> { self.0.enthalpy_of_adsorption() } } }; } impl_adsorption_isotherm!(PyAdsorption1D, PyPore1D, PyPoreProfile1D); impl_adsorption_isotherm!(PyAdsorption3D, PyPore3D, PyPoreProfile3D);
Rust
3D
feos-org/feos
py-feos/src/dft/adsorption/external_potential.rs
.rs
8,981
255
use feos_dft::adsorption::ExternalPotential; use ndarray::Array2; use numpy::prelude::*; use numpy::PyArray1; use pyo3::prelude::*; use quantity::Length; /// A collection of external potentials. #[pyclass(name = "ExternalPotential")] #[derive(Clone)] pub struct PyExternalPotential(pub ExternalPotential); #[pymethods] #[expect(non_snake_case)] impl PyExternalPotential { /// Hard wall potential /// /// .. math:: V_i^\mathrm{ext}(z)=\begin{cases}\infty&z\leq\sigma_{si}\\\\0&z>\sigma_{si}\end{cases},~~~~\sigma_{si}=\frac{1}{2}\left(\sigma_{ss}+\sigma_{ii}\right) /// /// Parameters /// ---------- /// sigma_ss : float /// Segment diameter of the solid. /// /// Returns /// ------- /// ExternalPotential /// #[staticmethod] #[expect(non_snake_case)] pub fn HardWall(sigma_ss: f64) -> Self { Self(ExternalPotential::HardWall { sigma_ss }) } /// 9-3 Lennard-Jones potential /// /// .. math:: V_i^\mathrm{ext}(z)=\frac{2\pi}{45} m_i\varepsilon_{si}\sigma_{si}^3\rho_s\left(2\left(\frac{\sigma_{si}}{z}\right)^9-15\left(\frac{\sigma_{si}}{z}\right)^3\right),~~~~\varepsilon_{si}=\sqrt{\varepsilon_{ss}\varepsilon_{ii}},~~~~\sigma_{si}=\frac{1}{2}\left(\sigma_{ss}+\sigma_{ii}\right) /// /// Parameters /// ---------- /// sigma_ss : float /// Segment diameter of the solid. /// epsilon_k_ss : float /// Energy parameter of the solid. /// rho_s : float /// Density of the solid. /// /// Returns /// ------- /// ExternalPotential /// #[staticmethod] pub fn LJ93(sigma_ss: f64, epsilon_k_ss: f64, rho_s: f64) -> Self { Self(ExternalPotential::LJ93 { sigma_ss, epsilon_k_ss, rho_s, }) } /// Simple 9-3 Lennard-Jones potential /// /// .. math:: V_i^\mathrm{ext}(z)=\varepsilon_{si}\left(\left(\frac{\sigma_{si}}{z}\right)^9-\left(\frac{\sigma_{si}}{z}\right)^3\right),~~~~\varepsilon_{si}=\sqrt{\varepsilon_{ss}\varepsilon_{ii}},~~~~\sigma_{si}=\frac{1}{2}\left(\sigma_{ss}+\sigma_{ii}\right) /// /// Parameters /// ---------- /// sigma_ss : float /// Segment diameter of the solid. /// epsilon_k_ss : float /// Energy parameter of the solid. /// /// Returns /// ------- /// ExternalPotential /// #[staticmethod] pub fn SimpleLJ93(sigma_ss: f64, epsilon_k_ss: f64) -> Self { Self(ExternalPotential::SimpleLJ93 { sigma_ss, epsilon_k_ss, }) } /// Custom 9-3 Lennard-Jones potential /// /// .. math:: V_i^\mathrm{ext}(z)=\varepsilon_{si}\left(\left(\frac{\sigma_{si}}{z}\right)^9-\left(\frac{\sigma_{si}}{z}\right)^3\right) /// /// Parameters /// ---------- /// sigma_sf : numpy.ndarray[float] /// Solid-fluid interaction diameters. /// epsilon_k_sf : numpy.ndarray[float] /// Solid-fluid interaction energies. /// /// Returns /// ------- /// ExternalPotential /// #[staticmethod] pub fn CustomLJ93( sigma_sf: &Bound<'_, PyArray1<f64>>, epsilon_k_sf: &Bound<'_, PyArray1<f64>>, ) -> Self { Self(ExternalPotential::CustomLJ93 { sigma_sf: sigma_sf.to_owned_array(), epsilon_k_sf: epsilon_k_sf.to_owned_array(), }) } /// Steele potential /// /// .. math:: V_i^\mathrm{ext}(z)=2\pi m_i\xi\varepsilon_{si}\sigma_{si}^2\Delta\rho_s\left(0.4\left(\frac{\sigma_{si}}{z}\right)^{10}-\left(\frac{\sigma_{si}}{z}\right)^4-\frac{\sigma_{si}^4}{3\Delta\left(z+0.61\Delta\right)^3}\right),~~~~\varepsilon_{si}=\sqrt{\varepsilon_{ss}\varepsilon_{ii}},~~~~\sigma_{si}=\frac{1}{2}\left(\sigma_{ss}+\sigma_{ii}\right),~~~~\Delta=3.35 /// /// Parameters /// ---------- /// sigma_ss : float /// Segment diameter of the solid. /// epsilon_k_ss : float /// Energy parameter of the solid. /// rho_s : float /// Density of the solid. /// xi : float, optional /// Binary wall-fluid interaction parameter. /// /// Returns /// ------- /// ExternalPotential /// #[staticmethod] #[pyo3(text_signature = "(sigma_ss, epsilon_k_ss, rho_s, xi=None)")] #[pyo3(signature = (sigma_ss, epsilon_k_ss, rho_s, xi=None))] pub fn Steele(sigma_ss: f64, epsilon_k_ss: f64, rho_s: f64, xi: Option<f64>) -> Self { Self(ExternalPotential::Steele { sigma_ss, epsilon_k_ss, rho_s, xi, }) } /// Steele potential with custom combining rules /// /// .. math:: V_i^\mathrm{ext}(z)=2\pi m_i\xi\varepsilon_{si}\sigma_{si}^2\Delta\rho_s\left(0.4\left(\frac{\sigma_{si}}{z}\right)^{10}-\left(\frac{\sigma_{si}}{z}\right)^4-\frac{\sigma_{si}^4}{3\Delta\left(z+0.61\Delta\right)^3}\right),~~~~\Delta=3.35 /// /// Parameters /// ---------- /// sigma_sf : numpy.ndarray[float] /// Solid-fluid interaction diameters. /// epsilon_k_sf : numpy.ndarray[float] /// Solid-fluid interaction energies. /// rho_s : float /// Density of the solid. /// xi : float, optional /// Binary wall-fluid interaction parameter. /// /// Returns /// ------- /// ExternalPotential /// #[staticmethod] #[pyo3(text_signature = "(sigma_sf, epsilon_k_sf, rho_s, xi=None)")] #[pyo3(signature = (sigma_sf, epsilon_k_sf, rho_s, xi=None))] pub fn CustomSteele( sigma_sf: &Bound<'_, PyArray1<f64>>, epsilon_k_sf: &Bound<'_, PyArray1<f64>>, rho_s: f64, xi: Option<f64>, ) -> Self { Self(ExternalPotential::CustomSteele { sigma_sf: sigma_sf.to_owned_array(), epsilon_k_sf: epsilon_k_sf.to_owned_array(), rho_s, xi, }) } /// Double well potential /// /// .. math:: V_i^\mathrm{ext}(z)=\mathrm{min}\left(\frac{2\pi}{45} m_i\varepsilon_{2si}\sigma_{si}^3\rho_s\left(2\left(\frac{2\sigma_{si}}{z}\right)^9-15\left(\frac{2\sigma_{si}}{z}\right)^3\right),0\right)+\frac{2\pi}{45} m_i\varepsilon_{1si}\sigma_{si}^3\rho_s\left(2\left(\frac{\sigma_{si}}{z}\right)^9-15\left(\frac{\sigma_{si}}{z}\right)^3\right),~~~~\varepsilon_{1si}=\sqrt{\varepsilon_{1ss}\varepsilon_{ii}},~~~~\varepsilon_{2si}=\sqrt{\varepsilon_{2ss}\varepsilon_{ii}},~~~~\sigma_{si}=\frac{1}{2}\left(\sigma_{ss}+\sigma_{ii}\right) /// /// Parameters /// ---------- /// sigma_ss : float /// Segment diameter of the solid. /// epsilon1_k_ss : float /// Energy parameter of the first well. /// epsilon2_k_ss : float /// Energy parameter of the second well. /// rho_s : float /// Density of the solid. /// /// Returns /// ------- /// ExternalPotential /// #[staticmethod] pub fn DoubleWell(sigma_ss: f64, epsilon1_k_ss: f64, epsilon2_k_ss: f64, rho_s: f64) -> Self { Self(ExternalPotential::DoubleWell { sigma_ss, epsilon1_k_ss, epsilon2_k_ss, rho_s, }) } /// Free-energy averaged potential /// /// for details see: `J. Eller, J. Gross (2021) <https://pubs.acs.org/doi/abs/10.1021/acs.langmuir.0c03287>`_ /// /// Parameters /// ---------- /// coordinates: SIArray2 /// The positions of all interaction sites in the solid. /// sigma_ss : numpy.ndarray[float] /// The size parameters of all interaction sites. /// epsilon_k_ss : numpy.ndarray[float] /// The energy parameter of all interaction sites. /// pore_center : [SINumber; 3] /// The cartesian coordinates of the center of the pore /// system_size : [SINumber; 3] /// The size of the unit cell. /// n_grid : [int; 2] /// The number of grid points in each direction. /// cutoff_radius : float, optional /// The cutoff used in the calculation of fluid/wall interactions. /// Returns /// ------- /// ExternalPotential /// #[staticmethod] #[pyo3( text_signature = "(coordinates, sigma_ss, epsilon_k_ss, pore_center, system_size, n_grid, cutoff_radius=None)", signature = (coordinates, sigma_ss, epsilon_k_ss, pore_center, system_size, n_grid, cutoff_radius=None) )] pub fn FreeEnergyAveraged( coordinates: Length<Array2<f64>>, sigma_ss: &Bound<'_, PyArray1<f64>>, epsilon_k_ss: &Bound<'_, PyArray1<f64>>, pore_center: [f64; 3], system_size: [Length; 3], n_grid: [usize; 2], cutoff_radius: Option<f64>, ) -> Self { Self(ExternalPotential::FreeEnergyAveraged { coordinates, sigma_ss: sigma_ss.to_owned_array(), epsilon_k_ss: epsilon_k_ss.to_owned_array(), pore_center, system_size, n_grid, cutoff_radius, }) } }
Rust
3D
feos-org/feos
py-feos/src/dft/adsorption/pore.rs
.rs
10,755
351
use super::PyExternalPotential; use crate::dft::profile::*; use crate::dft::{PyDFTSolver, PyDFTSolverLog, PyGeometry}; use crate::error::PyFeosError; use crate::ideal_gas::IdealGasModel; use crate::residual::ResidualModel; use crate::state::{PyContributions, PyState}; use feos_core::{EquationOfState, ReferenceSystem}; use feos_dft::adsorption::*; use nalgebra::{DMatrix, DVector}; use ndarray::*; use numpy::*; use pyo3::prelude::*; use quantity::*; use std::sync::Arc; macro_rules! impl_pore_profile { ($py_profile:ty) => { #[pymethods] impl $py_profile { #[getter] fn get_grand_potential(&self) -> Option<Energy> { self.0.grand_potential } #[getter] fn get_interfacial_tension(&self) -> Option<Energy> { self.0.interfacial_tension } #[getter] fn get_partial_molar_enthalpy_of_adsorption( &self, ) -> PyResult<MolarEnergy<DVector<f64>>> { Ok(self .0 .partial_molar_enthalpy_of_adsorption() .map_err(PyFeosError::from)?) } #[getter] fn get_enthalpy_of_adsorption(&self) -> PyResult<MolarEnergy> { Ok(self.0.enthalpy_of_adsorption().map_err(PyFeosError::from)?) } #[getter] fn get_henry_coefficients(&self) -> HenryCoefficient<DVector<f64>> { self.0.henry_coefficients() } #[getter] fn get_ideal_gas_enthalpy_of_adsorption(&self) -> MolarEnergy<DVector<f64>> { self.0.ideal_gas_enthalpy_of_adsorption() } } }; } /// Parameters required to specify a 1D pore. /// /// Parameters /// ---------- /// geometry : Geometry /// The pore geometry. /// pore_size : SINumber /// The width of the slit pore in cartesian coordinates, /// or the pore radius in spherical and cylindrical coordinates. /// potential : ExternalPotential /// The potential used to model wall-fluid interactions. /// n_grid : int, optional /// The number of grid points. /// potential_cutoff : float, optional /// Maximum value for the external potential. /// /// Returns /// ------- /// Pore1D /// #[pyclass(name = "Pore1D")] pub struct PyPore1D(pub Pore1D); #[pyclass(name = "PoreProfile1D")] pub struct PyPoreProfile1D( pub PoreProfile1D<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>, ); impl_1d_profile!(PyPoreProfile1D, [get_r, get_z]); impl_pore_profile!(PyPoreProfile1D); #[pymethods] impl PyPore1D { #[new] #[pyo3(text_signature = "(geometry, pore_size, potential, n_grid=None, potential_cutoff=None)")] #[pyo3(signature = (geometry, pore_size, potential, n_grid=None, potential_cutoff=None))] fn new( geometry: PyGeometry, pore_size: Length, potential: PyExternalPotential, n_grid: Option<usize>, potential_cutoff: Option<f64>, ) -> PyResult<Self> { Ok(Self(Pore1D::new( geometry.into(), pore_size, potential.0, n_grid, potential_cutoff, ))) } /// Initialize the pore for the given bulk state. /// /// Parameters /// ---------- /// bulk : State /// The bulk state in equilibrium with the pore. /// density : SIArray2, optional /// Initial values for the density profile. /// external_potential : numpy.ndarray[float], optional /// The external potential in the pore. Used to /// save computation time in the case of costly /// evaluations of external potentials. /// /// Returns /// ------- /// PoreProfile1D #[pyo3(text_signature = "($self, bulk, density=None, external_potential=None)")] #[pyo3(signature = (bulk, density=None, external_potential=None))] fn initialize( &self, bulk: &PyState, density: Option<Density<Array2<f64>>>, external_potential: Option<&Bound<'_, PyArray2<f64>>>, ) -> PyResult<PyPoreProfile1D> { Ok(PyPoreProfile1D( self.0 .initialize( &bulk.0, density.as_ref(), external_potential.map(|e| e.to_owned_array()).as_ref(), ) .map_err(PyFeosError::from)?, )) } #[getter] fn get_geometry(&self) -> PyGeometry { self.0.geometry.into() } #[getter] fn get_pore_size(&self) -> Length { self.0.pore_size } #[getter] fn get_potential(&self) -> PyExternalPotential { PyExternalPotential(self.0.potential.clone()) } #[getter] fn get_n_grid(&self) -> Option<usize> { self.0.n_grid } #[getter] fn get_potential_cutoff(&self) -> Option<f64> { self.0.potential_cutoff } /// The pore volume using Helium at 298 K as reference. #[getter] fn get_pore_volume(&self) -> PyResult<Volume> { Ok(self.0.pore_volume().map_err(PyFeosError::from)?) } } #[pyclass(name = "Pore2D")] pub struct PyPore2D(pub Pore2D); #[pyclass(name = "PoreProfile2D")] pub struct PyPoreProfile2D( pub PoreProfile2D<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>, ); impl_2d_profile!(PyPoreProfile2D, get_x, get_y); impl_pore_profile!(PyPoreProfile2D); #[pymethods] impl PyPore2D { #[new] #[pyo3(text_signature = "(system_size, angle, n_grid)")] fn new(system_size: [Length; 2], angle: Angle, n_grid: [usize; 2]) -> PyResult<Self> { Ok(Self(Pore2D::new( [system_size[0], system_size[1]], angle, n_grid, ))) } /// Initialize the pore for the given bulk state. /// /// Parameters /// ---------- /// bulk : State /// The bulk state in equilibrium with the pore. /// density : SIArray3, optional /// Initial values for the density profile. /// external_potential : numpy.ndarray[float], optional /// The external potential in the pore. Used to /// save computation time in the case of costly /// evaluations of external potentials. /// /// Returns /// ------- /// PoreProfile2D #[pyo3(text_signature = "($self, bulk, density=None, external_potential=None)")] #[pyo3(signature = (bulk, density=None, external_potential=None))] fn initialize( &self, bulk: &PyState, density: Option<Density<Array3<f64>>>, external_potential: Option<&Bound<'_, PyArray3<f64>>>, ) -> PyResult<PyPoreProfile2D> { Ok(PyPoreProfile2D( self.0 .initialize( &bulk.0, density.as_ref(), external_potential.map(|e| e.to_owned_array()).as_ref(), ) .map_err(PyFeosError::from)?, )) } /// The pore volume using Helium at 298 K as reference. #[getter] fn get_pore_volume(&self) -> PyResult<Volume> { Ok(self.0.pore_volume().map_err(PyFeosError::from)?) } } /// Parameters required to specify a 3D pore. /// /// Parameters /// ---------- /// system_size : [SINumber; 3] /// The size of the unit cell. /// n_grid : [int; 3] /// The number of grid points in each direction. /// coordinates : numpy.ndarray[float] /// The positions of all interaction sites in the solid. /// sigma_ss : numpy.ndarray[float] /// The size parameters of all interaction sites. /// epsilon_k_ss : numpy.ndarray[float] /// The energy parameter of all interaction sites. /// angles : [Angle; 3], optional /// The angles of the unit cell or `None` if the unit cell /// is orthorombic /// potential_cutoff: float, optional /// Maximum value for the external potential. /// cutoff_radius: SINumber, optional /// The cutoff radius for the calculation of solid-fluid interactions. /// /// Returns /// ------- /// Pore3D /// #[pyclass(name = "Pore3D")] pub struct PyPore3D(pub Pore3D); #[pyclass(name = "PoreProfile3D")] pub struct PyPoreProfile3D( pub PoreProfile3D<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>, ); impl_3d_profile!(PyPoreProfile3D, get_x, get_y, get_z); impl_pore_profile!(PyPoreProfile3D); #[pymethods] impl PyPore3D { #[new] #[pyo3( text_signature = "(system_size, n_grid, coordinates, sigma_ss, epsilon_k_ss, angles=None, potential_cutoff=None, cutoff_radius=None)" )] #[pyo3(signature = (system_size, n_grid, coordinates, sigma_ss, epsilon_k_ss, angles=None, potential_cutoff=None, cutoff_radius=None))] #[expect(clippy::too_many_arguments)] fn new( system_size: [Length; 3], n_grid: [usize; 3], coordinates: Length<Array2<f64>>, sigma_ss: &Bound<'_, PyArray1<f64>>, epsilon_k_ss: &Bound<'_, PyArray1<f64>>, angles: Option<[Angle; 3]>, potential_cutoff: Option<f64>, cutoff_radius: Option<Length>, ) -> Self { Self(Pore3D::new( system_size, n_grid, coordinates, sigma_ss.to_owned_array(), epsilon_k_ss.to_owned_array(), angles, potential_cutoff, cutoff_radius, )) } /// Initialize the pore for the given bulk state. /// /// Parameters /// ---------- /// bulk : State /// The bulk state in equilibrium with the pore. /// density : SIArray4, optional /// Initial values for the density profile. /// external_potential : numpy.ndarray[float], optional /// The external potential in the pore. Used to /// save computation time in the case of costly /// evaluations of external potentials. /// /// Returns /// ------- /// PoreProfile3D #[pyo3(text_signature = "($self, bulk, density=None, external_potential=None)")] #[pyo3(signature = (bulk, density=None, external_potential=None))] fn initialize( &self, bulk: &PyState, density: Option<Density<Array4<f64>>>, external_potential: Option<&Bound<'_, PyArray4<f64>>>, ) -> PyResult<PyPoreProfile3D> { Ok(PyPoreProfile3D( self.0 .initialize( &bulk.0, density.as_ref(), external_potential.map(|e| e.to_owned_array()).as_ref(), ) .map_err(PyFeosError::from)?, )) } /// The pore volume using Helium at 298 K as reference. #[getter] fn get_pore_volume(&self) -> PyResult<Volume> { Ok(self.0.pore_volume().map_err(PyFeosError::from)?) } }
Rust
3D
feos-org/feos
crates/feos-derive/src/subset.rs
.rs
1,662
60
use quote::quote; use syn::DeriveInput; pub(crate) fn expand_subset(input: DeriveInput) -> syn::Result<proc_macro2::TokenStream> { let variants = match input.data { syn::Data::Enum(syn::DataEnum { ref variants, .. }) => variants, _ => panic!("this derive macro only works on enums"), }; let components = impl_subset(input.ident, variants); Ok(quote! { #components }) } fn impl_subset( ident: syn::Ident, variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, ) -> proc_macro2::TokenStream { // let components = variants.iter().map(|v| { // let name = &v.ident; // if name == "NoModel" { // quote! { // Self::#name(n) => *n // } // } else { // quote! { // Self::#name(residual) => residual.components() // } // } // }); let subset = variants.iter().map(|v| { let name = &v.ident; if name == "NoModel" { quote! { Self::#name(n) => Self::#name(component_list.len()) } } else { quote! { Self::#name(residual) => Self::#name(residual.subset(component_list).into()) } } }); quote! { impl Subset for #ident { // fn components(&self) -> usize { // match self { // #(#components,)* // } // } fn subset(&self, component_list: &[usize]) -> Self { match self { #(#subset,)* } } } } }
Rust
3D
feos-org/feos
crates/feos-derive/src/lib.rs
.rs
3,533
103
//! This crate provides derive macros used for the EosVariant and //! FunctionalVariant enums in FeOs. The macros implement //! the boilerplate for the EquationOfState and HelmholtzEnergyFunctional traits. #![warn(clippy::all)] use dft::expand_helmholtz_energy_functional; use functional_contribution::expand_functional_contribution; use ideal_gas::expand_ideal_gas; use proc_macro::TokenStream; use residual::expand_residual; use subset::expand_subset; use syn::{parse_macro_input, DeriveInput}; mod dft; mod functional_contribution; mod ideal_gas; mod residual; mod subset; // possible additional traits to implement const OPT_IMPLS: [&str; 7] = [ "molar_weight", "parameter_info", "entropy_scaling", "functional", "bond_lengths", "fluid_parameters", "pair_potential", ]; fn implement(name: &str, variant: &syn::Variant, opts: &[&'static str]) -> syn::Result<bool> { let syn::Variant { attrs, .. } = variant; let mut implement = Ok(false); for attr in attrs.iter() { if attr.path.is_ident("implement") { if let Ok(syn::Meta::List(list)) = attr.parse_meta() { for meta in list.nested { if let syn::NestedMeta::Meta(syn::Meta::Path(path)) = meta { // check if all keywords are valid, return error if not if !opts.iter().any(|s| path.is_ident(s)) { let opts = opts.join(", "); return Err(syn::Error::new_spanned( path, format!("expected one of: {opts}"), )); } // "name" is present if path.is_ident(name) { implement = Ok(true) } } } } else { return Err(syn::Error::new_spanned( &attr.tokens, "expected 'implement(optional_trait, ...)'", )); } } } implement } #[proc_macro_derive(Subset)] pub fn derive_components(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); expand_subset(input) .unwrap_or_else(syn::Error::into_compile_error) .into() } #[proc_macro_derive(IdealGas)] pub fn derive_ideal_gas(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); expand_ideal_gas(input) .unwrap_or_else(syn::Error::into_compile_error) .into() } #[proc_macro_derive(ResidualDyn, attributes(implement))] pub fn derive_residual(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); expand_residual(input) .unwrap_or_else(syn::Error::into_compile_error) .into() } #[proc_macro_derive(HelmholtzEnergyFunctionalDyn, attributes(implement))] pub fn derive_helmholtz_energy_functional(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); expand_helmholtz_energy_functional(input) .unwrap_or_else(syn::Error::into_compile_error) .into() } #[proc_macro_derive(FunctionalContribution)] pub fn derive_functional_contribution(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); expand_functional_contribution(input) .unwrap_or_else(syn::Error::into_compile_error) .into() }
Rust
3D
feos-org/feos
crates/feos-derive/src/functional_contribution.rs
.rs
4,031
127
use quote::quote; use syn::{DeriveInput, Ident}; pub(crate) fn expand_functional_contribution( input: DeriveInput, ) -> syn::Result<proc_macro2::TokenStream> { let ident = input.ident; let variants = match input.data { syn::Data::Enum(syn::DataEnum { ref variants, .. }) => variants, _ => panic!("this derive macro only works on enums"), }; let functional_contribution = impl_functional_contribution(&ident, variants); // let display = impl_display(&ident, variants); let from = impl_from(&ident, variants); Ok(quote! { #functional_contribution // #display #from }) } fn impl_functional_contribution( ident: &Ident, variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, ) -> proc_macro2::TokenStream { let name = variants.iter().map(|v| { let name = &v.ident; quote! { Self::#name(functional_contribution) => functional_contribution.name() } }); let weight_functions = variants.iter().map(|v| { let name = &v.ident; quote! { Self::#name(functional_contribution) => functional_contribution.weight_functions(temperature) } }); let weight_functions_pdgt = variants.iter().map(|v| { let name = &v.ident; quote! { Self::#name(functional_contribution) => functional_contribution.weight_functions_pdgt(temperature) } }); let helmholtz_energy_density = variants.iter().map(|v| { let name = &v.ident; quote! { Self::#name(functional_contribution) => functional_contribution.helmholtz_energy_density(temperature, weighted_densities) } }); quote! { impl<'a> FunctionalContribution for #ident<'a> { fn name(&self) -> &'static str { match self { #(#name,)* } } fn weight_functions<N: DualNum<f64> + Copy>(&self, temperature: N) -> feos_dft::WeightFunctionInfo<N> { match self { #(#weight_functions,)* } } fn weight_functions_pdgt<N: DualNum<f64> + Copy>(&self, temperature: N) -> feos_dft::WeightFunctionInfo<N> { match self { #(#weight_functions_pdgt,)* } } fn helmholtz_energy_density<N: DualNum<f64> + Copy>( &self, temperature: N, weighted_densities: ndarray::ArrayView2<N>, ) -> FeosResult<Array1<N>> { match self { #(#helmholtz_energy_density,)* } } } } } // fn impl_display( // ident: &Ident, // variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, // ) -> proc_macro2::TokenStream { // let fmt = variants.iter().map(|v| { // let name = &v.ident; // quote! { // Self::#name(functional_contribution) => functional_contribution.fmt(f) // } // }); // quote! { // impl std::fmt::Display for #ident { // fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { // match self { // #(#fmt,)* // } // } // } // } // } fn impl_from( ident: &Ident, variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, ) -> proc_macro2::TokenStream { let from = variants.iter().map(|v| { let name = &v.ident; let syn::Fields::Unnamed(syn::FieldsUnnamed { unnamed, .. }) = &v.fields else { panic!("All variants must be tuple structs!") }; let inner = &unnamed.first().unwrap().ty; quote! { impl<'a> From<#inner> for #ident<'a> { fn from(variant: #inner) -> Self { Self::#name(variant) } } } }); quote! { #(#from)* } }
Rust
3D
feos-org/feos
crates/feos-derive/src/ideal_gas.rs
.rs
1,660
59
use quote::quote; use syn::DeriveInput; pub(crate) fn expand_ideal_gas(input: DeriveInput) -> syn::Result<proc_macro2::TokenStream> { let variants = match input.data { syn::Data::Enum(syn::DataEnum { ref variants, .. }) => variants, _ => panic!("this derive macro only works on enums"), }; let ideal_gas = impl_ideal_gas(variants); Ok(quote! { #ideal_gas }) } fn impl_ideal_gas( variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, ) -> proc_macro2::TokenStream { let ln_lambda3 = variants.iter().map(|v| { let name = &v.ident; if name == "NoModel" { quote! { Self::#name => panic!("No ideal gas model initialized!") } } else { quote! { Self::#name(ideal_gas) => ideal_gas.ln_lambda3(temperature) } } }); let string = variants.iter().map(|v| { let name = &v.ident; if name == "NoModel" { quote! { Self::#name => panic!("No ideal gas model initialized!") } } else { quote! { Self::#name(ideal_gas) => ideal_gas.ideal_gas_model() } } }); quote! { impl IdealGas for IdealGasModel { fn ln_lambda3<D: DualNum<f64, Inner=f64> + Copy>(&self, temperature: D) -> D { match self { #(#ln_lambda3,)* } } fn ideal_gas_model(&self) -> &'static str { match self { #(#string,)* } } } } }
Rust
3D
feos-org/feos
crates/feos-derive/src/dft.rs
.rs
5,269
150
use crate::{implement, OPT_IMPLS}; use quote::quote; use syn::DeriveInput; pub(crate) fn expand_helmholtz_energy_functional( input: DeriveInput, ) -> syn::Result<proc_macro2::TokenStream> { let syn::Data::Enum(syn::DataEnum { ref variants, .. }) = input.data else { panic!("this derive macro only works on enums") }; let functional = impl_helmholtz_energy_functional(&input.ident, variants)?; let fluid_parameters = impl_fluid_parameters(&input.ident, variants)?; let pair_potential = impl_pair_potential(&input.ident, variants)?; Ok(quote! { #functional #fluid_parameters #pair_potential }) } pub(crate) fn impl_helmholtz_energy_functional( ident: &syn::Ident, variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, ) -> syn::Result<proc_macro2::TokenStream> { let mut molecule_shape = Vec::new(); let mut contributions = Vec::new(); for v in variants.iter() { let name = &v.ident; if implement("functional", v, &OPT_IMPLS)? { molecule_shape.push(quote! { Self::#name(functional) => functional.molecule_shape() }); contributions.push(quote! { Self::#name(functional) => functional.contributions().map(FunctionalContributionVariant::from).collect::<Vec<_>>().into_iter() }); } else { molecule_shape.push(quote! { Self::#name(functional) => panic!("{} is not a Helmholtz energy functional!", stringify!(#name)) }); contributions.push(quote! { Self::#name(functional) => panic!("{} is not a Helmholtz energy functional!", stringify!(#name)) }); } } let mut bond_lengths = Vec::new(); for v in variants.iter() { if implement("bond_lengths", v, &OPT_IMPLS)? { let name = &v.ident; bond_lengths.push(quote! { Self::#name(functional) => functional.bond_lengths(temperature) }); } } Ok(quote! { impl HelmholtzEnergyFunctionalDyn for #ident { type Contribution<'a> = FunctionalContributionVariant<'a>; fn molecule_shape(&self) -> feos_dft::MoleculeShape<'_> { match self { #(#molecule_shape,)* } } fn contributions<'a>(&'a self) -> impl Iterator<Item = Self::Contribution<'a>> { match self { #(#contributions,)* } } fn bond_lengths<N: DualNum<f64> + Copy>(&self, temperature: N) -> petgraph::graph::UnGraph<(), N> { match self { #(#bond_lengths,)* _ => petgraph::Graph::with_capacity(0, 0), } } } }) } fn impl_fluid_parameters( ident: &syn::Ident, variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, ) -> syn::Result<proc_macro2::TokenStream> { let mut epsilon_k_ff = Vec::new(); let mut sigma_ff = Vec::new(); for v in variants.iter() { let name = &v.ident; if implement("fluid_parameters", v, &OPT_IMPLS)? { epsilon_k_ff.push(quote! { Self::#name(functional) => functional.epsilon_k_ff() }); sigma_ff.push(quote! { Self::#name(functional) => functional.sigma_ff() }); } else { epsilon_k_ff.push(quote! { Self::#name(functional) => panic!("{} does not support the automatic calculation of external potentials!", stringify!(#name)) }); sigma_ff.push(quote! { Self::#name(functional) => panic!("{} does not support the automatic calculation of external potentials!", stringify!(#name)) }); } } Ok(quote! { impl feos_dft::adsorption::FluidParameters for #ident { fn epsilon_k_ff(&self) -> DVector<f64> { match self { #(#epsilon_k_ff,)* } } fn sigma_ff(&self) -> DVector<f64> { match self { #(#sigma_ff,)* } } } }) } fn impl_pair_potential( ident: &syn::Ident, variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, ) -> syn::Result<proc_macro2::TokenStream> { let mut pair_potential = Vec::new(); for v in variants.iter() { let name = &v.ident; if implement("pair_potential", v, &OPT_IMPLS)? { pair_potential.push(quote! { Self::#name(functional) => functional.pair_potential(i, r, temperature) }); } else { pair_potential.push(quote! { Self::#name(functional) => panic!("{} does not provide pair potentials!", stringify!(#name)) }); } } Ok(quote! { impl feos_dft::solvation::PairPotential for #ident { fn pair_potential(&self, i: usize, r: &Array1<f64>, temperature: f64) -> ndarray::Array2<f64> { match self { #(#pair_potential,)* } } } }) }
Rust
3D
feos-org/feos
crates/feos-derive/src/residual.rs
.rs
10,319
298
use super::{implement, OPT_IMPLS}; use quote::quote; use syn::DeriveInput; pub(crate) fn expand_residual(input: DeriveInput) -> syn::Result<proc_macro2::TokenStream> { let variants = match input.data { syn::Data::Enum(syn::DataEnum { ref variants, .. }) => variants, _ => panic!("this derive macro only works on enums"), }; let residual = impl_residual(&input.ident, variants); let molar_weight = impl_molar_weight(&input.ident, variants)?; let parameter_info = impl_parameter_info(&input.ident, variants)?; let entropy_scaling = impl_entropy_scaling(&input.ident, variants)?; Ok(quote! { #residual #molar_weight #parameter_info #entropy_scaling }) } fn impl_residual( ident: &syn::Ident, variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, ) -> proc_macro2::TokenStream { let components = variants.iter().map(|v| { let name = &v.ident; quote! { Self::#name(residual) => residual.components() } }); let compute_max_density = variants.iter().map(|v| { let name = &v.ident; quote! { Self::#name(residual) => residual.compute_max_density(moles) } }); let reduced_helmholtz_energy_density_contributions = variants.iter().map(|v| { let name = &v.ident; quote! { Self::#name(residual) => residual.reduced_helmholtz_energy_density_contributions(state) } }); // let subset = variants.iter().map(|v| { // let name = &v.ident; // quote! { // Self::#name(residual) => Self::#name(residual.subset(component_list).into()) // } // }); quote! { impl ResidualDyn for #ident { fn components(&self) -> usize { match self { #(#components,)* } } fn compute_max_density<D: DualNum<f64> + Copy>(&self, moles: &DVector<D>) -> D { match self { #(#compute_max_density,)* } } fn reduced_helmholtz_energy_density_contributions<D: DualNum<f64> + Copy>(&self, state: &StateHD<D>) -> Vec<(&'static str, D)> { match self { #(#reduced_helmholtz_energy_density_contributions,)* } } // fn subset(&self, component_list: &[usize]) -> Self { // match self { // #(#subset,)* // } // } } } } fn impl_molar_weight( ident: &syn::Ident, variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, ) -> syn::Result<proc_macro2::TokenStream> { let mut molar_weight = Vec::new(); let mut has_molar_weight = Vec::new(); for v in variants.iter() { let name = &v.ident; if implement("molar_weight", v, &OPT_IMPLS)? { molar_weight.push(quote! { Self::#name(eos) => eos.molar_weight() }); has_molar_weight.push(quote! { Self::#name(_) => true }); } else { molar_weight.push(quote! { Self::#name(eos) => panic!("{} does not provide molar weights and can not be used to calculate mass-specific properties", stringify!(#name)) }); has_molar_weight.push(quote! { Self::#name(_) => false }); } } Ok(quote! { impl Molarweight for #ident { fn molar_weight(&self) -> MolarWeight<DVector<f64>> { match self { #(#molar_weight,)* } } } impl #ident { pub fn has_molar_weight(&self) -> bool { match self { #(#has_molar_weight,)* } } } }) } fn impl_parameter_info( ident: &syn::Ident, variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, ) -> syn::Result<proc_macro2::TokenStream> { let mut pure_parameters = Vec::new(); let mut binary_parameters = Vec::new(); let mut association_parameters_ab = Vec::new(); let mut association_parameters_cc = Vec::new(); for v in variants.iter() { let name = &v.ident; if implement("parameter_info", v, &OPT_IMPLS)? { pure_parameters.push(quote! { Self::#name(eos) => eos.parameters.pure_parameters() }); binary_parameters.push(quote! { Self::#name(eos) => eos.parameters.binary_parameters() }); association_parameters_ab.push(quote! { Self::#name(eos) => eos.parameters.association_parameters_ab() }); association_parameters_cc.push(quote! { Self::#name(eos) => eos.parameters.association_parameters_cc() }); } else { pure_parameters.push(quote! { Self::#name(eos) => panic!("{} does not provide parameters", stringify!(#name)) }); binary_parameters.push(quote! { Self::#name(eos) => panic!("{} does not provide parameters", stringify!(#name)) }); association_parameters_ab.push(quote! { Self::#name(eos) => panic!("{} does not provide parameters", stringify!(#name)) }); association_parameters_cc.push(quote! { Self::#name(eos) => panic!("{} does not provide parameters", stringify!(#name)) }); } } Ok(quote! { impl #ident { pub fn pure_parameters(&self) -> IndexMap<String, DVector<f64>> { match self { #(#pure_parameters,)* } } pub fn binary_parameters(&self) -> IndexMap<String, DMatrix<f64>> { match self { #(#binary_parameters,)* } } pub fn association_parameters_ab(&self) -> IndexMap<String, DMatrix<f64>> { match self { #(#association_parameters_ab,)* } } pub fn association_parameters_cc(&self) -> IndexMap<String, DMatrix<f64>> { match self { #(#association_parameters_cc,)* } } } }) } fn impl_entropy_scaling( ident: &syn::Ident, variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, ) -> syn::Result<proc_macro2::TokenStream> { let mut etar = Vec::new(); let mut etac = Vec::new(); let mut dr = Vec::new(); let mut dc = Vec::new(); let mut thcr = Vec::new(); let mut thcc = Vec::new(); for v in variants.iter() { let name = &v.ident; if implement("entropy_scaling", v, &OPT_IMPLS)? { etar.push(quote! { Self::#name(eos) => eos.viscosity_reference(temperature, volume, moles) }); etac.push(quote! { Self::#name(eos) => eos.viscosity_correlation(s_res, x) }); dr.push(quote! { Self::#name(eos) => eos.diffusion_reference(temperature, volume, moles) }); dc.push(quote! { Self::#name(eos) => eos.diffusion_correlation(s_res, x) }); thcr.push(quote! { Self::#name(eos) => eos.thermal_conductivity_reference(temperature, volume, moles) }); thcc.push(quote! { Self::#name(eos) => eos.thermal_conductivity_correlation(s_res, x) }); } else { etar.push(quote! { Self::#name(eos) => panic!("{} does not implement entropy scaling for transport properties!", stringify!(#name)) }); etac.push(quote! { Self::#name(eos) => panic!("{} does not implement entropy scaling for transport properties!", stringify!(#name)) }); dr.push(quote! { Self::#name(eos) => panic!("{} does not implement entropy scaling for transport properties!", stringify!(#name)) }); dc.push(quote! { Self::#name(eos) => panic!("{} does not implement entropy scaling for transport properties!", stringify!(#name)) }); thcr.push(quote! { Self::#name(eos) => panic!("{} does not implement entropy scaling for transport properties!", stringify!(#name)) }); thcc.push(quote! { Self::#name(eos) => panic!("{} does not implement entropy scaling for transport properties!", stringify!(#name)) }); } } Ok(quote! { impl EntropyScaling for #ident { fn viscosity_reference( &self, temperature: Temperature, volume: Volume, moles: &Moles<DVector<f64>>, ) -> Viscosity { match self { #(#etar,)* } } fn viscosity_correlation(&self, s_res: f64, x: &DVector<f64>) -> f64 { match self { #(#etac,)* } } fn diffusion_reference( &self, temperature: Temperature, volume: Volume, moles: &Moles<DVector<f64>>, ) -> Diffusivity { match self { #(#dr,)* } } fn diffusion_correlation(&self, s_res: f64, x: &DVector<f64>) -> f64 { match self { #(#dc,)* } } fn thermal_conductivity_reference( &self, temperature: Temperature, volume: Volume, moles: &Moles<DVector<f64>>, ) -> ThermalConductivity { match self { #(#thcr,)* } } fn thermal_conductivity_correlation(&self, s_res: f64, x: &DVector<f64>) -> f64 { match self { #(#thcc,)* } } } }) }
Rust
3D
feos-org/feos
crates/feos-core/CHANGELOG.md
.md
22,774
276
# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). > [!IMPORTANT] > This file contains changes up to `feos-core` v0.8.0. For newer versions, changes are documented for the entire project rather than individual crates [here](../../CHANGELOG.md). ## Unreleased ## [0.8.0] - 2024-12-28 ### Added - Added `ReferenceSystem` trait to handle conversion between SI units and reduced units. [#257](https://github.com/feos-org/feos/pull/257) - Readded `Molarweight` trait to avoid extra implementation requirements for some models. [#258](https://github.com/feos-org/feos/pull/258) ### Removed - Removed `si` module after the compile-time units are incorporated into the `quantity` crate. [#257](https://github.com/feos-org/feos/pull/257) ### Packaging - Updated `quantity` dependency to 0.10. [#262](https://github.com/feos-org/feos/pull/262) - Updated `num-dual` dependency to 0.11. [#262](https://github.com/feos-org/feos/pull/262) - Updated `numpy` and `PyO3` dependencies to 0.23. [#262](https://github.com/feos-org/feos/pull/262) ## [0.7.0] - 2024-05-21 ### Added - Added specific isochoric and isobaric heat capacities to the Python interface. [#223](https://github.com/feos-org/feos/pull/223)) - Added `to_dict` method for `PyStateVec`. [#224](https://github.com/feos-org/feos/pull/224) - Added `State::henrys_law_constant` to calculate Henry's law constants for arbitrary mixtures. [#234](https://github.com/feos-org/feos/pull/234) ### Changed - Changed the interface for Helmholtz energy calculation in `Residual` and `IdealGas` which removes the need for the `HelmholtzEnergy` and `HelmholtzEnergyDual` traits and trait objects. [#226](https://github.com/feos-org/feos/pull/226) - Adjusted Python macros to account for the removal of trait objects. [#226](https://github.com/feos-org/feos/pull/226) - Changed deprecated `remove` method of `IndexMap` to `shift_remove`. [#226](https://github.com/feos-org/feos/pull/226) - Added `contributions` argument to `State::chemical_potential_contributions` and fixed the corresponding Python function. [#228](https://github.com/feos-org/feos/pull/228) ### Removed - Removed `HelmholtzEnergyDual`, `HelmholzEnergy`, `DeBroglieWavelengthDual` and `DeBroglieWavelength` traits. [#226](https://github.com/feos-org/feos/pull/226) ### Fixed - Added comparison for pressures of both phases in `PyPhaseDiagram.to_dict` to make the method work with `spinodal` constructor. [#224](https://github.com/feos-org/feos/pull/224) - Enforce the total moles when providing `State::new` with molefracs that do not add up to 1. [#227](https://github.com/feos-org/feos/pull/227) ### Packaging - Updated `quantity` dependency to 0.8. [#238](https://github.com/feos-org/feos/pull/238) - Updated `num-dual` dependency to 0.9. [#238](https://github.com/feos-org/feos/pull/238) - Updated `numpy` and `PyO3` dependencies to 0.21. [#238](https://github.com/feos-org/feos/pull/238) ## [0.6.1] - 2024-01-11 ### Fixed - Improved convergence of `tp_flash` for certain edge cases. [#219](https://github.com/feos-org/feos/pull/219) ## [0.6.0] - 2023-12-19 ### Added - Added `EquationOfState::ideal_gas` to initialize an equation of state that only consists of an ideal gas contribution. [#204](https://github.com/feos-org/feos/pull/204) - Added `NoBinaryModelRecord` for models that do not use binary interaction parameters. [#211](https://github.com/feos-org/feos/pull/211) ### Changed - Made members of `JobackRecord` public. [#206](https://github.com/feos-org/feos/pull/206) ### Removed - Removed `JobackParameters` and `JobackBinaryRecord`. [#204](https://github.com/feos-org/feos/pull/204) - Moved the remaining implementation of `Joback` to `feos`. [#204](https://github.com/feos-org/feos/pull/204) ## [0.5.1] - 2023-11-23 ### Fixed - Aligned how binary segment records are treated in Rust and Python. [#200](https://github.com/feos-org/feos/pull/200) ## [0.5.0] - 2023-10-20 ### Added - Added new functions `isenthalpic_compressibility`, `thermal_expansivity` and `grueneisen_parameter` to `State`. [#154](https://github.com/feos-org/feos/pull/154) - Readded `PhaseEquilibrium::new_npt` to the public interface in Rust and Python. [#164](https://github.com/feos-org/feos/pull/164) - Added `Components`, `Residual`, `IdealGas` and `DeBroglieWavelength` traits to decouple ideal gas models from residual models. [#158](https://github.com/feos-org/feos/pull/158) - Added `JobackParameters` struct that implements `Parameters` including Python bindings. [#158](https://github.com/feos-org/feos/pull/158) - Added `Parameter::from_model_records` as a simpler interface to generate parameters. [#169](https://github.com/feos-org/feos/pull/169) - Added optional `Phase` argument for constructors of dynamic properties of `DataSet`s. [#174](https://github.com/feos-org/feos/pull/174) - Added `molar_weight` method to `Residual` trait. [#177](https://github.com/feos-org/feos/pull/177) - Added molar versions for entropy, enthalpy, etc. for residual properties. [#177](https://github.com/feos-org/feos/pull/177) - Python only: Added `SmartsRecord` and `ChemicalRecord.from_smiles` that uses rdkit to calculate segments and bonds from a SMILES code. [#191](https://github.com/feos-org/feos/pull/191) - Python only: Added `from_smiles` and `from_json_smiles` to parameter objects that build parameters from SMILES codes using rdkit. [#191](https://github.com/feos-org/feos/pull/191) ### Changed - Changed constructors of `Parameter` trait to return `Result`s. [#161](https://github.com/feos-org/feos/pull/161) - Changed `EquationOfState` from a trait to a `struct` that is generic over `Residual` and `IdealGas` and implements all necessary traits to be used as equation of state including the ideal gas contribution. [#158](https://github.com/feos-org/feos/pull/158) - The `Parameter` trait no longer has an associated type `IdealGas`. [#158](https://github.com/feos-org/feos/pull/158) - Split properties of `State` into those that require the `Residual` trait (`residual_properties.rs`) and those that require both `Residual + IdealGas` (`properties.rs`). [#158](https://github.com/feos-org/feos/pull/158) - State creation routines are split into those that can be used with `Residual` and those that require `Residual + IdealGas`. [#158](https://github.com/feos-org/feos/pull/158) - `Contributions` enum no longer includes the `ResidualNpt` variant. `ResidualNvt` variant is renamed to `Residual`. [#158](https://github.com/feos-org/feos/pull/158) - Moved `Verbosity` and `SolverOption` from `phase_equilibria` module to `lib.rs`. [#158](https://github.com/feos-org/feos/pull/158) - Moved `StateVec` into own file and module. [#158](https://github.com/feos-org/feos/pull/158) - Ideal gas and residual Helmholtz energy models can now be separately implemented in Python via the `PyIdealGas` and `PyResidual` structs. [#158](https://github.com/feos-org/feos/pull/158) - Bubble and dew point iterations will not attempt a second iteration if no solution is found for the given initial pressure. [#166](https://github.com/feos-org/feos/pull/166) - Made the binary records in the constructions and getters of the `Parameter` trait optional. [#169](https://github.com/feos-org/feos/pull/169) - Changed the second argument of `new_binary` in Python from a `BinaryRecord` to the corresponding binary model record (analogous to the Rust implementation). [#169](https://github.com/feos-org/feos/pull/169) - Renamed `c_v` and `c_p` to `isochoric_heat_capacity` and `isobaric_heat_capacity`, respectively, and added prefixes for molar and specific properties. [#177](https://github.com/feos-org/feos/pull/177) - `State.helmholtz_energy_contributions` in Python now accepts optional `Contributions`. [#177](https://github.com/feos-org/feos/pull/177) - Changed `StateVec` Python getters for entropy and enthalpy to functions that accept optional `Contributions`. [#177](https://github.com/feos-org/feos/pull/177) - `PhaseDiagram.to_dict` in Python now accepts optional `Contributions` and includes mass specific properties. [#177](https://github.com/feos-org/feos/pull/177) - Replaced the run-time unit checks from the `quantity` crate with compile-time unit checks with custom implementations in the new `feos_core.si` module. [#181](https://github.com/feos-org/feos/pull/181) - Renamed the keyword argument `search_option` to `identifier_option` in parameter constructors. [#196](https://github.com/feos-org/feos/pull/196) ### Removed - Removed `EquationOfState` trait. [#158](https://github.com/feos-org/feos/pull/158) - Removed ideal gas dependencies from `PureRecord` and `SegmentRecord`. [#158](https://github.com/feos-org/feos/pull/158) - Removed Python getter and setter functions and optional arguments for ideal gas records in macros. [#158](https://github.com/feos-org/feos/pull/158) - Removed `MolarWeight` trait. [#177](https://github.com/feos-org/feos/pull/177) ### Fixed - The vapor and liquid states in a bubble or dew point iteration are assigned correctly according to the inputs, rather than based on the mole density which can be incorrect for mixtures with large differences in molar weights. [#166](https://github.com/feos-org/feos/pull/166) - `Parameter::from_multiple_json` returns the correct parameters if a component occurs in multiple input files. [#196](https://github.com/feos-org/feos/pull/196) ### Packaging - Updated `quantity` dependency to 0.7. - Updated `num-dual` dependency to 0.8. [#137](https://github.com/feos-org/feos/pull/137) - Updated `numpy` and `PyO3` dependencies to 0.20. ## [0.4.2] - 2023-04-03 ### Fixed - Fixed a wrong reference state in the implementation of the Peng-Robinson equation of state. [#151](https://github.com/feos-org/feos/pull/151) ## [0.4.1] - 2023-03-20 ### Fixed - Fixed a bug that caused the bubble and dew point solvers to ignore the initial values for the opposing phase given by the user if no initial value for temperature/pressure was also given. [#138](https://github.com/feos-org/feos/pull/138) ## [0.4.0] - 2023-01-27 ### Added - Added `PhaseDiagram::par_pure` that uses rayon to calculate phase diagrams in parallel. [#57](https://github.com/feos-org/feos/pull/57) - Added `StateVec::moles` getter. [#113](https://github.com/feos-org/feos/pull/113) - Added public constructors `PhaseDiagram::new` and `StateVec::new` that allow the creation of the respective structs from a list of `PhaseEquilibrium`s or `State`s in Rust and Python. [#113](https://github.com/feos-org/feos/pull/113) - Added new variant `EosError::Error` which allows dispatching generic errors that are not covered by the existing variants. [#98](https://github.com/feos-org/feos/pull/98) - Added `binary_records` getter for parameter classes in Python. [#104](https://github.com/feos-org/feos/pull/104) - Added `BinaryRecord::from_json` and `BinarySegmentRecord::from_json` that read a list of records from a file. [#104](https://github.com/feos-org/feos/pull/104) ### Changed - Added `Sync` and `Send` as supertraits to `EquationOfState`. [#57](https://github.com/feos-org/feos/pull/57) - Added `Dual2_64` dual number to `HelmholtzEnergy` trait to facilitate efficient non-mixed second order derivatives. [#94](https://github.com/feos-org/feos/pull/94) - Renamed `PartialDerivative::Second` to `PartialDerivative::SecondMixed`. [#94](https://github.com/feos-org/feos/pull/94) - Added `PartialDerivative::Second` to enable non-mixed second order partial derivatives. [#94](https://github.com/feos-org/feos/pull/94) - Changed `dp_dv_` and `ds_dt_` to use `Dual2_64` instead of `HyperDual64`. [#94](https://github.com/feos-org/feos/pull/94) - Added `get_or_insert_with_d2_64` to `Cache`. [#94](https://github.com/feos-org/feos/pull/94) - The critical point algorithm now uses vector dual numbers to reduce the number of model evaluations and computation times. [#96](https://github.com/feos-org/feos/pull/96) - Renamed `State::molar_volume` to `State::partial_molar_volume` and `State::ln_phi_pure` to `State::ln_phi_pure_liquid`. [#107](https://github.com/feos-org/feos/pull/107) - Added a const generic parameter to `PhaseDiagram` that accounts for the number of phases analogously to `PhaseEquilibrium`. [#113](https://github.com/feos-org/feos/pull/113) - Removed generics for units in all structs and traits in favor of static SI units. [#115](https://github.com/feos-org/feos/pull/115) ### Fixed - Automatically generate all required data types to calculate higher order derivatives for equations of state implemented in Python. [#114](https://github.com/feos-org/feos/pull/114) ### Packaging - Updated `pyo3` and `numpy` dependencies to 0.18. [#119](https://github.com/feos-org/feos/pull/119) - Updated `quantity` dependency to 0.6. [#119](https://github.com/feos-org/feos/pull/119) - Updated `num-dual` dependency to 0.6. [#119](https://github.com/feos-org/feos/pull/119) ### Fixed - `Parameter::from_segments` only calculates binary interaction parameters for unlike molecules. [#104](https://github.com/feos-org/feos/pull/104) ## [0.3.1] - 2022-08-25 ### Added - Added `State::spinodal` that calculates both spinodal points for a given temperature and composition using the same objective function that is also used in the critical point calculation. [#23](https://github.com/feos-org/feos/pull/23) - Added `PhaseDiagram::bubble_point_line`, `PhaseDiagram::dew_point_line`, and `PhaseDiagram::spinodal` to calculate phase envelopes for mixtures with fixed compositions. [#23](https://github.com/feos-org/feos/pull/23) ### Changed - Made binary parameters in `from_records` Python routine an `Option`. [#35](https://github.com/feos-org/feos/pull/35) - Added panic with message when parsing missing Identifiers variants. [#35](https://github.com/feos-org/feos/pull/35) - Generalized the initialization routines for pure component VLEs at given temperature to multicomponent systems. [#23](https://github.com/feos-org/feos/pull/23) - Increased the default number of maximum iterations for binary critical point calculations from 50 to 200. [#48](https://github.com/feos-org/feos/pull/48) ### Removed - Removed the (internal) `SpinodalPoint` struct that was used within density iterations in favor of a simpler interface. [#23](https://github.com/feos-org/feos/pull/23) ### Fixed - Avoid panicking when calculating `ResidualNpt` properties of states with negative pressures. [#42](https://github.com/feos-org/feos/pull/42) ## [0.3.0] - 2022-06-13 ### Added - Added `pure_records` getter in the `impl_parameter` macro. [#54](https://github.com/feos-org/feos-core/pull/54) - Implemented `Deref` and `IntoIterator` for `StateVec` for additional vector functionalities of the `StateVec`. [#55](https://github.com/feos-org/feos-core/pull/55) - Added `StateVec.__len__` and `StateVec.__getitem__` to allow indexing and iterating over `StateVec`s in Python. [#55](https://github.com/feos-org/feos-core/pull/55) - Added `SegmentCount` trait that allows the construction of parameter sets from arbitrary chemical records. [#56](https://github.com/feos-org/feos-core/pull/56) - Added `ParameterHetero` trait to generically provide utility functions for parameter sets of heterosegmented Helmholtz energy models. [#56](https://github.com/feos-org/feos-core/pull/56) ### Changed - Changed datatype for binary parameters in interfaces of the `from_records` and `new_binary` methods for parameters to take either numpy arrays of `f64` or a list of `BinaryRecord` as input. [#54](https://github.com/feos-org/feos-core/pull/54) - Modified `PhaseDiagram.to_dict` function in Python to account for pure components and mixtures. [#55](https://github.com/feos-org/feos-core/pull/55) - Changed `StateVec` to a tuple struct. [#55](https://github.com/feos-org/feos-core/pull/55) - Made `cas` field of `Identifier` optional. [#56](https://github.com/feos-org/feos-core/pull/56) - Added type parameter to `FromSegments` and made its `from_segments` function fallible for more control over model limitations. [#56](https://github.com/feos-org/feos-core/pull/56) - Reverted `ChemicalRecord` back to a struct that only contains the structural information (and not segment and bond counts). [#56](https://github.com/feos-org/feos-core/pull/56) - Made `IdentifierOption` directly usable in Python using `PyO3`'s new `#[pyclass]` for fieldless enums feature. [#58](https://github.com/feos-org/feos-core/pull/58) ## [0.2.0] - 2022-04-12 ### Added - Added conversions between `ParameterError` and `EosError` to improve the error messages in some cases. [#40](https://github.com/feos-org/feos-core/pull/40) - Added new struct `StateVec`, that gives easy access to properties of lists of states, e.g. in phase diagrams. [#48](https://github.com/feos-org/feos-core/pull/48) - Added `ln_symmetric_activity_coefficient` and `ln_phi_pure` to the list of state properties that can be calculated. [#50](https://github.com/feos-org/feos-core/pull/50) ### Changed - Removed `State` from `EntropyScaling` trait and adjusted associated methods to use temperature, volume and moles instead of state. [#36](https://github.com/feos-org/feos-core/pull/36) - Replaced the outer loop iterations for the critical point of binary systems with dedicated algorithms. [#34](https://github.com/feos-org/feos-core/pull/34) - Renamed `VLEOptions` to `SolverOptions`. [#38](https://github.com/feos-org/feos-core/pull/38) - Renamed methods of `StateBuilder` and the parameters in the `State` constructor in python to `molar_enthalpy`, `molar_entropy`, and `molar_internal_energy`. [#35](https://github.com/feos-org/feos-core/pull/35) - Removed `PyContributions` and `PyVerbosity` in favor of a simpler implementation using `PyO3`'s new `#[pyclass]` for fieldless enums feature. [#41](https://github.com/feos-org/feos-core/pull/41) - Renamed `Contributions::Residual` to `Contributions::ResidualNvt` and `Contributions::ResidualP` to `Contributions::ResidualNpt`. [#43](https://github.com/feos-org/feos-core/pull/43) - Renamed macro `impl_vle_state!` to `impl_phase_equilibrium!`. [#48](https://github.com/feos-org/feos-core/pull/48) - Removed `_t` and `_p` functions in favor of simpler interfaces. The kind of specification (temperature or pressure) is determined from the unit of the argument. [#48](https://github.com/feos-org/feos-core/pull/48) - `PhaseEquilibrium::pure_t`, `PhaseEquilibrium::pure_p` -> `PhaseEquilibrium::pure` - `PhaseEquilibrium::vle_pure_comps_t`, `PhaseEquilibrium::vle_pure_comps_p` -> `PhaseEquilibrium::vle_pure_comps`\ The `PhaseEquilibria` returned by this function now have the same number of components as the (mixture) eos, that it is called with. - `PhaseEquilibrium::bubble_point_tx`, `PhaseEquilibrium::bubble_point_px` -> `PhaseEquilibrium::bubble_point` - `PhaseEquilibrium::dew_point_tx`, `PhaseEquilibrium::dew_point_px` -> `PhaseEquilibrium::dew_point` - `PhaseEquilibrium::heteroazeotrope_t`, `PhaseEquilibrium::heteroazeotrope_p` -> `PhaseEquilibrium::heteroazeotrope` - `State::critical_point_binary_t`, `State::critical_point_binary_p` -> `State::crititcal_point_binary` - Combined `PhaseDiagramPure` and `PhaseDiagramBinary` into a single struct `PhaseDiagram` and renamed its constructors. Properties of the phase diagram are available from the `vapor` and `liquid` getters, that return `StateVec`s. [#48](https://github.com/feos-org/feos-core/pull/48) - `PhaseDiagramPure::new` -> `PhaseDiagram::pure` - `PhaseDiagramBinary::new_txy`, `PhaseDiagramBinary::new_pxy` -> `PhaseDiagram::binary_vle` - `PhaseDiagramBinary::new_txy_lle`, `PhaseDiagramBinary::new_pxy_lle` -> `PhaseDiagram::lle` - `PhaseDiagramHetero::new_txy`, `PhaseDiagramHetero::new_pxy` -> `PhaseDiagram::binary_vlle`\ which still returns an instance of `PhaseDiagramHetero` - Changed the internal implementation of the Peng-Robinson equation of state to use contributions like the more complex equations of state and removed the suggestion to overwrite the `evaluate_residual` function of `EquationOfState`. [#51](https://github.com/feos-org/feos-core/pull/51) - Moved the creation of the python module to the `build_wheel` auxilliary crate, so that only the relevant structs and macros are available for the dependents. [#47](https://github.com/feos-org/feos-core/pull/47) ### Removed - Removed the `utils` module containing `DataSet` and `Estimator` in favor of a separate crate. [#47](https://github.com/feos-org/feos-core/pull/47) ### Packaging - Updated `pyo3` and `numpy` dependencies to 0.16. - Updated `num-dual` dependency to 0.5. - Updated `quantity` dependency to 0.5. ## [0.1.5] - 2022-02-21 ### Fixed - Fixed bug in `predict` of `Estimator`. [#30](https://github.com/feos-org/feos-core/pull/30) ### Added - Add `pyproject.toml`. [#29](https://github.com/feos-org/feos-core/pull/29) ## [0.1.4] - 2022-02-18 ### Fixed - Fix state constructor for `T`, `p`, `V`, `x_i` specification. [#26](https://github.com/feos-org/feos-core/pull/26) ### Added - Added method `predict` to `Estimator`. [#27](https://github.com/feos-org/feos-core/pull/27) ### Changed - Changed method for vapor pressure in `DataSet` to `vapor_pressure` (was `pressure` of VLE liquid phase). [#27](https://github.com/feos-org/feos-core/pull/27) ## [0.1.3] - 2022-01-21 ### Added - Added the following properties to `State`: [#21](https://github.com/feos-org/feos-core/pull/21) - `dp_drho` partial derivative of pressure w.r.t. density - `d2p_drho2` second partial derivative of pressure w.r.t. density - `isothermal_compressibility` the isothermal compressibility - Read a list of segment records directly from a JSON file. [#22](https://github.com/feos-org/feos-core/pull/22) ## [0.1.2] - 2022-01-10 ### Changed - Changed `ChemicalRecord` to an enum that can hold either the full structural information of a molecule or only segment and bond counts and added an `Identifier`. [#19](https://github.com/feos-org/feos-core/pull/19) - Removed the `chemical_record` field from `PureRecord` and made `model_record` non-optional. [#19](https://github.com/feos-org/feos-core/pull/19) ## [0.1.1] - 2021-12-22 ### Added - Added `from_multiple_json` function to `Parameter` trait that is able to read parameters from separate JSON files. [#15](https://github.com/feos-org/feos-core/pull/15) ### Packaging - Updated `pyo3` and `numpy` dependencies to 0.15. - Updated `quantity` dependency to 0.4. - Updated `num-dual` dependency to 0.4. - Removed `ndarray-linalg` and `ndarray-stats` dependencies. - Removed obsolete features for the selection of the BLAS/LAPACK library. ## [0.1.0] - 2021-12-02 ### Added - Initial release
Markdown
3D
feos-org/feos
crates/feos-core/src/lib.rs
.rs
14,824
491
#![warn(clippy::all)] #![allow(clippy::reversed_empty_ranges)] #![warn(clippy::allow_attributes)] use quantity::{Quantity, SIUnit}; use std::ops::{Div, Mul}; /// Print messages with level `Verbosity::Iter` or higher. #[macro_export] macro_rules! log_iter { ($verbosity:expr, $($arg:tt)*) => { if $verbosity >= Verbosity::Iter { println!($($arg)*); } } } /// Print messages with level `Verbosity::Result` or higher. #[macro_export] macro_rules! log_result { ($verbosity:expr, $($arg:tt)*) => { if $verbosity >= Verbosity::Result { println!($($arg)*); } } } mod ad; pub mod cubic; mod density_iteration; mod equation_of_state; mod errors; pub mod parameter; mod phase_equilibria; mod state; pub use ad::{ParametersAD, PropertiesAD}; pub use equation_of_state::{ EntropyScaling, EquationOfState, IdealGas, Molarweight, NoResidual, Residual, ResidualDyn, Subset, Total, }; pub use errors::{FeosError, FeosResult}; #[cfg(feature = "ndarray")] pub use phase_equilibria::{PhaseDiagram, PhaseDiagramHetero}; pub use phase_equilibria::{PhaseEquilibrium, TemperatureOrPressure}; pub use state::{Contributions, DensityInitialization, State, StateBuilder, StateHD, StateVec}; /// Level of detail in the iteration output. #[derive(Copy, Clone, PartialOrd, PartialEq, Eq, Default)] pub enum Verbosity { /// Do not print output. #[default] None, /// Print information about the success of failure of the iteration. Result, /// Print a detailed outpur for every iteration. Iter, } /// Options for the various phase equilibria solvers. /// /// If the values are [None], solver specific default /// values are used. #[derive(Copy, Clone, Default)] pub struct SolverOptions { /// Maximum number of iterations. pub max_iter: Option<usize>, /// Tolerance. pub tol: Option<f64>, /// Iteration outpput indicated by the [Verbosity] enum. pub verbosity: Verbosity, } impl From<(Option<usize>, Option<f64>, Option<Verbosity>)> for SolverOptions { fn from(options: (Option<usize>, Option<f64>, Option<Verbosity>)) -> Self { Self { max_iter: options.0, tol: options.1, verbosity: options.2.unwrap_or(Verbosity::None), } } } impl SolverOptions { pub fn new() -> Self { Self::default() } pub fn max_iter(mut self, max_iter: usize) -> Self { self.max_iter = Some(max_iter); self } pub fn tol(mut self, tol: f64) -> Self { self.tol = Some(tol); self } pub fn verbosity(mut self, verbosity: Verbosity) -> Self { self.verbosity = verbosity; self } pub fn unwrap_or(self, max_iter: usize, tol: f64) -> (usize, f64, Verbosity) { ( self.max_iter.unwrap_or(max_iter), self.tol.unwrap_or(tol), self.verbosity, ) } } /// Reference values used for reduced properties in feos const REFERENCE_VALUES: [f64; 7] = [ 1e-12, // 1 ps 1e-10, // 1 Å 1.380649e-27, // Fixed through k_B 1.0, // 1 A 1.0, // 1 K 1.0 / 6.02214076e23, // 1/N_AV 1.0, // 1 Cd ]; const fn powi(x: f64, n: i32) -> f64 { match n { ..=-1 => powi(1.0 / x, -n), 0 => 1.0, n if n % 2 == 0 => powi(x * x, n / 2), n => x * powi(x * x, (n - 1) / 2), } } /// Conversion between reduced units and SI units. pub trait ReferenceSystem { type Inner; const T: i8; const L: i8; const M: i8; const I: i8; const THETA: i8; const N: i8; const J: i8; const FACTOR: f64 = powi(REFERENCE_VALUES[0], Self::T as i32) * powi(REFERENCE_VALUES[1], Self::L as i32) * powi(REFERENCE_VALUES[2], Self::M as i32) * powi(REFERENCE_VALUES[3], Self::I as i32) * powi(REFERENCE_VALUES[4], Self::THETA as i32) * powi(REFERENCE_VALUES[5], Self::N as i32) * powi(REFERENCE_VALUES[6], Self::J as i32); fn from_reduced(value: Self::Inner) -> Self where Self::Inner: Mul<f64, Output = Self::Inner>; fn to_reduced(&self) -> Self::Inner where for<'a> &'a Self::Inner: Div<f64, Output = Self::Inner>; fn into_reduced(self) -> Self::Inner where Self::Inner: Div<f64, Output = Self::Inner>; } /// Conversion to and from reduced units impl< Inner, const T: i8, const L: i8, const M: i8, const I: i8, const THETA: i8, const N: i8, const J: i8, > ReferenceSystem for Quantity<Inner, SIUnit<T, L, M, I, THETA, N, J>> { type Inner = Inner; const T: i8 = T; const L: i8 = L; const M: i8 = M; const I: i8 = I; const THETA: i8 = THETA; const N: i8 = N; const J: i8 = J; fn from_reduced(value: Inner) -> Self where Inner: Mul<f64, Output = Inner>, { Self::new(value * Self::FACTOR) } fn to_reduced(&self) -> Inner where for<'a> &'a Inner: Div<f64, Output = Inner>, { self.convert_to(Quantity::new(Self::FACTOR)) } fn into_reduced(self) -> Inner where Inner: Div<f64, Output = Inner>, { self.convert_into(Quantity::new(Self::FACTOR)) } } #[cfg(test)] mod tests { use crate::Contributions; use crate::FeosResult; use crate::StateBuilder; use crate::cubic::*; use crate::equation_of_state::{EquationOfState, IdealGas}; use crate::parameter::*; use approx::*; use num_dual::DualNum; use quantity::{BAR, KELVIN, MOL, RGAS}; // Only to be able to instantiate an `EquationOfState` #[derive(Clone, Copy)] struct NoIdealGas; impl IdealGas for NoIdealGas { fn ideal_gas_model(&self) -> &'static str { "NoIdealGas" } fn ln_lambda3<D: DualNum<f64> + Copy>(&self, _: D) -> D { unreachable!() } } fn pure_record_vec() -> Vec<PureRecord<PengRobinsonRecord, ()>> { let records = r#"[ { "identifier": { "cas": "74-98-6", "name": "propane", "iupac_name": "propane", "smiles": "CCC", "inchi": "InChI=1/C3H8/c1-3-2/h3H2,1-2H3", "formula": "C3H8" }, "tc": 369.96, "pc": 4250000.0, "acentric_factor": 0.153, "molarweight": 44.0962 }, { "identifier": { "cas": "106-97-8", "name": "butane", "iupac_name": "butane", "smiles": "CCCC", "inchi": "InChI=1/C4H10/c1-3-4-2/h3-4H2,1-2H3", "formula": "C4H10" }, "tc": 425.2, "pc": 3800000.0, "acentric_factor": 0.199, "molarweight": 58.123 } ]"#; serde_json::from_str(records).expect("Unable to parse json.") } #[test] fn validate_residual_properties() -> FeosResult<()> { let mixture = pure_record_vec(); let propane = &mixture[0]; let parameters = PengRobinsonParameters::new_pure(propane.clone())?; let residual = PengRobinson::new(parameters); let sr = StateBuilder::new(&&residual) .temperature(300.0 * KELVIN) .pressure(1.0 * BAR) .total_moles(2.0 * MOL) .build()?; let parameters = PengRobinsonParameters::new_pure(propane.clone())?; let residual = PengRobinson::new(parameters); let eos = EquationOfState::new(vec![NoIdealGas], residual); let s = StateBuilder::new(&&eos) .temperature(300.0 * KELVIN) .pressure(1.0 * BAR) .total_moles(2.0 * MOL) .build()?; // pressure assert_relative_eq!( s.pressure(Contributions::Total), sr.pressure(Contributions::Total), max_relative = 1e-15 ); assert_relative_eq!( s.pressure(Contributions::Residual), sr.pressure(Contributions::Residual), max_relative = 1e-15 ); assert_relative_eq!( s.compressibility(Contributions::Total), sr.compressibility(Contributions::Total), max_relative = 1e-15 ); assert_relative_eq!( s.compressibility(Contributions::Residual), sr.compressibility(Contributions::Residual), max_relative = 1e-15 ); // residual properties assert_relative_eq!( s.helmholtz_energy(Contributions::Residual), sr.residual_helmholtz_energy(), max_relative = 1e-15 ); assert_relative_eq!( s.molar_helmholtz_energy(Contributions::Residual), sr.residual_molar_helmholtz_energy(), max_relative = 1e-15 ); assert_relative_eq!( s.entropy(Contributions::Residual), sr.residual_entropy(), max_relative = 1e-15 ); assert_relative_eq!( s.molar_entropy(Contributions::Residual), sr.residual_molar_entropy(), max_relative = 1e-15 ); assert_relative_eq!( s.enthalpy(Contributions::Residual), sr.residual_enthalpy(), max_relative = 1e-15 ); assert_relative_eq!( s.molar_enthalpy(Contributions::Residual), sr.residual_molar_enthalpy(), max_relative = 1e-15 ); assert_relative_eq!( s.internal_energy(Contributions::Residual), sr.residual_internal_energy(), max_relative = 1e-15 ); assert_relative_eq!( s.molar_internal_energy(Contributions::Residual), sr.residual_molar_internal_energy(), max_relative = 1e-15 ); assert_relative_eq!( s.gibbs_energy(Contributions::Residual) - s.total_moles * RGAS * s.temperature * s.compressibility(Contributions::Total).ln(), sr.residual_gibbs_energy(), max_relative = 1e-15 ); assert_relative_eq!( s.molar_gibbs_energy(Contributions::Residual) - RGAS * s.temperature * s.compressibility(Contributions::Total).ln(), sr.residual_molar_gibbs_energy(), max_relative = 1e-15 ); assert_relative_eq!( s.chemical_potential(Contributions::Residual), sr.residual_chemical_potential(), max_relative = 1e-15 ); // pressure derivatives assert_relative_eq!( s.structure_factor(), sr.structure_factor(), max_relative = 1e-15 ); assert_relative_eq!( s.dp_dt(Contributions::Total), sr.dp_dt(Contributions::Total), max_relative = 1e-15 ); assert_relative_eq!( s.dp_dt(Contributions::Residual), sr.dp_dt(Contributions::Residual), max_relative = 1e-15 ); assert_relative_eq!( s.dp_dv(Contributions::Total), sr.dp_dv(Contributions::Total), max_relative = 1e-15 ); assert_relative_eq!( s.dp_dv(Contributions::Residual), sr.dp_dv(Contributions::Residual), max_relative = 1e-15 ); assert_relative_eq!( s.dp_drho(Contributions::Total), sr.dp_drho(Contributions::Total), max_relative = 1e-15 ); assert_relative_eq!( s.dp_drho(Contributions::Residual), sr.dp_drho(Contributions::Residual), max_relative = 1e-15 ); assert_relative_eq!( s.d2p_dv2(Contributions::Total), sr.d2p_dv2(Contributions::Total), max_relative = 1e-15 ); assert_relative_eq!( s.d2p_dv2(Contributions::Residual), sr.d2p_dv2(Contributions::Residual), max_relative = 1e-15 ); assert_relative_eq!( s.d2p_drho2(Contributions::Total), sr.d2p_drho2(Contributions::Total), max_relative = 1e-15 ); assert_relative_eq!( s.d2p_drho2(Contributions::Residual), sr.d2p_drho2(Contributions::Residual), max_relative = 1e-15 ); assert_relative_eq!( s.dp_dni(Contributions::Total), sr.dp_dni(Contributions::Total), max_relative = 1e-15 ); assert_relative_eq!( s.dp_dni(Contributions::Residual), sr.dp_dni(Contributions::Residual), max_relative = 1e-15 ); // entropy assert_relative_eq!( s.ds_dt(Contributions::Residual), sr.ds_res_dt(), max_relative = 1e-15 ); // chemical potential assert_relative_eq!( s.dmu_dt(Contributions::Residual), sr.dmu_res_dt(), max_relative = 1e-15 ); assert_relative_eq!( s.dmu_dni(Contributions::Residual), sr.dmu_dni(Contributions::Residual), max_relative = 1e-15 ); assert_relative_eq!( s.dmu_dt(Contributions::Residual), sr.dmu_res_dt(), max_relative = 1e-15 ); // fugacity assert_relative_eq!(s.ln_phi(), sr.ln_phi(), max_relative = 1e-15); assert_relative_eq!(s.dln_phi_dt(), sr.dln_phi_dt(), max_relative = 1e-15); assert_relative_eq!(s.dln_phi_dp(), sr.dln_phi_dp(), max_relative = 1e-15); assert_relative_eq!(s.dln_phi_dnj(), sr.dln_phi_dnj(), max_relative = 1e-15); assert_relative_eq!( s.thermodynamic_factor(), sr.thermodynamic_factor(), max_relative = 1e-15 ); // residual properties using multiple derivatives assert_relative_eq!( s.molar_isochoric_heat_capacity(Contributions::Residual), sr.residual_molar_isochoric_heat_capacity(), max_relative = 1e-15 ); assert_relative_eq!( s.dc_v_dt(Contributions::Residual), sr.dc_v_res_dt(), max_relative = 1e-15 ); assert_relative_eq!( s.molar_isobaric_heat_capacity(Contributions::Residual), sr.residual_molar_isobaric_heat_capacity(), max_relative = 1e-15 ); Ok(()) } }
Rust
3D
feos-org/feos
crates/feos-core/src/cubic.rs
.rs
7,266
222
//! Implementation of the Peng-Robinson equation of state. //! //! This module acts as a reference on how a simple equation //! of state - with a single contribution to the Helmholtz energy - can be implemented. //! The implementation closely follows the form of the equations given in //! [this wikipedia article](https://en.wikipedia.org/wiki/Cubic_equations_of_state#Peng%E2%80%93Robinson_equation_of_state). use crate::parameter::{Identifier, Parameters, PureRecord}; use crate::{FeosError, FeosResult, Molarweight, ResidualDyn, StateHD, Subset}; use nalgebra::{DMatrix, DVector}; use num_dual::DualNum; use quantity::MolarWeight; use serde::{Deserialize, Serialize}; use std::f64::consts::SQRT_2; const KB_A3: f64 = 13806490.0; /// Peng-Robinson parameters for a single substance. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct PengRobinsonRecord { /// critical temperature in Kelvin tc: f64, /// critical pressure in Pascal pc: f64, /// acentric factor acentric_factor: f64, } impl PengRobinsonRecord { /// Create a new pure substance record for the Peng-Robinson equation of state. pub fn new(tc: f64, pc: f64, acentric_factor: f64) -> Self { Self { tc, pc, acentric_factor, } } } /// Peng-Robinson parameters for one ore more substances. pub type PengRobinsonParameters = Parameters<PengRobinsonRecord, f64, ()>; impl PengRobinsonParameters { /// Build a simple parameter set without binary interaction parameters. pub fn new_simple( tc: &[f64], pc: &[f64], acentric_factor: &[f64], molarweight: &[f64], ) -> FeosResult<Self> { if [pc.len(), acentric_factor.len(), molarweight.len()] .iter() .any(|&l| l != tc.len()) { return Err(FeosError::IncompatibleParameters(String::from( "each component has to have parameters.", ))); } let records = (0..tc.len()) .map(|i| { let record = PengRobinsonRecord { tc: tc[i], pc: pc[i], acentric_factor: acentric_factor[i], }; let id = Identifier::default(); PureRecord::new(id, molarweight[i], record) }) .collect(); PengRobinsonParameters::new(records, vec![]) } } /// A simple version of the Peng-Robinson equation of state. pub struct PengRobinson { /// Parameters pub parameters: PengRobinsonParameters, /// Critical temperature in Kelvin tc: DVector<f64>, a: DVector<f64>, b: DVector<f64>, /// Binary interaction parameter k_ij: DMatrix<f64>, kappa: DVector<f64>, } impl PengRobinson { /// Create a new equation of state from a set of parameters. pub fn new(parameters: PengRobinsonParameters) -> Self { let [tc, pc, ac] = parameters.collate(|r| [r.tc, r.pc, r.acentric_factor]); let [k_ij] = parameters.collate_binary(|&br| [br]); let a = 0.45724 * KB_A3 * tc.component_mul(&tc).component_div(&pc); let b = 0.07780 * KB_A3 * &tc.component_div(&pc); let kappa = ac.map(|ac| 0.37464 + (1.54226 - 0.26992 * &ac) * ac); Self { parameters, tc, a, b, k_ij, kappa, } } } impl ResidualDyn for PengRobinson { fn components(&self) -> usize { self.tc.len() } fn compute_max_density<D: DualNum<f64> + Copy>(&self, molefracs: &DVector<D>) -> D { D::from(0.9) / molefracs.dot(&self.b.map(D::from)) } fn reduced_helmholtz_energy_density_contributions<D: DualNum<f64> + Copy>( &self, state: &StateHD<D>, ) -> Vec<(&'static str, D)> { let density = state.partial_density.sum(); let x = &state.molefracs; let ak = &self .tc .map(|tc| D::one() - (state.temperature / tc).sqrt()) .component_mul(&self.kappa.map(D::from)) .map(|x| (x + 1.0).powi(2)) .component_mul(&self.a.map(D::from)); // Mixing rules let mut ak_mix = D::zero(); for i in 0..ak.len() { for j in 0..ak.len() { ak_mix += (ak[i] * ak[j]).sqrt() * (x[i] * x[j] * (1.0 - self.k_ij[(i, j)])); } } let b = x.dot(&self.b.map(D::from)); // Helmholtz energy let v = density.recip(); let f = density * ((v / (v - b)).ln() - ak_mix / (b * SQRT_2 * 2.0 * state.temperature) * ((v + b * (1.0 + SQRT_2)) / (v + b * (1.0 - SQRT_2))).ln()); vec![("Peng Robinson", f)] } } impl Subset for PengRobinson { fn subset(&self, component_list: &[usize]) -> Self { Self::new(self.parameters.subset(component_list)) } } impl Molarweight for PengRobinson { fn molar_weight(&self) -> MolarWeight<DVector<f64>> { self.parameters.molar_weight.clone() } } #[cfg(test)] mod tests { use super::*; use crate::parameter::PureRecord; use crate::state::{Contributions, State}; use crate::{FeosResult, SolverOptions, Verbosity}; use approx::*; use quantity::{KELVIN, PASCAL}; fn pure_record_vec() -> Vec<PureRecord<PengRobinsonRecord, ()>> { let records = r#"[ { "identifier": { "cas": "74-98-6", "name": "propane", "iupac_name": "propane", "smiles": "CCC", "inchi": "InChI=1/C3H8/c1-3-2/h3H2,1-2H3", "formula": "C3H8" }, "tc": 369.96, "pc": 4250000.0, "acentric_factor": 0.153, "molarweight": 44.0962 }, { "identifier": { "cas": "106-97-8", "name": "butane", "iupac_name": "butane", "smiles": "CCCC", "inchi": "InChI=1/C4H10/c1-3-4-2/h3-4H2,1-2H3", "formula": "C4H10" }, "tc": 425.2, "pc": 3800000.0, "acentric_factor": 0.199, "molarweight": 58.123 } ]"#; serde_json::from_str(records).expect("Unable to parse json.") } #[test] fn peng_robinson() -> FeosResult<()> { let mixture = pure_record_vec(); let propane = mixture[0].clone(); let tc = propane.model_record.tc; let pc = propane.model_record.pc; let parameters = PengRobinsonParameters::new_pure(propane)?; let pr = PengRobinson::new(parameters); let options = SolverOptions::new().verbosity(Verbosity::Iter); let cp = State::critical_point(&&pr, None, None, None, options)?; println!("{} {}", cp.temperature, cp.pressure(Contributions::Total)); assert_relative_eq!(cp.temperature, tc * KELVIN, max_relative = 1e-4); assert_relative_eq!( cp.pressure(Contributions::Total), pc * PASCAL, max_relative = 1e-4 ); Ok(()) } }
Rust
3D
feos-org/feos
crates/feos-core/src/errors.rs
.rs
2,234
69
use num_dual::linalg::LinAlgError; use std::io; use thiserror::Error; /// Error type for improperly defined states and convergence problems. #[derive(Error, Debug)] pub enum FeosError { // generic error with custom message #[error("{0}")] Error(String), // errors related to algorithms #[error("`{0}` did not converge within the maximum number of iterations.")] NotConverged(String), #[error("`{0}` encountered illegal values during the iteration.")] IterationFailed(String), #[error("Iteration resulted in trivial solution.")] TrivialSolution, #[error( "Equation of state is initialized for {0} components while the input specifies {1} components." )] IncompatibleComponents(usize, usize), #[error("Invalid state in {0}: {1} = {2}.")] InvalidState(String, String, f64), #[error("Undetermined state: {0}.")] UndeterminedState(String), #[error("System is supercritical.")] SuperCritical, #[error("No phase split according to stability analysis.")] NoPhaseSplit, #[error("Wrong input units. Expected {0}, got {1}")] WrongUnits(String, String), // errors related to file handling #[error(transparent)] FileIO(#[from] io::Error), // json errors #[error(transparent)] Serde(#[from] serde_json::Error), // errors related to parameter handling #[error("The following component(s) were not found: {0}")] ComponentsNotFound(String), #[error( "The identifier '{0}' is not known. ['cas', 'name', 'iupacname', 'smiles', inchi', 'formula']" )] IdentifierNotFound(String), #[error("Information missing.")] InsufficientInformation, #[error("Incompatible parameters: {0}")] IncompatibleParameters(String), #[error("Missing parameters: {0}")] MissingParameters(String), // other errors #[error(transparent)] LinAlgError(#[from] LinAlgError), #[cfg(feature = "rayon")] #[error(transparent)] RayonError(#[from] rayon::ThreadPoolBuildError), #[cfg(feature = "ndarray")] #[error(transparent)] ShapeError(#[from] ndarray::ShapeError), } /// Convenience type for `Result<T, FeosError>`. pub type FeosResult<T> = Result<T, FeosError>;
Rust
3D
feos-org/feos
crates/feos-core/src/density_iteration.rs
.rs
9,571
277
use crate::DensityInitialization::{self, InitialDensity, Liquid, Vapor}; use crate::errors::{FeosError, FeosResult}; use crate::{ReferenceSystem, Residual}; use nalgebra::allocator::Allocator; use nalgebra::{DefaultAllocator, Dim, OVector}; use num_dual::{Dual, DualNum, first_derivative}; use quantity::{Density, Pressure, Temperature}; pub fn density_iteration<E: Residual<N, D>, N: Dim, D: DualNum<f64> + Copy>( eos: &E, temperature: Temperature<D>, pressure: Pressure<D>, molefracs: &OVector<D, N>, initial_density: Option<DensityInitialization>, ) -> FeosResult<Density<D>> where DefaultAllocator: Allocator<N>, { let eos_f64 = eos.re(); let t = temperature.into_reduced(); let pressure = pressure.into_reduced(); let x = molefracs.map(|x| x.re()); let density = if let Some(initial_density) = initial_density { let rho_init = initial_density.into_reduced(); _density_iteration(&eos_f64, t.re(), pressure.re(), &x, rho_init) } else { _density_iteration_stable(&eos_f64, t.re(), pressure.re(), &x) }?; // Implicit differentiation let mut density = D::from(density); for _ in 0..D::NDERIV { let (_, p, dp_drho) = eos.p_dpdrho(t, density, molefracs); density -= (p - pressure) / dp_drho; } Ok(Density::from_reduced(density)) } fn _density_iteration_stable<E: Residual<N>, N: Dim>( eos: &E, temperature: f64, pressure: f64, molefracs: &OVector<f64, N>, ) -> FeosResult<f64> where DefaultAllocator: Allocator<N>, { // calculate stable phase let max_density = eos.compute_max_density(molefracs); let liquid = _density_iteration(eos, temperature, pressure, molefracs, Liquid); if pressure < max_density * temperature { let vapor = _density_iteration(eos, temperature, pressure, molefracs, Vapor); match (&liquid, &vapor) { (Ok(_), Err(_)) => liquid, (Err(_), Ok(_)) => vapor, (Ok(l), Ok(v)) => { if _chemical_potential(eos, temperature, *l, molefracs) > _chemical_potential(eos, temperature, *v, molefracs) { vapor } else { liquid } } _ => Err(FeosError::UndeterminedState(String::from( "Density iteration did not find a solution.", ))), } } else { liquid } } fn _chemical_potential<E: Residual<N, f64>, N: Dim>( eos: &E, temperature: f64, density: f64, molefracs: &OVector<f64, N>, ) -> f64 where DefaultAllocator: Allocator<N>, { let molar_volume = density.recip(); let t = Dual::from_re(temperature); let x = molefracs.map(Dual::from); let (a_res, da_res) = first_derivative( |molar_volume| { eos.lift() .residual_molar_helmholtz_energy(t, molar_volume, &x) }, molar_volume, ); a_res - da_res * molar_volume + temperature * density.ln() } pub(crate) fn _density_iteration<E: Residual<N>, N: Dim>( eos: &E, temperature: f64, pressure: f64, molefracs: &OVector<f64, N>, initial_density: DensityInitialization<f64>, ) -> FeosResult<f64> where DefaultAllocator: Allocator<N>, { let maxdensity = eos.compute_max_density(molefracs); let initial_density = match initial_density { Vapor => pressure / temperature, Liquid => maxdensity, InitialDensity(d) => d, }; let (abstol, reltol) = (1e-12, 1e-14); let mut rho = initial_density; if rho <= 0.0 { return Err(FeosError::InvalidState( String::from("density iteration"), String::from("density"), rho, )); } let maxiter = 50; let mut iterations = 0; 'iteration: for k in 0..maxiter { iterations += 1; let (_, mut p, mut dp_drho) = eos.p_dpdrho(temperature, rho, molefracs); // attempt to correct for poor initial density rho_init if dp_drho.is_sign_negative() && k == 0 { rho = if initial_density <= 0.15 * maxdensity { 0.05 * initial_density } else { (1.1 * initial_density).min(maxdensity) }; let p_ = eos.p_dpdrho(temperature, rho, molefracs); p = p_.0; dp_drho = p_.1; } let mut error = p - pressure; let mut delta_rho = -error / dp_drho; if delta_rho.abs() > 0.075 * maxdensity { delta_rho = 0.075 * maxdensity * delta_rho.signum(); }; delta_rho = delta_rho.max(-0.95 * rho); // prevent stepping to rho < 0.0 // correction for instable region if dp_drho.is_sign_negative() && k < maxiter { let (_, _, d2pdrho2) = eos.p_dpdrho_d2pdrho2(temperature, rho, molefracs); if rho > 0.85 * maxdensity { let (sp_p, sp_rho) = _pressure_spinodal(eos, temperature, initial_density, molefracs)?; rho = sp_rho; error = sp_p - pressure; if rho > 0.85 * maxdensity { if error.is_sign_negative() { return Err(FeosError::IterationFailed(String::from( "density_iteration", ))); } else { rho *= 0.98 } } else if error.is_sign_positive() { rho = 0.001 * maxdensity } else { rho = (rho * 1.1).min(maxdensity) } } else if error.is_sign_positive() && d2pdrho2.is_sign_positive() { let (sp_p, sp_rho) = _pressure_spinodal(eos, temperature, initial_density, molefracs)?; rho = sp_rho; error = sp_p - pressure; if error.is_sign_positive() { rho = 0.001 * maxdensity } else { rho = (rho * 1.1).min(maxdensity) } } else if error.is_sign_negative() && d2pdrho2.is_sign_negative() { let (sp_p, sp_rho) = _pressure_spinodal(eos, temperature, initial_density, molefracs)?; rho = sp_rho; error = sp_p - pressure; if error.is_sign_negative() { rho = 0.8 * maxdensity } else { rho *= 0.8 } } else if error.is_sign_negative() && d2pdrho2.is_sign_positive() { let (_, rho_l) = _pressure_spinodal(eos, temperature, 0.8 * maxdensity, molefracs)?; let (sp_v_p, rho_v) = _pressure_spinodal(eos, temperature, 0.001 * maxdensity, molefracs)?; error = sp_v_p - pressure; if error.is_sign_positive() && (initial_density - rho_v).abs() < (initial_density - rho_l).abs() { rho = 0.8 * rho_v } else { rho = (rho_l * 1.1).min(maxdensity) } } else if error.is_sign_positive() && d2pdrho2.is_sign_negative() { let (_, rho_l) = _pressure_spinodal(eos, temperature, 0.8 * maxdensity, molefracs)?; let (sp_v_p, rho_v) = _pressure_spinodal(eos, temperature, 0.001 * maxdensity, molefracs)?; error = sp_v_p - pressure; if error.is_sign_negative() && (initial_density - rho_v).abs() > (initial_density - rho_l).abs() { rho = (rho_l * 1.1).min(maxdensity) } else { rho = 0.8 * rho_v } } else { rho = (rho + initial_density) * 0.5; if (rho - initial_density).abs() < 1e-8 { rho = (rho + 0.1 * maxdensity).min(maxdensity) } } continue 'iteration; } // Newton step rho += delta_rho; if error.abs() < f64::max(abstol, rho * reltol) { break 'iteration; } } if iterations == maxiter + 1 { Err(FeosError::NotConverged("density_iteration".to_owned())) } else { Ok(rho) } } pub(crate) fn _pressure_spinodal<E: Residual<N>, N: Dim>( eos: &E, temperature: f64, rho_init: f64, molefracs: &OVector<f64, N>, ) -> FeosResult<(f64, f64)> where DefaultAllocator: Allocator<N>, { let maxiter = 30; let abstol = 1e-8; let maxdensity = eos.compute_max_density(molefracs); let mut rho = rho_init; if rho <= 0.0 { return Err(FeosError::InvalidState( String::from("pressure spinodal"), String::from("density"), rho, )); } for _ in 0..maxiter { let (p, dpdrho, d2pdrho2) = eos.p_dpdrho_d2pdrho2(temperature, rho, molefracs); let mut delta_rho = -dpdrho / d2pdrho2; if delta_rho.abs() > 0.05 * maxdensity { delta_rho = 0.05 * maxdensity * delta_rho.signum() } delta_rho = delta_rho.max(-rho * 0.95); // prevent stepping to rho < 0.0 delta_rho = delta_rho.min(maxdensity - rho); // prevent stepping to rho > maxdensity rho += delta_rho; if dpdrho.abs() < abstol { return Ok((p, rho)); } } Err(FeosError::NotConverged("pressure_spinodal".to_owned())) }
Rust
3D
feos-org/feos
crates/feos-core/src/ad/mod.rs
.rs
12,091
338
use crate::DensityInitialization::Liquid; use crate::density_iteration::density_iteration; use crate::{FeosResult, PhaseEquilibrium, ReferenceSystem, Residual}; use nalgebra::{Const, SVector, U1, U2}; #[cfg(feature = "rayon")] use ndarray::{Array1, Array2, ArrayView2, Zip}; use num_dual::{Derivative, DualSVec, DualStruct}; use quantity::{Density, Pressure, Temperature}; #[cfg(feature = "rayon")] use quantity::{KELVIN, KILO, METER, MOL, PASCAL}; type Gradient<const P: usize> = DualSVec<f64, f64, P>; /// A model that can be evaluated with derivatives of its parameters. pub trait ParametersAD<const N: usize>: for<'a> From<&'a [f64]> + Residual<Const<N>> { /// Return a mutable reference to the parameter named by `index` from the parameter set. fn index_parameters_mut<'a, const P: usize>( eos: &'a mut Self::Lifted<Gradient<P>>, index: &str, ) -> &'a mut Gradient<P>; /// Return the parameters with the appropriate derivatives. fn named_derivatives<const P: usize>( &self, parameter_names: [&str; P], ) -> Self::Lifted<Gradient<P>> { let mut eos = self.lift::<Gradient<P>>(); for (i, p) in parameter_names.into_iter().enumerate() { Self::index_parameters_mut(&mut eos, p).eps = Derivative::derivative_generic(Const::<P>, U1, i) } eos } } /// Properties that can be evaluated with derivatives of model parameters. pub trait PropertiesAD { fn vapor_pressure<const P: usize>( &self, temperature: Temperature, ) -> FeosResult<Pressure<Gradient<P>>> where Self: Residual<U1, Gradient<P>>, { let eos_f64 = self.re(); let (_, [vapor_density, liquid_density]) = PhaseEquilibrium::pure_t(&eos_f64, temperature, None, Default::default())?; // implicit differentiation is implemented here instead of just calling pure_t with dual // numbers, because for the first derivative, we can avoid calculating density derivatives. let v1 = 1.0 / liquid_density.to_reduced(); let v2 = 1.0 / vapor_density.to_reduced(); let t = temperature.into_reduced(); let (a1, a2) = { let t = Gradient::from(t); let v1 = Gradient::from(v1); let v2 = Gradient::from(v2); let x = Self::pure_molefracs(); let a1 = self.residual_molar_helmholtz_energy(t, v1, &x); let a2 = self.residual_molar_helmholtz_energy(t, v2, &x); (a1, a2) }; let p = -(a1 - a2 + t * (v2 / v1).ln()) / (v1 - v2); Ok(Pressure::from_reduced(p)) } fn equilibrium_liquid_density<const P: usize>( &self, temperature: Temperature, ) -> FeosResult<(Pressure<Gradient<P>>, Density<Gradient<P>>)> where Self: Residual<U1, Gradient<P>>, { let t = Temperature::from_inner(&temperature); PhaseEquilibrium::pure_t(self, t, None, Default::default()).map(|(p, [_, rho])| (p, rho)) } fn liquid_density<const P: usize>( &self, temperature: Temperature, pressure: Pressure, ) -> FeosResult<Density<Gradient<P>>> where Self: Residual<U1, Gradient<P>>, { let x = Self::pure_molefracs(); let t = Temperature::from_inner(&temperature); let p = Pressure::from_inner(&pressure); density_iteration(self, t, p, &x, Some(Liquid)) } #[cfg(feature = "rayon")] fn vapor_pressure_parallel<const P: usize>( parameter_names: [String; P], parameters: ArrayView2<f64>, input: ArrayView2<f64>, ) -> (Array1<f64>, Array2<f64>, Array1<bool>) where Self: ParametersAD<1>, { parallelize::<_, Self, _, _>( parameter_names, parameters, input, |eos: &Self::Lifted<Gradient<P>>, inp| { eos.vapor_pressure(inp[0] * KELVIN) .map(|p| p.convert_into(PASCAL)) }, ) } #[cfg(feature = "rayon")] fn liquid_density_parallel<const P: usize>( parameter_names: [String; P], parameters: ArrayView2<f64>, input: ArrayView2<f64>, ) -> (Array1<f64>, Array2<f64>, Array1<bool>) where Self: ParametersAD<1>, { parallelize::<_, Self, _, _>( parameter_names, parameters, input, |eos: &Self::Lifted<Gradient<P>>, inp| { eos.liquid_density(inp[0] * KELVIN, inp[1] * PASCAL) .map(|d| d.convert_into(KILO * MOL / (METER * METER * METER))) }, ) } #[cfg(feature = "rayon")] fn equilibrium_liquid_density_parallel<const P: usize>( parameter_names: [String; P], parameters: ArrayView2<f64>, input: ArrayView2<f64>, ) -> (Array1<f64>, Array2<f64>, Array1<bool>) where Self: ParametersAD<1>, { parallelize::<_, Self, _, _>( parameter_names, parameters, input, |eos: &Self::Lifted<Gradient<P>>, inp| { eos.equilibrium_liquid_density(inp[0] * KELVIN) .map(|(_, d)| d.convert_into(KILO * MOL / (METER * METER * METER))) }, ) } fn bubble_point_pressure<const P: usize>( &self, temperature: Temperature, pressure: Option<Pressure>, liquid_molefracs: SVector<f64, 2>, ) -> FeosResult<Pressure<Gradient<P>>> where Self: Residual<U2, Gradient<P>>, { let eos_f64 = self.re(); let vle = PhaseEquilibrium::bubble_point( &eos_f64, temperature, &liquid_molefracs, pressure, None, Default::default(), )?; // implicit differentiation is implemented here instead of just calling bubble_point with dual // numbers, because for the first derivative, we can avoid calculating density derivatives. let v_l = 1.0 / vle.liquid().density.to_reduced(); let v_v = 1.0 / vle.vapor().density.to_reduced(); let y = &vle.vapor().molefracs; let y: SVector<_, 2> = SVector::from_fn(|i, _| y[i]); let t = temperature.into_reduced(); let (a_l, a_v, v_l, v_v) = { let t = Gradient::from(t); let v_l = Gradient::from(v_l); let v_v = Gradient::from(v_v); let y = y.map(Gradient::from); let x = liquid_molefracs.map(Gradient::from); let a_v = self.residual_molar_helmholtz_energy(t, v_v, &y); let (p_l, mu_res_l, dp_l, dmu_l) = self.dmu_dv(t, v_l, &x); let vi_l = dmu_l / dp_l; let v_l = vi_l.dot(&y); let a_l = (mu_res_l - vi_l * p_l).dot(&y); (a_l, a_v, v_l, v_v) }; let rho_l = vle.liquid().partial_density.to_reduced(); let rho_l = [rho_l[0], rho_l[1]]; let rho_v = vle.vapor().partial_density.to_reduced(); let rho_v = [rho_v[0], rho_v[1]]; let p = -(a_v - a_l + t * (y[0] * (rho_v[0] / rho_l[0]).ln() + y[1] * (rho_v[1] / rho_l[1]).ln() - 1.0)) / (v_v - v_l); Ok(Pressure::from_reduced(p)) } fn dew_point_pressure<const P: usize>( &self, temperature: Temperature, pressure: Option<Pressure>, vapor_molefracs: SVector<f64, 2>, ) -> FeosResult<Pressure<Gradient<P>>> where Self: Residual<U2, Gradient<P>>, { let eos_f64 = self.re(); let vle = PhaseEquilibrium::dew_point( &eos_f64, temperature, &vapor_molefracs, pressure, None, Default::default(), )?; // implicit differentiation is implemented here instead of just calling dew_point with dual // numbers, because for the first derivative, we can avoid calculating density derivatives. let v_l = 1.0 / vle.liquid().density.to_reduced(); let v_v = 1.0 / vle.vapor().density.to_reduced(); let x = &vle.liquid().molefracs; let x: SVector<_, 2> = SVector::from_fn(|i, _| x[i]); let t = temperature.into_reduced(); let (a_l, a_v, v_l, v_v) = { let t = Gradient::from(t); let v_l = Gradient::from(v_l); let v_v = Gradient::from(v_v); let x = x.map(Gradient::from); let y = vapor_molefracs.map(Gradient::from); let a_l = self.residual_molar_helmholtz_energy(t, v_l, &x); let (p_v, mu_res_v, dp_v, dmu_v) = self.dmu_dv(t, v_v, &y); let vi_v = dmu_v / dp_v; let v_v = vi_v.dot(&x); let a_v = (mu_res_v - vi_v * p_v).dot(&x); (a_l, a_v, v_l, v_v) }; let rho_l = vle.liquid().partial_density.to_reduced(); let rho_l = [rho_l[0], rho_l[1]]; let rho_v = vle.vapor().partial_density.to_reduced(); let rho_v = [rho_v[0], rho_v[1]]; let p = -(a_l - a_v + t * (x[0] * (rho_l[0] / rho_v[0]).ln() + x[1] * (rho_l[1] / rho_v[1]).ln() - 1.0)) / (v_l - v_v); Ok(Pressure::from_reduced(p)) } #[cfg(feature = "rayon")] fn bubble_point_pressure_parallel<const P: usize>( parameter_names: [String; P], parameters: ArrayView2<f64>, input: ArrayView2<f64>, ) -> (Array1<f64>, Array2<f64>, Array1<bool>) where Self: ParametersAD<2>, { parallelize::<_, Self, _, _>( parameter_names, parameters, input, |eos: &Self::Lifted<Gradient<P>>, inp| { eos.bubble_point_pressure( inp[0] * KELVIN, Some(inp[2] * PASCAL), SVector::from([inp[1], 1.0 - inp[1]]), ) .map(|p| p.convert_into(PASCAL)) }, ) } #[cfg(feature = "rayon")] fn dew_point_pressure_parallel<const P: usize>( parameter_names: [String; P], parameters: ArrayView2<f64>, input: ArrayView2<f64>, ) -> (Array1<f64>, Array2<f64>, Array1<bool>) where Self: ParametersAD<2>, { parallelize::<_, Self, _, _>( parameter_names, parameters, input, |eos: &Self::Lifted<Gradient<P>>, inp| { eos.dew_point_pressure( inp[0] * KELVIN, Some(inp[2] * PASCAL), SVector::from([inp[1], 1.0 - inp[1]]), ) .map(|p| p.convert_into(PASCAL)) }, ) } } impl<T> PropertiesAD for T {} #[cfg(feature = "rayon")] fn parallelize<F, E: ParametersAD<N>, const N: usize, const P: usize>( parameter_names: [String; P], parameters: ArrayView2<f64>, input: ArrayView2<f64>, f: F, ) -> (Array1<f64>, Array2<f64>, Array1<bool>) where F: Fn(&E::Lifted<Gradient<P>>, &[f64]) -> FeosResult<Gradient<P>> + Sync, { let parameter_names = parameter_names.each_ref().map(|s| s as &str); let value_dual = Zip::from(parameters.rows()) .and(input.rows()) .par_map_collect(|par, inp| { let par = par.as_slice().expect("Parameter array is not contiguous!"); let inp = inp.as_slice().expect("Input array is not contiguous!"); let eos = E::from(par).named_derivatives(parameter_names); f(&eos, inp) }); let status = value_dual.iter().map(|p| p.is_ok()).collect(); let value_dual: Array1<_> = value_dual.into_iter().flatten().collect(); let mut value = Array1::zeros(value_dual.len()); let mut grad = Array2::zeros([value_dual.len(), P]); Zip::from(grad.rows_mut()) .and(&mut value) .and(&value_dual) .for_each(|mut grad, p, p_dual| { *p = p_dual.re; let eps = p_dual.eps.unwrap_generic(Const::<P>, U1).data.0[0].to_vec(); grad.assign(&Array1::from(eps)); }); (value, grad, status) }
Rust
3D
feos-org/feos
crates/feos-core/src/state/mod.rs
.rs
30,345
850
//! Description of a thermodynamic state. //! //! A thermodynamic state in SAFT is defined by //! * a temperature //! * an array of mole numbers //! * the volume //! //! Internally, all properties are computed using such states as input. use crate::density_iteration::density_iteration; use crate::equation_of_state::Residual; use crate::errors::{FeosError, FeosResult}; use crate::{ReferenceSystem, Total}; use nalgebra::allocator::Allocator; use nalgebra::{DefaultAllocator, Dim, Dyn, OVector, U1}; use num_dual::*; use quantity::*; use std::fmt; use std::ops::Sub; mod builder; mod cache; mod properties; mod residual_properties; mod statevec; pub use builder::StateBuilder; pub(crate) use cache::Cache; pub use statevec::StateVec; /// Possible contributions that can be computed. #[derive(Clone, Copy, PartialEq)] pub enum Contributions { /// Only compute the ideal gas contribution IdealGas, /// Only compute the difference between the total and the ideal gas contribution Residual, /// Compute ideal gas and residual contributions Total, } /// Initial values in a density iteration. #[derive(Clone, Copy)] pub enum DensityInitialization<D = Density> { /// Calculate a vapor phase by initializing using the ideal gas. Vapor, /// Calculate a liquid phase by using the `max_density`. Liquid, /// Use the given density as initial value. InitialDensity(D), } impl DensityInitialization { pub fn into_reduced(self) -> DensityInitialization<f64> { match self { Self::Vapor => DensityInitialization::Vapor, Self::Liquid => DensityInitialization::Liquid, Self::InitialDensity(d) => DensityInitialization::InitialDensity(d.into_reduced()), } } } /// Thermodynamic state of the system in reduced variables /// including their derivatives. /// /// Properties are stored as generalized (hyper) dual numbers which allows /// for automatic differentiation. #[derive(Clone, Debug)] pub struct StateHD<D: DualNum<f64> + Copy, N: Dim = Dyn> where DefaultAllocator: Allocator<N>, { /// temperature in Kelvin pub temperature: D, // /// volume in Angstrom^3 // pub molar_volume: D, /// mole fractions pub molefracs: OVector<D, N>, /// partial number densities in Angstrom^-3 pub partial_density: OVector<D, N>, } impl<N: Dim, D: DualNum<f64> + Copy> StateHD<D, N> where DefaultAllocator: Allocator<N>, { /// Create a new `StateHD` for given temperature, molar volume and composition. pub fn new(temperature: D, molar_volume: D, molefracs: &OVector<D, N>) -> Self { let partial_density = molefracs / molar_volume; Self { temperature, molefracs: molefracs.clone(), partial_density, } } /// Create a new `StateHD` for given temperature and partial densities pub fn new_density(temperature: D, partial_density: &OVector<D, N>) -> Self { let molefracs = partial_density / partial_density.sum(); Self { temperature, molefracs, partial_density: partial_density.clone(), } } // Since the molefracs can not be reproduced from moles if the density is zero, // this constructor exists specifically for these cases. pub(crate) fn new_virial(temperature: D, density: D, molefracs: &OVector<D, N>) -> Self { let partial_density = molefracs * density; Self { temperature, molefracs: molefracs.clone(), partial_density, } } } /// Thermodynamic state of the system. /// /// The state is always specified by the variables of the Helmholtz energy: volume $V$, /// temperature $T$ and mole numbers $N_i$. Additional to these variables, the state saves /// properties like the density, that can be calculated directly from the basic variables. /// The state also contains a reference to the equation of state used to create the state. /// Therefore, it can be used directly to calculate all state properties. /// /// Calculated partial derivatives are cached in the state. Therefore, the second evaluation /// of a property like the pressure, does not require a recalculation of the equation of state. /// This can be used in situations where both lower and higher order derivatives are required, as /// in a calculation of a derivative all lower derivatives have to be calculated internally as well. /// Since they are cached it is more efficient to calculate the highest derivatives first. /// For example during the calculation of the isochoric heat capacity $c_v$, the entropy and the /// Helmholtz energy are calculated as well. /// /// `State` objects are meant to be immutable. If individual fields like `volume` are changed, the /// calculations are wrong as the internal fields of the state are not updated. /// /// ## Contents /// /// + [State properties](#state-properties) /// + [Mass specific state properties](#mass-specific-state-properties) /// + [Transport properties](#transport-properties) /// + [Critical points](#critical-points) /// + [State constructors](#state-constructors) /// + [Stability analysis](#stability-analysis) /// + [Flash calculations](#flash-calculations) #[derive(Debug)] pub struct State<E, N: Dim = Dyn, D: DualNum<f64> + Copy = f64> where DefaultAllocator: Allocator<N>, { /// Equation of state pub eos: E, /// Temperature $T$ pub temperature: Temperature<D>, /// Volume $V$ pub volume: Volume<D>, /// Mole numbers $N_i$ pub moles: Moles<OVector<D, N>>, /// Total number of moles $N=\sum_iN_i$ pub total_moles: Moles<D>, /// Partial densities $\rho_i=\frac{N_i}{V}$ pub partial_density: Density<OVector<D, N>>, /// Total density $\rho=\frac{N}{V}=\sum_i\rho_i$ pub density: Density<D>, /// Mole fractions $x_i=\frac{N_i}{N}=\frac{\rho_i}{\rho}$ pub molefracs: OVector<D, N>, /// Cache cache: Cache<D, N>, } impl<E: Clone, N: Dim, D: DualNum<f64> + Copy> Clone for State<E, N, D> where DefaultAllocator: Allocator<N>, { fn clone(&self) -> Self { Self { eos: self.eos.clone(), temperature: self.temperature, volume: self.volume, moles: self.moles.clone(), total_moles: self.total_moles, partial_density: self.partial_density.clone(), density: self.density, molefracs: self.molefracs.clone(), cache: self.cache.clone(), } } } impl<E: Residual<N, D>, N: Dim, D: DualNum<f64> + Copy> fmt::Display for State<E, N, D> where DefaultAllocator: Allocator<N>, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.eos.components() == 1 { write!( f, "T = {:.5}, ρ = {:.5}", self.temperature.re(), self.density.re() ) } else { write!( f, "T = {:.5}, ρ = {:.5}, x = {:.5?}", self.temperature.re(), self.density.re(), self.molefracs.map(|x| x.re()).as_slice() ) } } } impl<E: Residual<N, D>, N: Dim, D: DualNum<f64> + Copy> State<E, N, D> where DefaultAllocator: Allocator<N>, { /// Return a new `State` given a temperature, an array of mole numbers and a volume. /// /// This function will perform a validation of the given properties, i.e. test for signs /// and if values are finite. It will **not** validate physics, i.e. if the resulting /// densities are below the maximum packing fraction. pub fn new_nvt( eos: &E, temperature: Temperature<D>, volume: Volume<D>, moles: &Moles<OVector<D, N>>, ) -> FeosResult<Self> { let total_moles = moles.sum(); let molefracs = (moles / total_moles).into_value(); let density = total_moles / volume; validate(temperature, density, &molefracs)?; Ok(Self::new_unchecked( eos, temperature, density, total_moles, &molefracs, )) } /// Return a new `State` for which the total amount of substance is unspecified. /// /// Internally the total number of moles will be set to 1 mol. /// /// This function will perform a validation of the given properties, i.e. test for signs /// and if values are finite. It will **not** validate physics, i.e. if the resulting /// densities are below the maximum packing fraction. pub fn new_intensive( eos: &E, temperature: Temperature<D>, density: Density<D>, molefracs: &OVector<D, N>, ) -> FeosResult<Self> { validate(temperature, density, molefracs)?; let total_moles = Moles::new(D::one()); Ok(Self::new_unchecked( eos, temperature, density, total_moles, molefracs, )) } fn new_unchecked( eos: &E, temperature: Temperature<D>, density: Density<D>, total_moles: Moles<D>, molefracs: &OVector<D, N>, ) -> Self { let volume = total_moles / density; let moles = Dimensionless::new(molefracs.clone()) * total_moles; let partial_density = moles.clone() / volume; State { eos: eos.clone(), temperature, volume, moles, total_moles, partial_density, density, molefracs: molefracs.clone(), cache: Cache::new(), } } /// Return a new `State` for a pure component given a temperature and a density. The moles /// are set to the reference value for each component. /// /// This function will perform a validation of the given properties, i.e. test for signs /// and if values are finite. It will **not** validate physics, i.e. if the resulting /// densities are below the maximum packing fraction. pub fn new_pure(eos: &E, temperature: Temperature<D>, density: Density<D>) -> FeosResult<Self> { let molefracs = OVector::from_element_generic(N::from_usize(1), U1, D::one()); Self::new_intensive(eos, temperature, density, &molefracs) } /// Return a new `State` for the combination of inputs. /// /// The function attempts to create a new state using the given input values. If the state /// is overdetermined, it will choose a method based on the following hierarchy. /// 1. Create a state non-iteratively from the set of $T$, $V$, $\rho$, $\rho_i$, $N$, $N_i$ and $x_i$. /// 2. Use a density iteration for a given pressure. /// /// The [StateBuilder] provides a convenient way of calling this function without the need to provide /// all the optional input values. /// /// # Errors /// /// When the state cannot be created using the combination of inputs. #[expect(clippy::too_many_arguments)] pub fn new( eos: &E, temperature: Option<Temperature<D>>, volume: Option<Volume<D>>, density: Option<Density<D>>, partial_density: Option<&Density<OVector<D, N>>>, total_moles: Option<Moles<D>>, moles: Option<&Moles<OVector<D, N>>>, molefracs: Option<&OVector<D, N>>, pressure: Option<Pressure<D>>, density_initialization: Option<DensityInitialization>, ) -> FeosResult<Self> { Self::_new( eos, temperature, volume, density, partial_density, total_moles, moles, molefracs, pressure, density_initialization, )? .map_err(|_| FeosError::UndeterminedState(String::from("Missing input parameters."))) } #[expect(clippy::too_many_arguments)] #[expect(clippy::type_complexity)] fn _new( eos: &E, temperature: Option<Temperature<D>>, volume: Option<Volume<D>>, density: Option<Density<D>>, partial_density: Option<&Density<OVector<D, N>>>, total_moles: Option<Moles<D>>, moles: Option<&Moles<OVector<D, N>>>, molefracs: Option<&OVector<D, N>>, pressure: Option<Pressure<D>>, density_initialization: Option<DensityInitialization>, ) -> FeosResult<Result<Self, Option<Moles<OVector<D, N>>>>> { // check for density if density.and(partial_density).is_some() { return Err(FeosError::UndeterminedState(String::from( "Both density and partial density given.", ))); } let rho = density.or_else(|| partial_density.map(|pd| pd.sum())); // check for total moles if moles.and(total_moles).is_some() { return Err(FeosError::UndeterminedState(String::from( "Both moles and total moles given.", ))); } let mut n = total_moles.or_else(|| moles.map(|m| m.sum())); // check if total moles can be inferred from volume if rho.and(n).and(volume).is_some() { return Err(FeosError::UndeterminedState(String::from( "Density is overdetermined.", ))); } n = n.or_else(|| rho.and_then(|d| volume.map(|v| v * d))); // check for composition if partial_density.and(moles).is_some() { return Err(FeosError::UndeterminedState(String::from( "Composition is overdetermined.", ))); } let x = partial_density .map(|pd| pd / pd.sum()) .or_else(|| moles.map(|ms| ms / ms.sum())) .map(Quantity::into_value); let x_u = match (x, molefracs, eos.components()) { (Some(_), Some(_), _) => { return Err(FeosError::UndeterminedState(String::from( "Composition is overdetermined.", ))); } (Some(x), None, _) => x, (None, Some(x), _) => x.clone(), (None, None, 1) => OVector::from_element_generic(N::from_usize(1), U1, D::from(1.0)), _ => { return Err(FeosError::UndeterminedState(String::from( "Missing composition.", ))); } }; let x_u = &x_u / x_u.sum(); // If no extensive property is given, moles is set to the reference value. if let (None, None) = (volume, n) { n = Some(Moles::from_reduced(D::from(1.0))) } let n_i = n.map(|n| Dimensionless::new(&x_u) * n); let v = volume.or_else(|| rho.and_then(|d| n.map(|n| n / d))); // check if new state can be created using default constructor if let (Some(v), Some(t), Some(n_i)) = (v, temperature, &n_i) { return Ok(Ok(State::new_nvt(eos, t, v, n_i)?)); } // Check if new state can be created using density iteration if let (Some(p), Some(t), Some(n_i)) = (pressure, temperature, &n_i) { return Ok(Ok(State::new_npt(eos, t, p, n_i, density_initialization)?)); } if let (Some(p), Some(t), Some(v)) = (pressure, temperature, v) { return Ok(Ok(State::new_npvx( eos, t, p, v, &x_u, density_initialization, )?)); } Ok(Err(n_i.to_owned())) } /// Return a new `State` using a density iteration. [DensityInitialization] is used to /// influence the calculation with respect to the possible solutions. pub fn new_npt( eos: &E, temperature: Temperature<D>, pressure: Pressure<D>, moles: &Moles<OVector<D, N>>, density_initialization: Option<DensityInitialization>, ) -> FeosResult<Self> { let total_moles = moles.sum(); let molefracs = (moles / total_moles).into_value(); let density = Self::new_xpt( eos, temperature, pressure, &molefracs, density_initialization, )? .density; Ok(Self::new_unchecked( eos, temperature, density, total_moles, &molefracs, )) } /// Return a new `State` using a density iteration. [DensityInitialization] is used to /// influence the calculation with respect to the possible solutions. pub fn new_xpt( eos: &E, temperature: Temperature<D>, pressure: Pressure<D>, molefracs: &OVector<D, N>, density_initialization: Option<DensityInitialization>, ) -> FeosResult<Self> { density_iteration( eos, temperature, pressure, molefracs, density_initialization, ) .and_then(|density| Self::new_intensive(eos, temperature, density, molefracs)) } /// Return a new `State` for given pressure $p$, volume $V$, temperature $T$ and composition $x_i$. pub fn new_npvx( eos: &E, temperature: Temperature<D>, pressure: Pressure<D>, volume: Volume<D>, molefracs: &OVector<D, N>, density_initialization: Option<DensityInitialization>, ) -> FeosResult<Self> { let density = Self::new_xpt( eos, temperature, pressure, molefracs, density_initialization, )? .density; let total_moles = density * volume; Ok(Self::new_unchecked( eos, temperature, density, total_moles, molefracs, )) } } impl<E: Total<N, D>, N: Gradients, D: DualNum<f64> + Copy> State<E, N, D> where DefaultAllocator: Allocator<N>, { /// Return a new `State` for the combination of inputs. /// /// The function attempts to create a new state using the given input values. If the state /// is overdetermined, it will choose a method based on the following hierarchy. /// 1. Create a state non-iteratively from the set of $T$, $V$, $\rho$, $\rho_i$, $N$, $N_i$ and $x_i$. /// 2. Use a density iteration for a given pressure. /// 3. Determine the state using a Newton iteration from (in this order): $(p, h)$, $(p, s)$, $(T, h)$, $(T, s)$, $(V, u)$ /// /// The [StateBuilder] provides a convenient way of calling this function without the need to provide /// all the optional input values. /// /// # Errors /// /// When the state cannot be created using the combination of inputs. #[expect(clippy::too_many_arguments)] pub fn new_full( eos: &E, temperature: Option<Temperature<D>>, volume: Option<Volume<D>>, density: Option<Density<D>>, partial_density: Option<&Density<OVector<D, N>>>, total_moles: Option<Moles<D>>, moles: Option<&Moles<OVector<D, N>>>, molefracs: Option<&OVector<D, N>>, pressure: Option<Pressure<D>>, molar_enthalpy: Option<MolarEnergy<D>>, molar_entropy: Option<MolarEntropy<D>>, molar_internal_energy: Option<MolarEnergy<D>>, density_initialization: Option<DensityInitialization>, initial_temperature: Option<Temperature<D>>, ) -> FeosResult<Self> { let state = Self::_new( eos, temperature, volume, density, partial_density, total_moles, moles, molefracs, pressure, density_initialization, )?; let ti = initial_temperature; match state { Ok(state) => Ok(state), Err(n_i) => { // Check if new state can be created using molar_enthalpy and temperature if let (Some(p), Some(h), Some(n_i)) = (pressure, molar_enthalpy, &n_i) { return State::new_nph(eos, p, h, n_i, density_initialization, ti); } if let (Some(p), Some(s), Some(n_i)) = (pressure, molar_entropy, &n_i) { return State::new_nps(eos, p, s, n_i, density_initialization, ti); } if let (Some(t), Some(h), Some(n_i)) = (temperature, molar_enthalpy, &n_i) { return State::new_nth(eos, t, h, n_i, density_initialization); } if let (Some(t), Some(s), Some(n_i)) = (temperature, molar_entropy, &n_i) { return State::new_nts(eos, t, s, n_i, density_initialization); } if let (Some(u), Some(v), Some(n_i)) = (molar_internal_energy, volume, &n_i) { return State::new_nvu(eos, v, u, n_i, ti); } Err(FeosError::UndeterminedState(String::from( "Missing input parameters.", ))) } } } /// Return a new `State` for given pressure $p$ and molar enthalpy $h$. pub fn new_nph( eos: &E, pressure: Pressure<D>, molar_enthalpy: MolarEnergy<D>, moles: &Moles<OVector<D, N>>, density_initialization: Option<DensityInitialization>, initial_temperature: Option<Temperature<D>>, ) -> FeosResult<Self> { let t0 = initial_temperature.unwrap_or(Temperature::from_reduced(D::from(298.15))); let mut density = density_initialization; let f = |x0| { let s = State::new_npt(eos, x0, pressure, moles, density)?; let dfx = s.molar_isobaric_heat_capacity(Contributions::Total); let fx = s.molar_enthalpy(Contributions::Total) - molar_enthalpy; density = Some(DensityInitialization::InitialDensity(s.density.re())); Ok((fx, dfx, s)) }; newton(t0, f, Temperature::from_reduced(1.0e-8)) } /// Return a new `State` for given temperature $T$ and molar enthalpy $h$. pub fn new_nth( eos: &E, temperature: Temperature<D>, molar_enthalpy: MolarEnergy<D>, moles: &Moles<OVector<D, N>>, density_initialization: Option<DensityInitialization>, ) -> FeosResult<Self> { let x = moles.convert_to(moles.sum()); let rho0 = match density_initialization { Some(DensityInitialization::InitialDensity(r)) => { Density::from_reduced(D::from(r.into_reduced())) } Some(DensityInitialization::Liquid) => eos.max_density(&Some(x))?, Some(DensityInitialization::Vapor) => eos.max_density(&Some(x))? * 1.0e-5, None => eos.max_density(&Some(x))? * 0.01, }; let n_inv = moles.sum().inv(); let f = |x0| { let s = State::new_nvt(eos, temperature, moles.sum() / x0, moles)?; let dfx = -s.volume / s.density * n_inv * (s.volume * s.dp_dv(Contributions::Total) + temperature * s.dp_dt(Contributions::Total)); let fx = s.molar_enthalpy(Contributions::Total) - molar_enthalpy; Ok((fx, dfx, s)) }; newton(rho0, f, Density::from_reduced(1.0e-12)) } /// Return a new `State` for given temperature $T$ and molar entropy $s$. pub fn new_nts( eos: &E, temperature: Temperature<D>, molar_entropy: MolarEntropy<D>, moles: &Moles<OVector<D, N>>, density_initialization: Option<DensityInitialization>, ) -> FeosResult<Self> { let x = moles.convert_to(moles.sum()); let rho0 = match density_initialization { Some(DensityInitialization::InitialDensity(r)) => { Density::from_reduced(D::from(r.into_reduced())) } Some(DensityInitialization::Liquid) => eos.max_density(&Some(x))?, Some(DensityInitialization::Vapor) => eos.max_density(&Some(x))? * 1.0e-5, None => eos.max_density(&Some(x))? * 0.01, }; let n_inv = moles.sum().inv(); let f = |x0| { let s = State::new_nvt(eos, temperature, moles.sum() / x0, moles)?; let dfx = -n_inv * s.volume / s.density * s.dp_dt(Contributions::Total); let fx = s.molar_entropy(Contributions::Total) - molar_entropy; Ok((fx, dfx, s)) }; newton(rho0, f, Density::from_reduced(1.0e-12)) } /// Return a new `State` for given pressure $p$ and molar entropy $s$. pub fn new_nps( eos: &E, pressure: Pressure<D>, molar_entropy: MolarEntropy<D>, moles: &Moles<OVector<D, N>>, density_initialization: Option<DensityInitialization>, initial_temperature: Option<Temperature<D>>, ) -> FeosResult<Self> { let t0 = initial_temperature.unwrap_or(Temperature::from_reduced(D::from(298.15))); let mut density = density_initialization; let f = |x0| { let s = State::new_npt(eos, x0, pressure, moles, density)?; let dfx = s.molar_isobaric_heat_capacity(Contributions::Total) / s.temperature; let fx = s.molar_entropy(Contributions::Total) - molar_entropy; density = Some(DensityInitialization::InitialDensity(s.density.re())); Ok((fx, dfx, s)) }; newton(t0, f, Temperature::from_reduced(1.0e-8)) } /// Return a new `State` for given volume $V$ and molar internal energy $u$. pub fn new_nvu( eos: &E, volume: Volume<D>, molar_internal_energy: MolarEnergy<D>, moles: &Moles<OVector<D, N>>, initial_temperature: Option<Temperature<D>>, ) -> FeosResult<Self> { let t0 = initial_temperature.unwrap_or(Temperature::from_reduced(D::from(298.15))); let f = |x0| { let s = State::new_nvt(eos, x0, volume, moles)?; let fx = s.molar_internal_energy(Contributions::Total) - molar_internal_energy; let dfx = s.molar_isochoric_heat_capacity(Contributions::Total); Ok((fx, dfx, s)) }; newton(t0, f, Temperature::from_reduced(1.0e-8)) } } fn is_close<U: Copy>( x: Quantity<f64, U>, y: Quantity<f64, U>, atol: Quantity<f64, U>, rtol: f64, ) -> bool { (x - y).abs() <= atol + rtol * y.abs() } fn newton<E: Residual<N, D>, N: Dim, D: DualNum<f64> + Copy, F, X: Copy, Y>( mut x0: Quantity<D, X>, mut f: F, atol: Quantity<f64, X>, ) -> FeosResult<State<E, N, D>> where DefaultAllocator: Allocator<N>, Y: Sub<X> + Sub<<Y as Sub<X>>::Output, Output = X>, F: FnMut( Quantity<D, X>, ) -> FeosResult<( Quantity<D, Y>, Quantity<D, <Y as Sub<X>>::Output>, State<E, N, D>, )>, { let rtol = 1e-10; let maxiter = 50; for _ in 0..maxiter { let (fx, dfx, mut state) = f(x0)?; let x = x0 - fx / dfx; if is_close(x.re(), x0.re(), atol, rtol) { // Ensure that at least NDERIV iterations are performed (for implicit AD) for _ in 0..D::NDERIV { let (fx, dfx, s) = f(x0)?; x0 -= fx / dfx; state = s; } return Ok(state); } x0 = x; } Err(FeosError::NotConverged("newton".to_owned())) } /// Validate the given temperature, mole numbers and volume. /// /// Properties are valid if /// * they are finite /// * they have a positive sign /// /// There is no validation of the physical state, e.g. /// if resulting densities are below maximum packing fraction. fn validate<N: Dim, D: DualNum<f64>>( temperature: Temperature<D>, density: Density<D>, molefracs: &OVector<D, N>, ) -> FeosResult<()> where DefaultAllocator: Allocator<N>, { let t = temperature.re().to_reduced(); let rho = density.re().to_reduced(); if !t.is_finite() || t.is_sign_negative() { return Err(FeosError::InvalidState( String::from("validate"), String::from("temperature"), t, )); } if !rho.is_finite() || rho.is_sign_negative() { return Err(FeosError::InvalidState( String::from("validate"), String::from("density"), rho, )); } for n in molefracs.iter() { if !n.re().is_finite() || n.re().is_sign_negative() { return Err(FeosError::InvalidState( String::from("validate"), String::from("molefracs"), n.re(), )); } } Ok(()) } mod critical_point; #[cfg(test)] mod tests { use super::*; use nalgebra::dvector; #[test] fn test_validate() { let temperature = 298.15 * KELVIN; let density = 3000.0 * MOL / METER.powi::<3>(); let molefracs = dvector![0.03, 0.02, 0.05]; assert!(validate(temperature, density, &molefracs).is_ok()); } #[test] fn test_negative_temperature() { let temperature = -298.15 * KELVIN; let density = 3000.0 * MOL / METER.powi::<3>(); let molefracs = dvector![0.03, 0.02, 0.05]; assert!(validate(temperature, density, &molefracs).is_err()); } #[test] fn test_nan_temperature() { let temperature = f64::NAN * KELVIN; let density = 3000.0 * MOL / METER.powi::<3>(); let molefracs = dvector![0.03, 0.02, 0.05]; assert!(validate(temperature, density, &molefracs).is_err()); } #[test] fn test_negative_mole_number() { let temperature = 298.15 * KELVIN; let density = 3000.0 * MOL / METER.powi::<3>(); let molefracs = dvector![-0.03, 0.02, 0.05]; assert!(validate(temperature, density, &molefracs).is_err()); } #[test] fn test_nan_mole_number() { let temperature = 298.15 * KELVIN; let density = 3000.0 * MOL / METER.powi::<3>(); let molefracs = dvector![f64::NAN, 0.02, 0.05]; assert!(validate(temperature, density, &molefracs).is_err()); } #[test] fn test_negative_density() { let temperature = 298.15 * KELVIN; let density = -3000.0 * MOL / METER.powi::<3>(); let molefracs = dvector![0.01, 0.02, 0.05]; assert!(validate(temperature, density, &molefracs).is_err()); } }
Rust
3D
feos-org/feos
crates/feos-core/src/state/statevec.rs
.rs
3,494
111
#[cfg(feature = "ndarray")] use super::Contributions; use super::State; #[cfg(feature = "ndarray")] use crate::equation_of_state::{Molarweight, Residual, Total}; #[cfg(feature = "ndarray")] use ndarray::{Array1, Array2}; #[cfg(feature = "ndarray")] use quantity::{ Density, MassDensity, MolarEnergy, MolarEntropy, Moles, Pressure, SpecificEnergy, SpecificEntropy, Temperature, }; use std::iter::FromIterator; use std::ops::Deref; /// A list of states for a simple access to properties /// of multiple states. pub struct StateVec<'a, E>(pub Vec<&'a State<E>>); impl<'a, E> FromIterator<&'a State<E>> for StateVec<'a, E> { fn from_iter<I: IntoIterator<Item = &'a State<E>>>(iter: I) -> Self { Self(iter.into_iter().collect()) } } impl<'a, E> IntoIterator for StateVec<'a, E> { type Item = &'a State<E>; type IntoIter = std::vec::IntoIter<Self::Item>; fn into_iter(self) -> Self::IntoIter { self.0.into_iter() } } impl<'a, E> Deref for StateVec<'a, E> { type Target = Vec<&'a State<E>>; fn deref(&self) -> &Self::Target { &self.0 } } #[cfg(feature = "ndarray")] impl<E: Residual> StateVec<'_, E> { pub fn temperature(&self) -> Temperature<Array1<f64>> { Temperature::from_shape_fn(self.0.len(), |i| self.0[i].temperature) } pub fn pressure(&self) -> Pressure<Array1<f64>> { Pressure::from_shape_fn(self.0.len(), |i| self.0[i].pressure(Contributions::Total)) } pub fn compressibility(&self) -> Array1<f64> { Array1::from_shape_fn(self.0.len(), |i| { self.0[i].compressibility(Contributions::Total) }) } pub fn density(&self) -> Density<Array1<f64>> { Density::from_shape_fn(self.0.len(), |i| self.0[i].density) } pub fn moles(&self) -> Moles<Array2<f64>> { Moles::from_shape_fn((self.0.len(), self.0[0].eos.components()), |(i, j)| { self.0[i].moles.get(j) }) } pub fn molefracs(&self) -> Array2<f64> { Array2::from_shape_fn((self.0.len(), self.0[0].eos.components()), |(i, j)| { self.0[i].molefracs[j] }) } } #[cfg(feature = "ndarray")] impl<E: Residual + Molarweight> StateVec<'_, E> { pub fn mass_density(&self) -> MassDensity<Array1<f64>> { MassDensity::from_shape_fn(self.0.len(), |i| self.0[i].mass_density()) } pub fn massfracs(&self) -> Array2<f64> { Array2::from_shape_fn((self.0.len(), self.0[0].eos.components()), |(i, j)| { self.0[i].massfracs()[j] }) } } #[cfg(feature = "ndarray")] impl<E: Total> StateVec<'_, E> { pub fn molar_enthalpy(&self, contributions: Contributions) -> MolarEnergy<Array1<f64>> { MolarEnergy::from_shape_fn(self.0.len(), |i| self.0[i].molar_enthalpy(contributions)) } pub fn molar_entropy(&self, contributions: Contributions) -> MolarEntropy<Array1<f64>> { MolarEntropy::from_shape_fn(self.0.len(), |i| self.0[i].molar_entropy(contributions)) } } #[cfg(feature = "ndarray")] impl<E: Total + Molarweight> StateVec<'_, E> { pub fn specific_enthalpy(&self, contributions: Contributions) -> SpecificEnergy<Array1<f64>> { SpecificEnergy::from_shape_fn(self.0.len(), |i| self.0[i].specific_enthalpy(contributions)) } pub fn specific_entropy(&self, contributions: Contributions) -> SpecificEntropy<Array1<f64>> { SpecificEntropy::from_shape_fn(self.0.len(), |i| self.0[i].specific_entropy(contributions)) } }
Rust
3D
feos-org/feos
crates/feos-core/src/state/cache.rs
.rs
1,606
48
use nalgebra::allocator::Allocator; use nalgebra::{DefaultAllocator, Dim, OVector, Scalar}; use quantity::*; use std::ops::Sub; use std::sync::OnceLock; type Diff<T1, T2> = <T1 as Sub<T2>>::Output; #[derive(Clone, Debug)] #[expect(clippy::type_complexity)] pub struct Cache<D: Scalar, N: Dim> where DefaultAllocator: Allocator<N>, { pub a: OnceLock<Energy<D>>, pub da_dt: OnceLock<Entropy<D>>, pub da_dv: OnceLock<Pressure<D>>, pub da_dn: OnceLock<MolarEnergy<OVector<D, N>>>, pub d2a_dt2: OnceLock<Quantity<D, Diff<_Entropy, _Temperature>>>, pub d2a_dv2: OnceLock<Quantity<D, Diff<_Pressure, _Volume>>>, pub d2a_dtdv: OnceLock<Quantity<D, Diff<_Pressure, _Temperature>>>, pub d2a_dndt: OnceLock<Quantity<OVector<D, N>, Diff<_MolarEnergy, _Temperature>>>, pub d2a_dndv: OnceLock<Quantity<OVector<D, N>, Diff<_MolarEnergy, _Volume>>>, pub d3a_dt3: OnceLock<Quantity<D, Diff<Diff<_Entropy, _Temperature>, _Temperature>>>, pub d3a_dv3: OnceLock<Quantity<D, Diff<Diff<_Pressure, _Volume>, _Volume>>>, } impl<D: Scalar + Copy, N: Dim> Cache<D, N> where DefaultAllocator: Allocator<N>, { pub fn new() -> Self { Self { a: OnceLock::new(), da_dt: OnceLock::new(), da_dv: OnceLock::new(), da_dn: OnceLock::new(), d2a_dt2: OnceLock::new(), d2a_dv2: OnceLock::new(), d2a_dtdv: OnceLock::new(), d2a_dndt: OnceLock::new(), d2a_dndv: OnceLock::new(), d3a_dt3: OnceLock::new(), d3a_dv3: OnceLock::new(), } } }
Rust
3D
feos-org/feos
crates/feos-core/src/state/residual_properties.rs
.rs
29,542
712
use super::{Contributions, State}; use crate::equation_of_state::{EntropyScaling, Molarweight, Residual, Subset}; use crate::{FeosResult, PhaseEquilibrium, ReferenceSystem}; use nalgebra::allocator::Allocator; use nalgebra::{DMatrix, DVector, DefaultAllocator, OMatrix, OVector, dvector}; use num_dual::{Dual, DualNum, Gradients, partial, partial2}; use quantity::*; use std::ops::{Add, Div, Neg, Sub}; type DpDn<T> = Quantity<T, <_Pressure as Sub<_Moles>>::Output>; type DeDn<T> = Quantity<T, <_MolarEnergy as Sub<_Moles>>::Output>; type InvT<T> = Quantity<T, <_Temperature as Neg>::Output>; type InvP<T> = Quantity<T, <_Pressure as Neg>::Output>; type InvM<T> = Quantity<T, <_Moles as Neg>::Output>; type POverT<T> = Quantity<T, <_Pressure as Sub<_Temperature>>::Output>; /// # State properties impl<E: Residual<N, D>, N: Gradients, D: DualNum<f64> + Copy> State<E, N, D> where DefaultAllocator: Allocator<N>, { pub(super) fn contributions< T: Add<T, Output = T>, U, I: FnOnce() -> Quantity<T, U>, R: FnOnce() -> Quantity<T, U>, >( ideal_gas: I, residual: R, contributions: Contributions, ) -> Quantity<T, U> { match contributions { Contributions::IdealGas => ideal_gas(), Contributions::Total => ideal_gas() + residual(), Contributions::Residual => residual(), } } /// Residual Helmholtz energy $A^\text{res}$ pub fn residual_helmholtz_energy(&self) -> Energy<D> { *self.cache.a.get_or_init(|| { self.eos .residual_helmholtz_energy_unit(self.temperature, self.volume, &self.moles) }) } /// Residual molar Helmholtz energy $a^\text{res}$ pub fn residual_molar_helmholtz_energy(&self) -> MolarEnergy<D> { self.residual_helmholtz_energy() / self.total_moles } /// Residual entropy $S^\text{res}=\left(\frac{\partial A^\text{res}}{\partial T}\right)_{V,N_i}$ pub fn residual_entropy(&self) -> Entropy<D> { -*self.cache.da_dt.get_or_init(|| { let (a, da_dt) = quantity::ad::first_derivative( partial2( |t, &v, n| self.eos.lift().residual_helmholtz_energy_unit(t, v, n), &self.volume, &self.moles, ), self.temperature, ); let _ = self.cache.a.set(a); da_dt }) } /// Residual entropy $s^\text{res}=\left(\frac{\partial a^\text{res}}{\partial T}\right)_{V,N_i}$ pub fn residual_molar_entropy(&self) -> MolarEntropy<D> { self.residual_entropy() / self.total_moles } /// Pressure: $p=-\left(\frac{\partial A}{\partial V}\right)_{T,N_i}$ pub fn pressure(&self, contributions: Contributions) -> Pressure<D> { let ideal_gas = || self.density * RGAS * self.temperature; let residual = || { -*self.cache.da_dv.get_or_init(|| { let (a, da_dv) = quantity::ad::first_derivative( partial2( |v, &t, n| self.eos.lift().residual_helmholtz_energy_unit(t, v, n), &self.temperature, &self.moles, ), self.volume, ); let _ = self.cache.a.set(a); da_dv }) }; Self::contributions(ideal_gas, residual, contributions) } /// Residual chemical potential: $\mu_i^\text{res}=\left(\frac{\partial A^\text{res}}{\partial N_i}\right)_{T,V,N_j}$ pub fn residual_chemical_potential(&self) -> MolarEnergy<OVector<D, N>> { self.cache .da_dn .get_or_init(|| { let (a, mu) = quantity::ad::gradient_copy( partial2( |n, &t, &v| self.eos.lift().residual_helmholtz_energy_unit(t, v, &n), &self.temperature, &self.volume, ), &self.moles, ); let _ = self.cache.a.set(a); mu }) .clone() } /// Compressibility factor: $Z=\frac{pV}{NRT}$ pub fn compressibility(&self, contributions: Contributions) -> D { (self.pressure(contributions) / (self.density * self.temperature * RGAS)).into_value() } // pressure derivatives /// Partial derivative of pressure w.r.t. volume: $\left(\frac{\partial p}{\partial V}\right)_{T,N_i}$ pub fn dp_dv(&self, contributions: Contributions) -> <Pressure<D> as Div<Volume<D>>>::Output { let ideal_gas = || -self.density * RGAS * self.temperature / self.volume; let residual = || { -*self.cache.d2a_dv2.get_or_init(|| { let (a, da_dv, d2a_dv2) = quantity::ad::second_derivative( partial2( |v, &t, n| self.eos.lift().residual_helmholtz_energy_unit(t, v, n), &self.temperature, &self.moles, ), self.volume, ); let _ = self.cache.a.set(a); let _ = self.cache.da_dv.set(da_dv); d2a_dv2 }) }; Self::contributions(ideal_gas, residual, contributions) } /// Partial derivative of pressure w.r.t. density: $\left(\frac{\partial p}{\partial \rho}\right)_{T,N_i}$ pub fn dp_drho( &self, contributions: Contributions, ) -> <Pressure<D> as Div<Density<D>>>::Output { -self.volume / self.density * self.dp_dv(contributions) } /// Partial derivative of pressure w.r.t. temperature: $\left(\frac{\partial p}{\partial T}\right)_{V,N_i}$ pub fn dp_dt(&self, contributions: Contributions) -> POverT<D> { let ideal_gas = || self.density * RGAS; let residual = || { -*self.cache.d2a_dtdv.get_or_init(|| { let (a, da_dt, da_dv, d2a_dtdv) = quantity::ad::second_partial_derivative( partial( |(t, v), n| self.eos.lift().residual_helmholtz_energy_unit(t, v, n), &self.moles, ), (self.temperature, self.volume), ); let _ = self.cache.a.set(a); let _ = self.cache.da_dt.set(da_dt); let _ = self.cache.da_dv.set(da_dv); d2a_dtdv }) }; Self::contributions(ideal_gas, residual, contributions) } /// Partial derivative of pressure w.r.t. moles: $\left(\frac{\partial p}{\partial N_i}\right)_{T,V,N_j}$ pub fn dp_dni(&self, contributions: Contributions) -> DpDn<OVector<D, N>> { let residual = -self .cache .d2a_dndv .get_or_init(|| { let (a, da_dn, da_dv, dmu_dv) = quantity::ad::partial_hessian_copy( partial( |(n, v), &t| self.eos.lift().residual_helmholtz_energy_unit(t, v, &n), &self.temperature, ), (&self.moles, self.volume), ); let _ = self.cache.a.set(a); let _ = self.cache.da_dn.set(da_dn); let _ = self.cache.da_dv.set(da_dv); dmu_dv }) .clone(); let (r, c) = residual.shape_generic(); let ideal_gas = || self.temperature / self.volume * RGAS; Quantity::from_fn_generic(r, c, |i, _| { Self::contributions(ideal_gas, || residual.get(i), contributions) }) } /// Second partial derivative of pressure w.r.t. volume: $\left(\frac{\partial^2 p}{\partial V^2}\right)_{T,N_j}$ pub fn d2p_dv2( &self, contributions: Contributions, ) -> <<Pressure<D> as Div<Volume<D>>>::Output as Div<Volume<D>>>::Output { let ideal_gas = || self.density * RGAS * self.temperature / (self.volume * self.volume) * 2.0; let residual = || { -*self.cache.d3a_dv3.get_or_init(|| { let (a, da_dv, d2a_dv2, d3a_dv3) = quantity::ad::third_derivative( partial2( |v, &t, n| self.eos.lift().residual_helmholtz_energy_unit(t, v, n), &self.temperature, &self.moles, ), self.volume, ); let _ = self.cache.a.set(a); let _ = self.cache.da_dv.set(da_dv); let _ = self.cache.d2a_dv2.set(d2a_dv2); d3a_dv3 }) }; Self::contributions(ideal_gas, residual, contributions) } /// Second partial derivative of pressure w.r.t. density: $\left(\frac{\partial^2 p}{\partial \rho^2}\right)_{T,N_j}$ pub fn d2p_drho2( &self, contributions: Contributions, ) -> <<Pressure<D> as Div<Density<D>>>::Output as Div<Density<D>>>::Output { self.volume / (self.density * self.density) * (self.volume * self.d2p_dv2(contributions) + self.dp_dv(contributions) * 2.0) } /// Structure factor: $S(0)=k_BT\left(\frac{\partial\rho}{\partial p}\right)_{T,N_i}$ pub fn structure_factor(&self) -> D { -(self.temperature * self.density * RGAS / (self.volume * self.dp_dv(Contributions::Total))) .into_value() } // This function is designed specifically for use in density iterations pub(crate) fn p_dpdrho(&self) -> (Pressure<D>, <Pressure<D> as Div<Density<D>>>::Output) { let dp_dv = self.dp_dv(Contributions::Total); ( self.pressure(Contributions::Total), (-self.volume * dp_dv / self.density), ) } /// Partial molar volume: $v_i=\left(\frac{\partial V}{\partial N_i}\right)_{T,p,N_j}$ pub fn partial_molar_volume(&self) -> MolarVolume<OVector<D, N>> { -self.dp_dni(Contributions::Total) / self.dp_dv(Contributions::Total) } /// Partial derivative of chemical potential w.r.t. moles: $\left(\frac{\partial\mu_i}{\partial N_j}\right)_{T,V,N_k}$ pub fn dmu_dni(&self, contributions: Contributions) -> DeDn<OMatrix<D, N, N>> where DefaultAllocator: Allocator<N, N>, { let (a, da_dn, d2a_dn2) = quantity::ad::hessian_copy( partial2( |n, &t, &v| self.eos.lift().residual_helmholtz_energy_unit(t, v, &n), &self.temperature, &self.volume, ), &self.moles, ); let _ = self.cache.a.set(a); let _ = self.cache.da_dn.set(da_dn); let residual = || d2a_dn2; let ideal_gas = || { Dimensionless::new(OMatrix::from_diagonal(&self.molefracs.map(|x| x.recip()))) * (self.temperature * RGAS / self.total_moles) }; Self::contributions(ideal_gas, residual, contributions) } /// Isothermal compressibility: $\kappa_T=-\frac{1}{V}\left(\frac{\partial V}{\partial p}\right)_{T,N_i}$ pub fn isothermal_compressibility(&self) -> InvP<D> { (self.dp_dv(Contributions::Total) * self.volume).inv() } // entropy derivatives /// Partial derivative of the residual entropy w.r.t. temperature: $\left(\frac{\partial S^\text{res}}{\partial T}\right)_{V,N_i}$ pub fn ds_res_dt(&self) -> <Entropy<D> as Div<Temperature<D>>>::Output { -*self.cache.d2a_dt2.get_or_init(|| { let (a, da_dt, d2a_dt2) = quantity::ad::second_derivative( partial2( |t, &v, n| self.eos.lift().residual_helmholtz_energy_unit(t, v, n), &self.volume, &self.moles, ), self.temperature, ); let _ = self.cache.a.set(a); let _ = self.cache.da_dt.set(da_dt); d2a_dt2 }) } /// Second partial derivative of the residual entropy w.r.t. temperature: $\left(\frac{\partial^2S^\text{res}}{\partial T^2}\right)_{V,N_i}$ pub fn d2s_res_dt2( &self, ) -> <<Entropy<D> as Div<Temperature<D>>>::Output as Div<Temperature<D>>>::Output { -*self.cache.d3a_dt3.get_or_init(|| { let (a, da_dt, d2a_dt2, d3a_dt3) = quantity::ad::third_derivative( partial2( |t, &v, n| self.eos.lift().residual_helmholtz_energy_unit(t, v, n), &self.volume, &self.moles, ), self.temperature, ); let _ = self.cache.a.set(a); let _ = self.cache.da_dt.set(da_dt); let _ = self.cache.d2a_dt2.set(d2a_dt2); d3a_dt3 }) } /// Partial derivative of chemical potential w.r.t. temperature: $\left(\frac{\partial\mu_i}{\partial T}\right)_{V,N_i}$ pub fn dmu_res_dt(&self) -> MolarEntropy<OVector<D, N>> { self.cache .d2a_dndt .get_or_init(|| { let (a, da_dn, da_dt, d2a_dndt) = quantity::ad::partial_hessian_copy( partial( |(n, t), &v| self.eos.lift().residual_helmholtz_energy_unit(t, v, &n), &self.volume, ), (&self.moles, self.temperature), ); let _ = self.cache.a.set(a); let _ = self.cache.da_dn.set(da_dn); let _ = self.cache.da_dt.set(da_dt); d2a_dndt }) .clone() } /// Logarithm of the fugacity coefficient: $\ln\varphi_i=\beta\mu_i^\mathrm{res}\left(T,p,\lbrace N_i\rbrace\right)$ pub fn ln_phi(&self) -> OVector<D, N> { let mu_res = self.residual_chemical_potential(); let ln_z = self.compressibility(Contributions::Total).ln(); (mu_res / (self.temperature * RGAS)) .into_value() .map(|mu| mu - ln_z) } /// Partial derivative of the logarithm of the fugacity coefficient w.r.t. temperature: $\left(\frac{\partial\ln\varphi_i}{\partial T}\right)_{p,N_i}$ pub fn dln_phi_dt(&self) -> InvT<OVector<D, N>> { let vi = self.partial_molar_volume(); ((self.dmu_res_dt() - self.residual_chemical_potential() / self.temperature - vi * self.dp_dt(Contributions::Total)) / (self.temperature * RGAS)) .add_scalar(self.temperature.inv()) } /// Partial derivative of the logarithm of the fugacity coefficient w.r.t. pressure: $\left(\frac{\partial\ln\varphi_i}{\partial p}\right)_{T,N_i}$ pub fn dln_phi_dp(&self) -> InvP<OVector<D, N>> { (self.partial_molar_volume() / (self.temperature * RGAS)) .add_scalar(-self.pressure(Contributions::Total).inv()) } /// Partial derivative of the logarithm of the fugacity coefficient w.r.t. moles: $\left(\frac{\partial\ln\varphi_i}{\partial N_j}\right)_{T,p,N_k}$ pub fn dln_phi_dnj(&self) -> InvM<OMatrix<D, N, N>> where DefaultAllocator: Allocator<N, N>, { let dmu_dni = self.dmu_dni(Contributions::Residual); let dp_dni = self.dp_dni(Contributions::Total); let dp_dv = self.dp_dv(Contributions::Total); let (r, c) = dmu_dni.shape_generic(); let dp_dn_2 = Quantity::from_fn_generic(r, c, |i, j| dp_dni.get(i) * dp_dni.get(j)); ((dmu_dni + dp_dn_2 / dp_dv) / (self.temperature * RGAS)).add_scalar(self.total_moles.inv()) } } impl<E: Residual + Subset> State<E> { /// Logarithm of the fugacity coefficient of all components treated as pure substance at mixture temperature and pressure. pub fn ln_phi_pure_liquid(&self) -> FeosResult<DVector<f64>> { let pressure = self.pressure(Contributions::Total); (0..self.eos.components()) .map(|i| { let eos = self.eos.subset(&[i]); let state = State::new_xpt( &eos, self.temperature, pressure, &dvector![1.0], Some(crate::DensityInitialization::Liquid), )?; Ok(state.ln_phi()[0]) }) .collect::<FeosResult<Vec<_>>>() .map(DVector::from) } /// Activity coefficient $\ln \gamma_i = \ln \varphi_i(T, p, \mathbf{N}) - \ln \varphi_i^\mathrm{pure}(T, p)$ pub fn ln_symmetric_activity_coefficient(&self) -> FeosResult<DVector<f64>> { Ok(match self.eos.components() { 1 => dvector![0.0], _ => self.ln_phi() - &self.ln_phi_pure_liquid()?, }) } /// Henry's law constant $H_{i,s}=\lim_{x_i\to 0}\frac{y_ip}{x_i}=p_s^\mathrm{sat}\frac{\varphi_i^{\infty,\mathrm{L}}}{\varphi_i^{\infty,\mathrm{V}}}$ /// /// The composition of the (possibly mixed) solvent is determined by the molefracs. All components for which the composition is 0 are treated as solutes. /// /// For some reason the compiler is overwhelmed if returning a quantity array, therefore it is returned as list. pub fn henrys_law_constant( eos: &E, temperature: Temperature, molefracs: &DVector<f64>, ) -> FeosResult<Vec<Pressure>> { // Calculate the phase equilibrium (bubble point) of the solvent only let (solvent_comps, solvent_molefracs): (Vec<_>, Vec<_>) = molefracs .iter() .enumerate() .filter_map(|(i, &x)| (x != 0.0).then_some((i, x))) .unzip(); let solvent_molefracs = DVector::from_vec(solvent_molefracs); let solvent = eos.subset(&solvent_comps); let vle = if solvent_comps.len() == 1 { PhaseEquilibrium::pure(&solvent, temperature, None, Default::default()) } else { PhaseEquilibrium::bubble_point( &solvent, temperature, &solvent_molefracs, None, None, Default::default(), ) }?; // Calculate the liquid state including the Henry components let liquid = State::new_nvt( eos, temperature, vle.liquid().volume, &(molefracs * vle.liquid().total_moles), )?; // Calculate the vapor state including the Henry components let mut molefracs_vapor = molefracs.clone(); solvent_comps .into_iter() .zip(&vle.vapor().molefracs) .for_each(|(i, &y)| molefracs_vapor[i] = y); let vapor = State::new_nvt( eos, temperature, vle.vapor().volume, &(molefracs_vapor * vle.vapor().total_moles), )?; // Determine the Henry's law coefficients and return only those of the Henry components let p = vle.vapor().pressure(Contributions::Total).into_reduced(); let h = (liquid.ln_phi() - vapor.ln_phi()).map(f64::exp) * p; Ok(h.into_iter() .zip(molefracs) .filter_map(|(h, &x)| (x == 0.0).then_some(h)) .map(|&h| Pressure::from_reduced(h)) .collect()) } /// Henry's law constant $H_{i,s}=\lim_{x_i\to 0}\frac{y_ip}{x_i}=p_s^\mathrm{sat}\frac{\varphi_i^{\infty,\mathrm{L}}}{\varphi_i^{\infty,\mathrm{V}}}$ for a binary system /// /// The solute (i) is the first component and the solvent (s) the second component. pub fn henrys_law_constant_binary(eos: &E, temperature: Temperature) -> FeosResult<Pressure> { Ok(Self::henrys_law_constant(eos, temperature, &dvector![0.0, 1.0])?[0]) } } impl<E: Residual> State<E> { /// Thermodynamic factor: $\Gamma_{ij}=\delta_{ij}+x_i\left(\frac{\partial\ln\varphi_i}{\partial x_j}\right)_{T,p,\Sigma}$ pub fn thermodynamic_factor(&self) -> DMatrix<f64> { let dln_phi_dnj = (self.dln_phi_dnj() * Moles::from_reduced(1.0)).into_value(); let moles = &self.molefracs * self.total_moles.into_reduced(); let n = self.eos.components() - 1; DMatrix::from_fn(n, n, |i, j| { moles[i] * (dln_phi_dnj[(i, j)] - dln_phi_dnj[(i, n)]) + if i == j { 1.0 } else { 0.0 } }) } } impl<E: Residual<N, D>, N: Gradients, D: DualNum<f64> + Copy> State<E, N, D> where DefaultAllocator: Allocator<N>, { /// Residual molar isochoric heat capacity: $c_v^\text{res}=\left(\frac{\partial u^\text{res}}{\partial T}\right)_{V,N_i}$ pub fn residual_molar_isochoric_heat_capacity(&self) -> MolarEntropy<D> { self.ds_res_dt() * self.temperature / self.total_moles } /// Partial derivative of the residual molar isochoric heat capacity w.r.t. temperature: $\left(\frac{\partial c_V^\text{res}}{\partial T}\right)_{V,N_i}$ pub fn dc_v_res_dt(&self) -> <MolarEntropy<D> as Div<Temperature<D>>>::Output { (self.temperature * self.d2s_res_dt2() + self.ds_res_dt()) / self.total_moles } /// Residual molar isobaric heat capacity: $c_p^\text{res}=\left(\frac{\partial h^\text{res}}{\partial T}\right)_{p,N_i}$ pub fn residual_molar_isobaric_heat_capacity(&self) -> MolarEntropy<D> { let dp_dt = self.dp_dt(Contributions::Total); self.temperature / self.total_moles * (self.ds_res_dt() - dp_dt * dp_dt / self.dp_dv(Contributions::Total)) - RGAS } /// Residual enthalpy: $H^\text{res}(T,p,\mathbf{n})=A^\text{res}+TS^\text{res}+p^\text{res}V$ pub fn residual_enthalpy(&self) -> Energy<D> { self.temperature * self.residual_entropy() + self.residual_helmholtz_energy() + self.pressure(Contributions::Residual) * self.volume } /// Residual molar enthalpy: $h^\text{res}(T,p,\mathbf{n})=a^\text{res}+Ts^\text{res}+p^\text{res}v$ pub fn residual_molar_enthalpy(&self) -> MolarEnergy<D> { self.residual_enthalpy() / self.total_moles } /// Residual internal energy: $U^\text{res}(T,V,\mathbf{n})=A^\text{res}+TS^\text{res}$ pub fn residual_internal_energy(&self) -> Energy<D> { self.temperature * self.residual_entropy() + self.residual_helmholtz_energy() } /// Residual molar internal energy: $u^\text{res}(T,V,\mathbf{n})=a^\text{res}+Ts^\text{res}$ pub fn residual_molar_internal_energy(&self) -> MolarEnergy<D> { self.residual_internal_energy() / self.total_moles } /// Residual Gibbs energy: $G^\text{res}(T,p,\mathbf{n})=A^\text{res}+p^\text{res}V-NRT \ln Z$ pub fn residual_gibbs_energy(&self) -> Energy<D> { self.pressure(Contributions::Residual) * self.volume + self.residual_helmholtz_energy() - self.total_moles * RGAS * self.temperature * Dimensionless::new(self.compressibility(Contributions::Total).ln()) } /// Residual Gibbs energy: $g^\text{res}(T,p,\mathbf{n})=a^\text{res}+p^\text{res}v-RT \ln Z$ pub fn residual_molar_gibbs_energy(&self) -> MolarEnergy<D> { self.residual_gibbs_energy() / self.total_moles } /// Molar Helmholtz energy $a^\text{res}$ evaluated for each residual contribution of the equation of state. pub fn residual_molar_helmholtz_energy_contributions( &self, ) -> Vec<(&'static str, MolarEnergy<D>)> { let residual_contributions = self.eos.molar_helmholtz_energy_contributions( self.temperature.into_reduced(), self.density.into_reduced().recip(), &self.molefracs, ); let mut res = Vec::with_capacity(residual_contributions.len()); for (s, v) in residual_contributions { res.push((s, MolarEnergy::from_reduced(v))); } res } /// Chemical potential $\mu_i^\text{res}$ evaluated for each residual contribution of the equation of state. pub fn residual_chemical_potential_contributions( &self, component: usize, ) -> Vec<(&'static str, MolarEnergy<D>)> { let t = Dual::from_re(self.temperature.into_reduced()); let v = Dual::from_re(self.temperature.into_reduced()); let mut x = self.molefracs.map(Dual::from_re); x[component].eps = D::one(); let contributions = self .eos .lift() .molar_helmholtz_energy_contributions(t, v, &x); let mut res = Vec::with_capacity(contributions.len()); for (s, v) in contributions { res.push((s, MolarEnergy::from_reduced(v.eps))); } res } /// Pressure $p$ evaluated for each contribution of the equation of state. pub fn pressure_contributions(&self) -> Vec<(&'static str, Pressure<D>)> { let t = Dual::from_re(self.temperature.into_reduced()); let v = Dual::from_re(self.density.into_reduced().recip()).derivative(); let x = self.molefracs.map(Dual::from_re); let contributions = self .eos .lift() .molar_helmholtz_energy_contributions(t, v, &x); let mut res = Vec::with_capacity(contributions.len() + 1); res.push(("Ideal gas", self.density * RGAS * self.temperature)); for (s, v) in contributions { res.push((s, Pressure::from_reduced(-v.eps))); } res } } impl<E: Residual<N, D> + Molarweight<N, D>, N: Gradients, D: DualNum<f64> + Copy> State<E, N, D> where DefaultAllocator: Allocator<N>, { /// Total molar weight: $MW=\sum_ix_iMW_i$ pub fn total_molar_weight(&self) -> MolarWeight<D> { self.eos .molar_weight() .dot(&Dimensionless::new(self.molefracs.clone())) } /// Mass of each component: $m_i=n_iMW_i$ pub fn mass(&self) -> Mass<OVector<D, N>> { self.eos.molar_weight().component_mul(&self.moles) } /// Total mass: $m=\sum_im_i=nMW$ pub fn total_mass(&self) -> Mass<D> { self.total_moles * self.total_molar_weight() } /// Mass density: $\rho^{(m)}=\frac{m}{V}$ pub fn mass_density(&self) -> MassDensity<D> { self.density * self.total_molar_weight() } /// Mass fractions: $w_i=\frac{m_i}{m}$ pub fn massfracs(&self) -> OVector<D, N> { (self.mass() / self.total_mass()).into_value() } } /// # Transport properties /// /// These properties are available for equations of state /// that implement the [EntropyScaling] trait. impl<E: Residual<N, D> + EntropyScaling<N, D>, N: Gradients, D: DualNum<f64> + Copy> State<E, N, D> where DefaultAllocator: Allocator<N>, { /// Return the viscosity via entropy scaling. pub fn viscosity(&self) -> Viscosity<D> { let s = self.residual_molar_entropy().into_reduced(); self.eos .viscosity_reference(self.temperature, self.volume, &self.moles) * Dimensionless::new(self.eos.viscosity_correlation(s, &self.molefracs).exp()) } /// Return the logarithm of the reduced viscosity. /// /// This term equals the viscosity correlation function /// that is used for entropy scaling. pub fn ln_viscosity_reduced(&self) -> D { let s = self.residual_molar_entropy().into_reduced(); self.eos.viscosity_correlation(s, &self.molefracs) } /// Return the viscosity reference as used in entropy scaling. pub fn viscosity_reference(&self) -> Viscosity<D> { self.eos .viscosity_reference(self.temperature, self.volume, &self.moles) } /// Return the diffusion via entropy scaling. pub fn diffusion(&self) -> Diffusivity<D> { let s = self.residual_molar_entropy().into_reduced(); self.eos .diffusion_reference(self.temperature, self.volume, &self.moles) * Dimensionless::new(self.eos.diffusion_correlation(s, &self.molefracs).exp()) } /// Return the logarithm of the reduced diffusion. /// /// This term equals the diffusion correlation function /// that is used for entropy scaling. pub fn ln_diffusion_reduced(&self) -> D { let s = self.residual_molar_entropy().into_reduced(); self.eos.diffusion_correlation(s, &self.molefracs) } /// Return the diffusion reference as used in entropy scaling. pub fn diffusion_reference(&self) -> Diffusivity<D> { self.eos .diffusion_reference(self.temperature, self.volume, &self.moles) } /// Return the thermal conductivity via entropy scaling. pub fn thermal_conductivity(&self) -> ThermalConductivity<D> { let s = self.residual_molar_entropy().into_reduced(); self.eos .thermal_conductivity_reference(self.temperature, self.volume, &self.moles) * Dimensionless::new( self.eos .thermal_conductivity_correlation(s, &self.molefracs) .exp(), ) } /// Return the logarithm of the reduced thermal conductivity. /// /// This term equals the thermal conductivity correlation function /// that is used for entropy scaling. pub fn ln_thermal_conductivity_reduced(&self) -> D { let s = self.residual_molar_entropy().into_reduced(); self.eos .thermal_conductivity_correlation(s, &self.molefracs) } /// Return the thermal conductivity reference as used in entropy scaling. pub fn thermal_conductivity_reference(&self) -> ThermalConductivity<D> { self.eos .thermal_conductivity_reference(self.temperature, self.volume, &self.moles) } }
Rust
3D
feos-org/feos
crates/feos-core/src/state/properties.rs
.rs
13,018
323
use super::{Contributions, State}; use crate::equation_of_state::{Molarweight, Total}; use crate::{ReferenceSystem, Residual}; use nalgebra::allocator::Allocator; use nalgebra::{DefaultAllocator, OVector}; use num_dual::{Dual, DualNum, Gradients, partial, partial2}; use quantity::*; use std::ops::{Div, Neg}; type InvP<T> = Quantity<T, <_Pressure as Neg>::Output>; type InvT<T> = Quantity<T, <_Temperature as Neg>::Output>; impl<E: Total<N, D>, N: Gradients, D: DualNum<f64> + Copy> State<E, N, D> where DefaultAllocator: Allocator<N>, { /// Chemical potential: $\mu_i=\left(\frac{\partial A}{\partial N_i}\right)_{T,V,N_j}$ pub fn chemical_potential(&self, contributions: Contributions) -> MolarEnergy<OVector<D, N>> { let residual = || self.residual_chemical_potential(); let ideal_gas = || { quantity::ad::gradient_copy( partial2( |n, &t, &v| self.eos.ideal_gas_helmholtz_energy(t, v, &n), &self.temperature, &self.volume, ), &self.moles, ) .1 }; Self::contributions(ideal_gas, residual, contributions) } /// Partial derivative of chemical potential w.r.t. temperature: $\left(\frac{\partial\mu_i}{\partial T}\right)_{V,N_i}$ pub fn dmu_dt(&self, contributions: Contributions) -> MolarEntropy<OVector<D, N>> { let residual = || self.dmu_res_dt(); let ideal_gas = || { quantity::ad::partial_hessian_copy( partial( |(n, t), &v| self.eos.ideal_gas_helmholtz_energy(t, v, &n), &self.volume, ), (&self.moles, self.temperature), ) .3 }; Self::contributions(ideal_gas, residual, contributions) } /// Molar isochoric heat capacity: $c_v=\left(\frac{\partial u}{\partial T}\right)_{V,N_i}$ pub fn molar_isochoric_heat_capacity(&self, contributions: Contributions) -> MolarEntropy<D> { self.temperature * self.ds_dt(contributions) / self.total_moles } /// Partial derivative of the molar isochoric heat capacity w.r.t. temperature: $\left(\frac{\partial c_V}{\partial T}\right)_{V,N_i}$ pub fn dc_v_dt( &self, contributions: Contributions, ) -> <MolarEntropy<D> as Div<Temperature<D>>>::Output { (self.temperature * self.d2s_dt2(contributions) + self.ds_dt(contributions)) / self.total_moles } /// Molar isobaric heat capacity: $c_p=\left(\frac{\partial h}{\partial T}\right)_{p,N_i}$ pub fn molar_isobaric_heat_capacity(&self, contributions: Contributions) -> MolarEntropy<D> { match contributions { Contributions::Residual => self.residual_molar_isobaric_heat_capacity(), _ => { self.temperature / self.total_moles * (self.ds_dt(contributions) - (self.dp_dt(contributions) * self.dp_dt(contributions)) / self.dp_dv(contributions)) } } } /// Entropy: $S=-\left(\frac{\partial A}{\partial T}\right)_{V,N_i}$ pub fn entropy(&self, contributions: Contributions) -> Entropy<D> { let residual = || self.residual_entropy(); let ideal_gas = || { -quantity::ad::first_derivative( partial2( |t, &v, n| self.eos.ideal_gas_helmholtz_energy(t, v, n), &self.volume, &self.moles, ), self.temperature, ) .1 }; Self::contributions(ideal_gas, residual, contributions) } /// Molar entropy: $s=\frac{S}{N}$ pub fn molar_entropy(&self, contributions: Contributions) -> MolarEntropy<D> { self.entropy(contributions) / self.total_moles } /// Partial molar entropy: $s_i=\left(\frac{\partial S}{\partial N_i}\right)_{T,p,N_j}$ pub fn partial_molar_entropy(&self) -> MolarEntropy<OVector<D, N>> { let c = Contributions::Total; -(self.dmu_dt(c) + self.dp_dni(c) * (self.dp_dt(c) / self.dp_dv(c))) } /// Partial derivative of the entropy w.r.t. temperature: $\left(\frac{\partial S}{\partial T}\right)_{V,N_i}$ pub fn ds_dt( &self, contributions: Contributions, ) -> <Entropy<D> as Div<Temperature<D>>>::Output { let residual = || self.ds_res_dt(); let ideal_gas = || { -quantity::ad::second_derivative( partial2( |t, &v, n| self.eos.ideal_gas_helmholtz_energy(t, v, n), &self.volume, &self.moles, ), self.temperature, ) .2 }; Self::contributions(ideal_gas, residual, contributions) } /// Second partial derivative of the entropy w.r.t. temperature: $\left(\frac{\partial^2 S}{\partial T^2}\right)_{V,N_i}$ pub fn d2s_dt2( &self, contributions: Contributions, ) -> <<Entropy<D> as Div<Temperature<D>>>::Output as Div<Temperature<D>>>::Output { let residual = || self.d2s_res_dt2(); let ideal_gas = || { -quantity::ad::third_derivative( partial2( |t, &v, n| self.eos.ideal_gas_helmholtz_energy(t, v, n), &self.volume, &self.moles, ), self.temperature, ) .3 }; Self::contributions(ideal_gas, residual, contributions) } /// Enthalpy: $H=A+TS+pV$ pub fn enthalpy(&self, contributions: Contributions) -> Energy<D> { self.temperature * self.entropy(contributions) + self.helmholtz_energy(contributions) + self.pressure(contributions) * self.volume } /// Molar enthalpy: $h=\frac{H}{N}$ pub fn molar_enthalpy(&self, contributions: Contributions) -> MolarEnergy<D> { self.enthalpy(contributions) / self.total_moles } /// Partial molar enthalpy: $h_i=\left(\frac{\partial H}{\partial N_i}\right)_{T,p,N_j}$ pub fn partial_molar_enthalpy(&self) -> MolarEnergy<OVector<D, N>> { let s = self.partial_molar_entropy(); let mu = self.chemical_potential(Contributions::Total); s * self.temperature + mu } /// Helmholtz energy: $A$ pub fn helmholtz_energy(&self, contributions: Contributions) -> Energy<D> { let residual = || self.residual_helmholtz_energy(); let ideal_gas = || { quantity::ad::zeroth_derivative( partial2( |t, &v, n| self.eos.ideal_gas_helmholtz_energy(t, v, n), &self.volume, &self.moles, ), self.temperature, ) }; Self::contributions(ideal_gas, residual, contributions) } /// Molar Helmholtz energy: $a=\frac{A}{N}$ pub fn molar_helmholtz_energy(&self, contributions: Contributions) -> MolarEnergy<D> { self.helmholtz_energy(contributions) / self.total_moles } /// Internal energy: $U=A+TS$ pub fn internal_energy(&self, contributions: Contributions) -> Energy<D> { self.temperature * self.entropy(contributions) + self.helmholtz_energy(contributions) } /// Molar internal energy: $u=\frac{U}{N}$ pub fn molar_internal_energy(&self, contributions: Contributions) -> MolarEnergy<D> { self.internal_energy(contributions) / self.total_moles } /// Gibbs energy: $G=A+pV$ pub fn gibbs_energy(&self, contributions: Contributions) -> Energy<D> { self.pressure(contributions) * self.volume + self.helmholtz_energy(contributions) } /// Molar Gibbs energy: $g=\frac{G}{N}$ pub fn molar_gibbs_energy(&self, contributions: Contributions) -> MolarEnergy<D> { self.gibbs_energy(contributions) / self.total_moles } /// Joule Thomson coefficient: $\mu_{JT}=\left(\frac{\partial T}{\partial p}\right)_{H,N_i}$ pub fn joule_thomson(&self) -> <Temperature<D> as Div<Pressure<D>>>::Output { let c = Contributions::Total; -(self.volume + self.temperature * self.dp_dt(c) / self.dp_dv(c)) / (self.total_moles * self.molar_isobaric_heat_capacity(c)) } /// Isentropic compressibility: $\kappa_s=-\frac{1}{V}\left(\frac{\partial V}{\partial p}\right)_{S,N_i}$ pub fn isentropic_compressibility(&self) -> InvP<D> { let c = Contributions::Total; -self.molar_isochoric_heat_capacity(c) / (self.molar_isobaric_heat_capacity(c) * self.dp_dv(c) * self.volume) } /// Isenthalpic compressibility: $\kappa_H=-\frac{1}{V}\left(\frac{\partial V}{\partial p}\right)_{H,N_i}$ pub fn isenthalpic_compressibility(&self) -> InvP<D> { self.isentropic_compressibility() * Dimensionless::new(self.grueneisen_parameter() + 1.0) } /// Thermal expansivity: $\alpha_p=-\frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{p,N_i}$ pub fn thermal_expansivity(&self) -> InvT<D> { let c = Contributions::Total; -self.dp_dt(c) / self.dp_dv(c) / self.volume } /// Grueneisen parameter: $\phi=V\left(\frac{\partial p}{\partial U}\right)_{V,n_i}=\frac{v}{c_v}\left(\frac{\partial p}{\partial T}\right)_{v,n_i}=\frac{\rho}{T}\left(\frac{\partial T}{\partial \rho}\right)_{s, n_i}$ pub fn grueneisen_parameter(&self) -> D { let c = Contributions::Total; (self.dp_dt(c) / (self.molar_isochoric_heat_capacity(c) * self.density)).into_value() } /// Chemical potential $\mu_i$ evaluated for each contribution of the equation of state. pub fn chemical_potential_contributions( &self, component: usize, contributions: Contributions, ) -> Vec<(&'static str, MolarEnergy<D>)> { let t = Dual::from_re(self.temperature.into_reduced()); let v = Dual::from_re(self.density.into_reduced().recip()); let mut x = self.molefracs.map(Dual::from_re); x[component].eps = D::one(); let mut res = Vec::new(); if let Contributions::IdealGas | Contributions::Total = contributions { res.push(( self.eos.ideal_gas_model(), self.eos.ideal_gas_molar_helmholtz_energy(t, v, &x), )); } if let Contributions::Residual | Contributions::Total = contributions { res.extend( self.eos .lift() .molar_helmholtz_energy_contributions(t, v, &x), ); } res.into_iter() .map(|(s, v)| (s, MolarEnergy::from_reduced(v.eps))) .collect() } } impl<E: Total<N, D> + Molarweight<N, D>, N: Gradients, D: DualNum<f64> + Copy> State<E, N, D> where DefaultAllocator: Allocator<N>, { /// Specific isochoric heat capacity: $c_v^{(m)}=\frac{C_v}{m}$ pub fn specific_isochoric_heat_capacity( &self, contributions: Contributions, ) -> SpecificEntropy<D> { self.molar_isochoric_heat_capacity(contributions) / self.total_molar_weight() } /// Specific isobaric heat capacity: $c_p^{(m)}=\frac{C_p}{m}$ pub fn specific_isobaric_heat_capacity( &self, contributions: Contributions, ) -> SpecificEntropy<D> { self.molar_isobaric_heat_capacity(contributions) / self.total_molar_weight() } /// Specific entropy: $s^{(m)}=\frac{S}{m}$ pub fn specific_entropy(&self, contributions: Contributions) -> SpecificEntropy<D> { self.molar_entropy(contributions) / self.total_molar_weight() } /// Specific enthalpy: $h^{(m)}=\frac{H}{m}$ pub fn specific_enthalpy(&self, contributions: Contributions) -> SpecificEnergy<D> { self.molar_enthalpy(contributions) / self.total_molar_weight() } /// Specific Helmholtz energy: $a^{(m)}=\frac{A}{m}$ pub fn specific_helmholtz_energy(&self, contributions: Contributions) -> SpecificEnergy<D> { self.molar_helmholtz_energy(contributions) / self.total_molar_weight() } /// Specific internal energy: $u^{(m)}=\frac{U}{m}$ pub fn specific_internal_energy(&self, contributions: Contributions) -> SpecificEnergy<D> { self.molar_internal_energy(contributions) / self.total_molar_weight() } /// Specific Gibbs energy: $g^{(m)}=\frac{G}{m}$ pub fn specific_gibbs_energy(&self, contributions: Contributions) -> SpecificEnergy<D> { self.molar_gibbs_energy(contributions) / self.total_molar_weight() } } impl<E: Total<N> + Molarweight<N>, N: Gradients> State<E, N> where DefaultAllocator: Allocator<N>, { /// Speed of sound: $c=\sqrt{\left(\frac{\partial p}{\partial\rho^{(m)}}\right)_{S,N_i}}$ pub fn speed_of_sound(&self) -> Velocity { (self.density * self.total_molar_weight() * self.isentropic_compressibility()) .inv() .sqrt() } }
Rust
3D
feos-org/feos
crates/feos-core/src/state/critical_point.rs
.rs
20,754
615
use super::{DensityInitialization, State}; use crate::equation_of_state::Residual; use crate::errors::{FeosError, FeosResult}; use crate::{ReferenceSystem, SolverOptions, Subset, TemperatureOrPressure, Verbosity}; use nalgebra::allocator::Allocator; use nalgebra::{DVector, DefaultAllocator, OMatrix, OVector, SVector, U1, U2, U3}; use num_dual::linalg::smallest_ev; use num_dual::{ Dual3, DualNum, DualSVec, DualSVec64, DualStruct, Gradients, first_derivative, implicit_derivative_binary, implicit_derivative_vec, jacobian, partial, partial2, third_derivative, }; use quantity::{Density, Pressure, Temperature}; const MAX_ITER_CRIT_POINT: usize = 50; const MAX_ITER_CRIT_POINT_BINARY: usize = 200; const TOL_CRIT_POINT: f64 = 1e-8; /// # Critical points impl<R: Residual + Subset> State<R> { /// Calculate the pure component critical point of all components. pub fn critical_point_pure( eos: &R, initial_temperature: Option<Temperature>, initial_density: Option<Density>, options: SolverOptions, ) -> FeosResult<Vec<Self>> { (0..eos.components()) .map(|i| { let pure_eos = eos.subset(&[i]); let cp = State::critical_point( &pure_eos, None, initial_temperature, initial_density, options, )?; let mut molefracs = DVector::zeros(eos.components()); molefracs[i] = 1.0; State::new_intensive(eos, cp.temperature, cp.density, &molefracs) }) .collect() } } impl<E: Residual<N, D>, N: Gradients, D: DualNum<f64> + Copy> State<E, N, D> where DefaultAllocator: Allocator<N> + Allocator<N, N> + Allocator<U1, N>, { pub fn critical_point_binary<TP: TemperatureOrPressure<D>>( eos: &E, temperature_or_pressure: TP, initial_temperature: Option<Temperature>, initial_molefracs: Option<[f64; 2]>, initial_density: Option<Density>, options: SolverOptions, ) -> FeosResult<Self> { let eos_re = eos.re(); let n = N::from_usize(2); let initial_molefracs = initial_molefracs.unwrap_or([0.5; 2]); let initial_molefracs = OVector::from_fn_generic(n, U1, |i, _| initial_molefracs[i]); if let Some(t) = temperature_or_pressure.temperature() { let [rho0, rho1] = critical_point_binary_t( &eos_re, t.re(), initial_molefracs, initial_density, options, )?; let rho = implicit_derivative_binary( |rho0, rho1, &temperature| { let rho = [rho0, rho1]; let density = rho0 + rho1; let molefracs = OVector::from_fn_generic(n, U1, |i, _| rho[i] / density); criticality_conditions(&eos.lift(), temperature, density, &molefracs) }, rho0, rho1, &t.into_reduced(), ); let density = rho[0] + rho[1]; let molefracs = OVector::from_fn_generic(n, U1, |i, _| rho[i] / density); Self::new_intensive(eos, t, Density::from_reduced(density), &molefracs) } else if let Some(p) = temperature_or_pressure.pressure() { let x = critical_point_binary_p( &eos_re, p.re(), initial_temperature, initial_molefracs, initial_density, options, )?; let trho = implicit_derivative_vec::<_, _, _, _, U3>( |x, &p| { let t = x[0]; let rho = [x[1], x[2]]; criticality_conditions_p(&eos.lift(), p, t, rho) }, SVector::from(x), &p.into_reduced(), ); let density = trho[1] + trho[2]; let molefracs = OVector::from_fn_generic(n, U1, |i, _| trho[i + 1] / density); let t = Temperature::from_reduced(trho[0]); Self::new_intensive(eos, t, Density::from_reduced(density), &molefracs) } else { unreachable!() } } /// Calculate the critical point of a system for given moles. pub fn critical_point( eos: &E, molefracs: Option<&OVector<D, N>>, initial_temperature: Option<Temperature>, initial_density: Option<Density>, options: SolverOptions, ) -> FeosResult<Self> { let eos_re = eos.re(); let molefracs = molefracs.map_or_else(E::pure_molefracs, |x| x.clone()); let x = &molefracs.map(|x| x.re()); let rho_init = initial_density.map(|r| r.into_reduced()); let trial_temperatures = [300.0, 700.0, 500.0]; let mut t_rho = None; if let Some(t) = initial_temperature { let t = t.into_reduced(); t_rho = Some(critical_point_hkm(&eos_re, x, t, rho_init, options)?); } for &t in trial_temperatures.iter() { if t_rho.is_some() { break; } t_rho = critical_point_hkm(&eos_re, x, t, rho_init, options).ok(); } let Some(t_rho) = t_rho else { return Err(FeosError::NotConverged(String::from("Critical point"))); }; // implicit derivative let [temperature, density] = implicit_derivative_binary( |t, rho, x| criticality_conditions(&eos.lift(), t, rho, x), t_rho[0], t_rho[1], &molefracs, ); Self::new_intensive( eos, Temperature::from_reduced(temperature), Density::from_reduced(density), &molefracs, ) } } fn critical_point_hkm<E: Residual<N>, N: Gradients>( eos: &E, molefracs: &OVector<f64, N>, initial_temperature: f64, initial_density: Option<f64>, options: SolverOptions, ) -> FeosResult<[f64; 2]> where DefaultAllocator: Allocator<N> + Allocator<N, N> + Allocator<U1, N>, { let (max_iter, tol, verbosity) = options.unwrap_or(MAX_ITER_CRIT_POINT, TOL_CRIT_POINT); let mut t = initial_temperature; let max_density = eos.compute_max_density(molefracs); let mut rho = initial_density.unwrap_or(0.3 * max_density); log_iter!( verbosity, " iter | residual | temperature | density " ); log_iter!(verbosity, "{:-<64}", ""); log_iter!( verbosity, " {:4} | | {:13.8} | {:12.8}", 0, Temperature::from_reduced(t), Density::from_reduced(rho), ); for i in 1..=max_iter { // calculate residuals and derivatives w.r.t. temperature and density let (res, jac) = jacobian::<_, _, _, U2, U2, _>( |x: SVector<DualSVec64<2>, 2>| { SVector::from(criticality_conditions( &eos.lift(), x[0], x[1], &molefracs.map(DualSVec::from_re), )) }, &SVector::from([t, rho]), ); // calculate Newton step let delta = jac.lu().solve::<U2, U1, _>(&res); let mut delta = delta.ok_or(FeosError::IterationFailed("Critical point".into()))?; // reduce step if necessary if delta[0].abs() > 0.25 * t { delta *= 0.25 * t / delta[0].abs() } if delta[1].abs() > 0.03 * max_density { delta *= 0.03 * max_density / delta[1].abs() } // apply step t -= delta[0]; rho -= delta[1]; rho = f64::max(rho, 1e-4 * max_density); log_iter!( verbosity, " {:4} | {:14.8e} | {:13.8} | {:12.8}", i, res.norm(), Temperature::from_reduced(t), Density::from_reduced(rho), ); // check convergence if res.norm() < tol { log_result!( verbosity, "Critical point calculation converged in {} step(s)\n", i ); return Ok([t, rho]); } } Err(FeosError::NotConverged(String::from("Critical point"))) } /// Calculate the critical point of a binary system for given temperature. fn critical_point_binary_t<E: Residual<N>, N: Gradients>( eos: &E, temperature: Temperature, initial_molefracs: OVector<f64, N>, initial_density: Option<Density>, options: SolverOptions, ) -> FeosResult<[f64; 2]> where DefaultAllocator: Allocator<N> + Allocator<N, N> + Allocator<U1, N>, { let (max_iter, tol, verbosity) = options.unwrap_or(MAX_ITER_CRIT_POINT_BINARY, TOL_CRIT_POINT); let t = temperature.to_reduced(); let n = N::from_usize(2); let max_density = eos.compute_max_density(&initial_molefracs); let rho_init = initial_density.map_or(0.3 * max_density, |r| r.into_reduced()); let mut rho = SVector::from([initial_molefracs[0], initial_molefracs[1]]) * rho_init; log_iter!( verbosity, " iter | residual | density 1 | density 2 " ); log_iter!(verbosity, "{:-<69}", ""); log_iter!( verbosity, " {:4} | | {:12.8} | {:12.8}", 0, Density::from_reduced(rho[0]), Density::from_reduced(rho[1]), ); for i in 1..=max_iter { // calculate residuals and derivatives w.r.t. partial densities let (res, jac) = jacobian::<_, _, _, U2, U2, _>( |rho: SVector<DualSVec64<2>, 2>| { let density = rho.sum(); let x = rho / density; let molefracs = OVector::from_fn_generic(n, U1, |i, _| x[i]); let t = DualSVec::from_re(t); SVector::from(criticality_conditions(&eos.lift(), t, density, &molefracs)) }, &rho, ); // calculate Newton step let delta = jac.lu().solve(&res); let mut delta = delta.ok_or(FeosError::IterationFailed("Critical point".into()))?; // reduce step if necessary for i in 0..2 { if delta[i].abs() > 0.03 * max_density { delta *= 0.03 * max_density / delta[i].abs() } } // apply step rho -= delta; rho[0] = f64::max(rho[0], 1e-4 * max_density); rho[1] = f64::max(rho[1], 1e-4 * max_density); log_iter!( verbosity, " {:4} | {:14.8e} | {:12.8} | {:12.8}", i, res.norm(), Density::from_reduced(rho[0]), Density::from_reduced(rho[1]), ); // check convergence if res.norm() < tol { log_result!( verbosity, "Critical point calculation converged in {} step(s)\n", i ); return Ok(rho.data.0[0]); } } Err(FeosError::NotConverged(String::from("Critical point"))) } /// Calculate the critical point of a binary system for given pressure. fn critical_point_binary_p<E: Residual<N>, N: Gradients>( eos: &E, pressure: Pressure, initial_temperature: Option<Temperature>, initial_molefracs: OVector<f64, N>, initial_density: Option<Density>, options: SolverOptions, ) -> FeosResult<[f64; 3]> where DefaultAllocator: Allocator<N> + Allocator<N, N> + Allocator<U1, N>, { let (max_iter, tol, verbosity) = options.unwrap_or(MAX_ITER_CRIT_POINT_BINARY, TOL_CRIT_POINT); let p = pressure.to_reduced(); let mut t = initial_temperature.map(|t| t.to_reduced()).unwrap_or(300.0); let max_density = eos.compute_max_density(&initial_molefracs); let rho_init = initial_density.map_or(0.3 * max_density, |r| r.into_reduced()); let mut rho = SVector::from([initial_molefracs[0], initial_molefracs[1]]) * rho_init; log_iter!( verbosity, " iter | residual | temperature | density 1 | density 2 " ); log_iter!(verbosity, "{:-<87}", ""); log_iter!( verbosity, " {:4} | | {:13.8} | {:12.8} | {:12.8}", 0, Temperature::from_reduced(t), Density::from_reduced(rho[0]), Density::from_reduced(rho[1]), ); for i in 1..=max_iter { // calculate residuals and derivatives w.r.t. temperature and partial densities let res = |x: SVector<DualSVec64<3>, 3>| { let t = x[0]; let partial_density = [x[1], x[2]]; let p = DualSVec::from_re(p); criticality_conditions_p(&eos.lift(), p, t, partial_density) }; let (res, jac) = jacobian::<_, _, _, U3, U3, _>(res, &SVector::from([t, rho[0], rho[1]])); // calculate Newton step let delta = jac.lu().solve(&res); let mut delta = delta.ok_or(FeosError::IterationFailed("Critical point".into()))?; // reduce step if necessary if delta[0].abs() > 0.25 * t { delta *= 0.25 * t / delta[0].abs() } if delta[1].abs() > 0.03 * max_density { delta *= 0.03 * max_density / delta[1].abs() } if delta[2].abs() > 0.03 * max_density { delta *= 0.03 * max_density / delta[2].abs() } // apply step t -= delta[0]; rho[0] -= delta[1]; rho[1] -= delta[2]; rho[0] = f64::max(rho[0], 1e-4 * max_density); rho[1] = f64::max(rho[1], 1e-4 * max_density); log_iter!( verbosity, " {:4} | {:14.8e} | {:13.8} | {:12.8} | {:12.8}", i, res.norm(), Temperature::from_reduced(t), Density::from_reduced(rho[0]), Density::from_reduced(rho[1]), ); // check convergence if res.norm() < tol { log_result!( verbosity, "Critical point calculation converged in {} step(s)\n", i ); return Ok([t, rho[0], rho[1]]); } } Err(FeosError::NotConverged(String::from("Critical point"))) } impl<E: Residual<N>, N: Gradients> State<E, N> where DefaultAllocator: Allocator<N> + Allocator<N, N> + Allocator<U1, N>, { pub fn spinodal( eos: &E, temperature: Temperature, molefracs: Option<&OVector<f64, N>>, options: SolverOptions, ) -> FeosResult<[Self; 2]> { let critical_point = Self::critical_point(eos, molefracs, None, None, options)?; let molefracs = molefracs.map_or_else(E::pure_molefracs, |x| x.clone()); let spinodal_vapor = Self::calculate_spinodal( eos, temperature, &molefracs, DensityInitialization::Vapor, options, )?; let rho = 2.0 * critical_point.density - spinodal_vapor.density; let spinodal_liquid = Self::calculate_spinodal( eos, temperature, &molefracs, DensityInitialization::InitialDensity(rho), options, )?; Ok([spinodal_vapor, spinodal_liquid]) } fn calculate_spinodal( eos: &E, temperature: Temperature, molefracs: &OVector<f64, N>, density_initialization: DensityInitialization, options: SolverOptions, ) -> FeosResult<Self> { let (max_iter, tol, verbosity) = options.unwrap_or(MAX_ITER_CRIT_POINT, TOL_CRIT_POINT); let max_density = eos.compute_max_density(molefracs); let t = temperature.to_reduced(); let mut rho = match density_initialization { DensityInitialization::Vapor => 1e-5 * max_density, DensityInitialization::Liquid => max_density, DensityInitialization::InitialDensity(rho) => rho.to_reduced(), }; log_iter!(verbosity, " iter | residual | density "); log_iter!(verbosity, "{:-<46}", ""); log_iter!( verbosity, " {:4} | | {:12.8}", 0, Density::from_reduced(rho), ); for i in 1..=max_iter { // calculate residuals and derivative w.r.t. density let (f, df) = first_derivative( partial( |rho, x| stability_condition(&eos.lift(), t.into(), rho, x), molefracs, ), rho, ); // calculate Newton step let mut delta = f / df; // reduce step if necessary if delta.abs() > 0.03 * max_density { delta *= 0.03 * max_density / delta.abs() } // apply step rho -= delta; rho = f64::max(rho, 1e-4 * max_density); log_iter!( verbosity, " {:4} | {:14.8e} | {:12.8}", i, f.abs(), Density::from_reduced(rho), ); // check convergence if f.abs() < tol { log_result!( verbosity, "Spinodal calculation converged in {} step(s)\n", i ); return Self::new_intensive( eos, temperature, Density::from_reduced(rho), molefracs, ); } } Err(FeosError::SuperCritical) } } fn criticality_conditions<E: Residual<N, D>, N: Gradients, D: DualNum<f64> + Copy>( eos: &E, temperature: D, density: D, molefracs: &OVector<D, N>, ) -> [D; 2] where DefaultAllocator: Allocator<N> + Allocator<U1, N> + Allocator<N, N>, { // calculate M let molar_volume = density.recip(); let sqrt_z = molefracs.map(|z| z.sqrt()); let z_mix = &sqrt_z * sqrt_z.transpose(); let m = dmu_dn(eos, temperature, molar_volume, molefracs); let (r, c) = m.shape_generic(); let m = m.component_mul(&z_mix) + OMatrix::identity_generic(r, c); // calculate smallest eigenvalue and corresponding eigenvector let (l, u) = smallest_ev(m); let (_, _, _, c2) = third_derivative( |s| { let n = molefracs.map(Dual3::from_re); let n = n + sqrt_z.component_mul(&u).map(Dual3::from_re) * s; let t = Dual3::from_re(temperature); let v = Dual3::from_re(molar_volume); let ig = n.dot(&n.map(|n| (n / v).ln() - 1.0)); eos.lift().residual_helmholtz_energy(t, v, &n) / t + ig }, D::from(0.0), ); [l, c2] } fn criticality_conditions_p<E: Residual<N, D>, N: Gradients, D: DualNum<f64> + Copy>( eos: &E, pressure: D, temperature: D, partial_density: [D; 2], ) -> SVector<D, 3> where DefaultAllocator: Allocator<N> + Allocator<U1, N> + Allocator<N, N>, { let density = partial_density[0] + partial_density[1]; let n = N::from_usize(2); let molefracs: OVector<D, N> = OVector::from_fn_generic(n, U1, |i, _| partial_density[i] / density); let [c1, c2] = criticality_conditions(eos, temperature, density, &molefracs); // calculate pressure let a = partial2( |v, &t, x| eos.lift().residual_molar_helmholtz_energy(t, v, x), &temperature, &molefracs, ); let (_, da) = first_derivative(a, D::one()); let p_calc = -da + density * temperature; SVector::from([c1, c2, -p_calc + pressure]) } fn stability_condition<E: Residual<N, D>, N: Gradients, D: DualNum<f64> + Copy>( eos: &E, temperature: D, density: D, molefracs: &OVector<D, N>, ) -> D where DefaultAllocator: Allocator<N> + Allocator<U1, N> + Allocator<N, N>, { // calculate M let molar_volume = density.recip(); let sqrt_z = molefracs.map(|z| z.sqrt()); let z_mix = &sqrt_z * sqrt_z.transpose(); let m = dmu_dn(eos, temperature, molar_volume, molefracs); let (r, c) = m.shape_generic(); let m = m.component_mul(&z_mix) + OMatrix::identity_generic(r, c); // calculate smallest eigenvalue and corresponding eigenvector let (l, _) = smallest_ev(m); l } fn dmu_dn<E: Residual<N, D>, N: Gradients, D: DualNum<f64> + Copy>( eos: &E, temperature: D, molar_volume: D, molefracs: &OVector<D, N>, ) -> OMatrix<D, N, N> where DefaultAllocator: Allocator<N> + Allocator<N, N>, { let (_, _, h) = N::hessian( |n, &(t, v)| eos.lift().residual_helmholtz_energy(t, v, &n) / t, molefracs, &(temperature, molar_volume), ); h }
Rust
3D
feos-org/feos
crates/feos-core/src/state/builder.rs
.rs
8,333
252
use super::{DensityInitialization, State}; use crate::Total; use crate::equation_of_state::Residual; use crate::errors::FeosResult; use nalgebra::DVector; use quantity::*; /// A simple tool to construct [State]s with arbitrary input parameters. /// /// # Examples /// ``` /// # use feos_core::{FeosResult, StateBuilder}; /// # use feos_core::cubic::{PengRobinson, PengRobinsonParameters}; /// # use quantity::*; /// # use nalgebra::dvector; /// # use approx::assert_relative_eq; /// # fn main() -> FeosResult<()> { /// // Create a state for given T,V,N /// let eos = &PengRobinson::new(PengRobinsonParameters::new_simple(&[369.8], &[41.9 * 1e5], &[0.15], &[15.0])?); /// let state = StateBuilder::new(&eos) /// .temperature(300.0 * KELVIN) /// .volume(12.5 * METER.powi::<3>()) /// .moles(&(dvector![2.5] * MOL)) /// .build()?; /// assert_eq!(state.density, 0.2 * MOL / METER.powi::<3>()); /// /// // For a pure component, the composition does not need to be specified. /// let eos = &PengRobinson::new(PengRobinsonParameters::new_simple(&[369.8], &[41.9 * 1e5], &[0.15], &[15.0])?); /// let state = StateBuilder::new(&eos) /// .temperature(300.0 * KELVIN) /// .volume(12.5 * METER.powi::<3>()) /// .total_moles(2.5 * MOL) /// .build()?; /// assert_eq!(state.density, 0.2 * MOL / METER.powi::<3>()); /// /// // The state can be constructed without providing any extensive property. /// let eos = &PengRobinson::new( /// PengRobinsonParameters::new_simple( /// &[369.8, 305.4], /// &[41.9 * 1e5, 48.2 * 1e5], /// &[0.15, 0.10], /// &[15.0, 30.0] /// )? /// ); /// let state = StateBuilder::new(&eos) /// .temperature(300.0 * KELVIN) /// .partial_density(&(dvector![0.2, 0.6] * MOL / METER.powi::<3>())) /// .build()?; /// assert_relative_eq!(state.molefracs, dvector![0.25, 0.75]); /// assert_relative_eq!(state.density, 0.8 * MOL / METER.powi::<3>()); /// # Ok(()) /// # } /// ``` #[derive(Clone)] pub struct StateBuilder<'a, E, const IG: bool> { eos: &'a E, temperature: Option<Temperature>, volume: Option<Volume>, density: Option<Density>, partial_density: Option<&'a Density<DVector<f64>>>, total_moles: Option<Moles>, moles: Option<&'a Moles<DVector<f64>>>, molefracs: Option<&'a DVector<f64>>, pressure: Option<Pressure>, molar_enthalpy: Option<MolarEnergy>, molar_entropy: Option<MolarEntropy>, molar_internal_energy: Option<MolarEnergy>, density_initialization: Option<DensityInitialization>, initial_temperature: Option<Temperature>, } impl<'a, E: Residual> StateBuilder<'a, E, false> { /// Create a new `StateBuilder` for the given equation of state. pub fn new(eos: &'a E) -> Self { StateBuilder { eos, temperature: None, volume: None, density: None, partial_density: None, total_moles: None, moles: None, molefracs: None, pressure: None, molar_enthalpy: None, molar_entropy: None, molar_internal_energy: None, density_initialization: None, initial_temperature: None, } } } impl<'a, E: Residual, const IG: bool> StateBuilder<'a, E, IG> { /// Provide the temperature for the new state. pub fn temperature(mut self, temperature: Temperature) -> Self { self.temperature = Some(temperature); self } /// Provide the volume for the new state. pub fn volume(mut self, volume: Volume) -> Self { self.volume = Some(volume); self } /// Provide the density for the new state. pub fn density(mut self, density: Density) -> Self { self.density = Some(density); self } /// Provide partial densities for the new state. pub fn partial_density(mut self, partial_density: &'a Density<DVector<f64>>) -> Self { self.partial_density = Some(partial_density); self } /// Provide the total moles for the new state. pub fn total_moles(mut self, total_moles: Moles) -> Self { self.total_moles = Some(total_moles); self } /// Provide the moles for the new state. pub fn moles(mut self, moles: &'a Moles<DVector<f64>>) -> Self { self.moles = Some(moles); self } /// Provide the molefracs for the new state. pub fn molefracs(mut self, molefracs: &'a DVector<f64>) -> Self { self.molefracs = Some(molefracs); self } /// Provide the pressure for the new state. pub fn pressure(mut self, pressure: Pressure) -> Self { self.pressure = Some(pressure); self } /// Specify a vapor state. pub fn vapor(mut self) -> Self { self.density_initialization = Some(DensityInitialization::Vapor); self } /// Specify a liquid state. pub fn liquid(mut self) -> Self { self.density_initialization = Some(DensityInitialization::Liquid); self } /// Provide an initial density used in density iterations. pub fn initial_density(mut self, initial_density: Density) -> Self { self.density_initialization = Some(DensityInitialization::InitialDensity(initial_density)); self } } impl<'a, E: Total, const IG: bool> StateBuilder<'a, E, IG> { /// Provide the molar enthalpy for the new state. pub fn molar_enthalpy(mut self, molar_enthalpy: MolarEnergy) -> StateBuilder<'a, E, true> { self.molar_enthalpy = Some(molar_enthalpy); self.convert() } /// Provide the molar entropy for the new state. pub fn molar_entropy(mut self, molar_entropy: MolarEntropy) -> StateBuilder<'a, E, true> { self.molar_entropy = Some(molar_entropy); self.convert() } /// Provide the molar internal energy for the new state. pub fn molar_internal_energy( mut self, molar_internal_energy: MolarEnergy, ) -> StateBuilder<'a, E, true> { self.molar_internal_energy = Some(molar_internal_energy); self.convert() } /// Provide an initial temperature used in the Newton solver. pub fn initial_temperature( mut self, initial_temperature: Temperature, ) -> StateBuilder<'a, E, true> { self.initial_temperature = Some(initial_temperature); self.convert() } fn convert(self) -> StateBuilder<'a, E, true> { StateBuilder { eos: self.eos, temperature: self.temperature, volume: self.volume, density: self.density, partial_density: self.partial_density, total_moles: self.total_moles, moles: self.moles, molefracs: self.molefracs, pressure: self.pressure, molar_enthalpy: self.molar_enthalpy, molar_entropy: self.molar_entropy, molar_internal_energy: self.molar_internal_energy, density_initialization: self.density_initialization, initial_temperature: self.initial_temperature, } } } impl<E: Residual> StateBuilder<'_, E, false> { /// Try to build the state with the given inputs. pub fn build(self) -> FeosResult<State<E>> { State::new( self.eos, self.temperature, self.volume, self.density, self.partial_density, self.total_moles, self.moles, self.molefracs, self.pressure, self.density_initialization, ) } } impl<E: Total> StateBuilder<'_, E, true> { /// Try to build the state with the given inputs. pub fn build(self) -> FeosResult<State<E>> { State::new_full( self.eos, self.temperature, self.volume, self.density, self.partial_density, self.total_moles, self.moles, self.molefracs, self.pressure, self.molar_enthalpy, self.molar_entropy, self.molar_internal_energy, self.density_initialization, self.initial_temperature, ) } }
Rust
3D
feos-org/feos
crates/feos-core/src/equation_of_state/mod.rs
.rs
6,377
211
use crate::{ReferenceSystem, StateHD}; use nalgebra::{ Const, DVector, DefaultAllocator, Dim, Dyn, OVector, SVector, U1, allocator::Allocator, }; use num_dual::DualNum; use quantity::{Energy, MolarEnergy, Moles, Temperature, Volume}; use std::ops::Deref; mod residual; pub use residual::{EntropyScaling, Molarweight, NoResidual, Residual, ResidualDyn, Subset}; /// An equation of state consisting of an ideal gas model /// and a residual Helmholtz energy model. #[derive(Clone)] pub struct EquationOfState<I, R> { pub ideal_gas: I, pub residual: R, } impl<I, R> Deref for EquationOfState<I, R> { type Target = R; fn deref(&self) -> &R { &self.residual } } impl<I, R> EquationOfState<I, R> { /// Return a new [EquationOfState] with the given ideal gas /// and residual models. pub fn new(ideal_gas: I, residual: R) -> Self { Self { ideal_gas, residual, } } } impl<I> EquationOfState<Vec<I>, NoResidual> { /// Return a new [EquationOfState] that only consists of /// an ideal gas models. pub fn ideal_gas(ideal_gas: Vec<I>) -> Self { let residual = NoResidual(ideal_gas.len()); Self { ideal_gas, residual, } } } impl<I, R: ResidualDyn> ResidualDyn for EquationOfState<Vec<I>, R> { fn components(&self) -> usize { self.residual.components() } fn compute_max_density<D: DualNum<f64> + Copy>(&self, molefracs: &DVector<D>) -> D { self.residual.compute_max_density(molefracs) } fn reduced_helmholtz_energy_density_contributions<D: DualNum<f64> + Copy>( &self, state: &StateHD<D>, ) -> Vec<(&'static str, D)> { self.residual .reduced_helmholtz_energy_density_contributions(state) } } impl<I: Clone, R: Subset> Subset for EquationOfState<Vec<I>, R> { fn subset(&self, component_list: &[usize]) -> Self { let ideal_gas = component_list .iter() .map(|&i| self.ideal_gas[i].clone()) .collect(); EquationOfState { ideal_gas, residual: self.residual.subset(component_list), } } } impl<I: Clone, R: Residual<Const<N>, D>, D: DualNum<f64> + Copy, const N: usize> Residual<Const<N>, D> for EquationOfState<[I; N], R> { fn components(&self) -> usize { N } type Real = EquationOfState<[I; N], R::Real>; type Lifted<D2: DualNum<f64, Inner = D> + Copy> = EquationOfState<[I; N], R::Lifted<D2>>; fn re(&self) -> Self::Real { EquationOfState::new(self.ideal_gas.clone(), self.residual.re()) } fn lift<D2: DualNum<f64, Inner = D> + Copy>(&self) -> Self::Lifted<D2> { EquationOfState::new(self.ideal_gas.clone(), self.residual.lift()) } fn compute_max_density(&self, molefracs: &SVector<D, N>) -> D { self.residual.compute_max_density(molefracs) } fn reduced_helmholtz_energy_density_contributions( &self, state: &StateHD<D, Const<N>>, ) -> Vec<(&'static str, D)> { self.residual .reduced_helmholtz_energy_density_contributions(state) } fn reduced_residual_helmholtz_energy_density(&self, state: &StateHD<D, Const<N>>) -> D { self.residual .reduced_residual_helmholtz_energy_density(state) } } /// Ideal gas Helmholtz energy contribution. pub trait IdealGas<D = f64> { /// Implementation of an ideal gas model in terms of the /// logarithm of the cubic thermal de Broglie wavelength /// in units ln(A³) for each component in the system. fn ln_lambda3<D2: DualNum<f64, Inner = D> + Copy>(&self, temperature: D2) -> D2; /// The name of the ideal gas model. fn ideal_gas_model(&self) -> &'static str; } /// A total Helmholtz energy model consisting of a [Residual] model and an [IdealGas] part. pub trait Total<N: Dim = Dyn, D: DualNum<f64> + Copy = f64>: Residual<N, D> where DefaultAllocator: Allocator<N>, { type IdealGas: IdealGas<D>; fn ideal_gas_model(&self) -> &'static str; fn ideal_gas(&self) -> impl Iterator<Item = &Self::IdealGas>; fn ln_lambda3<D2: DualNum<f64, Inner = D> + Copy>(&self, temperature: D2) -> OVector<D2, N> { OVector::from_iterator_generic( N::from_usize(self.components()), U1, self.ideal_gas().map(|i| i.ln_lambda3(temperature)), ) } fn ideal_gas_molar_helmholtz_energy<D2: DualNum<f64, Inner = D> + Copy>( &self, temperature: D2, molar_volume: D2, molefracs: &OVector<D2, N>, ) -> D2 { let partial_density = molefracs / molar_volume; let mut res = D2::from(0.0); for (i, &r) in self.ideal_gas().zip(partial_density.iter()) { let ln_rho_m1 = if r.re() == 0.0 { D2::from(0.0) } else { r.ln() - 1.0 }; res += r * (i.ln_lambda3(temperature) + ln_rho_m1) } res * molar_volume * temperature } fn ideal_gas_helmholtz_energy<D2: DualNum<f64, Inner = D> + Copy>( &self, temperature: Temperature<D2>, volume: Volume<D2>, moles: &Moles<OVector<D2, N>>, ) -> Energy<D2> { let total_moles = moles.sum(); let molefracs = moles / total_moles; let molar_volume = volume / total_moles; MolarEnergy::from_reduced(self.ideal_gas_molar_helmholtz_energy( temperature.into_reduced(), molar_volume.into_reduced(), &molefracs, )) * total_moles } } impl< I: IdealGas + Clone + 'static, C: Deref<Target = EquationOfState<Vec<I>, R>> + Clone, R: ResidualDyn + 'static, > Total<Dyn, f64> for C { type IdealGas = I; fn ideal_gas_model(&self) -> &'static str { self.ideal_gas[0].ideal_gas_model() } fn ideal_gas(&self) -> impl Iterator<Item = &Self::IdealGas> { self.ideal_gas.iter() } } impl<I: IdealGas<D> + Clone, R: Residual<Const<N>, D>, D: DualNum<f64> + Copy, const N: usize> Total<Const<N>, D> for EquationOfState<[I; N], R> { type IdealGas = I; fn ideal_gas_model(&self) -> &'static str { self.ideal_gas[0].ideal_gas_model() } fn ideal_gas(&self) -> impl Iterator<Item = &Self::IdealGas> { self.ideal_gas.iter() } }
Rust
3D
feos-org/feos
crates/feos-core/src/equation_of_state/residual.rs
.rs
17,915
512
use crate::{FeosError, FeosResult, ReferenceSystem, state::StateHD}; use nalgebra::{DVector, DefaultAllocator, Dim, Dyn, OMatrix, OVector, U1, allocator::Allocator}; use num_dual::{DualNum, Gradients, partial, partial2, second_derivative, third_derivative}; use quantity::ad::first_derivative; use quantity::*; use std::ops::{Deref, Div}; use std::sync::Arc; type Quot<T1, T2> = <T1 as Div<T2>>::Output; /// Molar weight of all components. /// /// Enables calculation of (mass) specific properties. pub trait Molarweight<N: Dim = Dyn, D: DualNum<f64> + Copy = f64> where DefaultAllocator: Allocator<N>, { fn molar_weight(&self) -> MolarWeight<OVector<D, N>>; } impl<C: Deref<Target = T>, T: Molarweight<N, D>, N: Dim, D: DualNum<f64> + Copy> Molarweight<N, D> for C where DefaultAllocator: Allocator<N>, { fn molar_weight(&self) -> MolarWeight<OVector<D, N>> { T::molar_weight(self) } } /// A model from which models for subsets of its components can be extracted. pub trait Subset { /// Return a model consisting of the components /// contained in component_list. fn subset(&self, component_list: &[usize]) -> Self; } impl<T: Subset> Subset for Arc<T> { fn subset(&self, component_list: &[usize]) -> Self { Arc::new(T::subset(self, component_list)) } } /// A simple residual Helmholtz energy model for arbitrary many components /// and no automatic differentiation of model parameters. /// /// This is a shortcut to implementing `Residual<Dyn, f64>`. To avoid unnecessary /// cloning, `Residual<Dyn, f64>` is automatically implemented for all pointer /// types that deref to the struct implementing `ResidualDyn` and are `Clone` /// (i.e., `Rc<T>`, `Arc<T>`, `&T`, ...). pub trait ResidualDyn { /// Return the number of components in the system. fn components(&self) -> usize; /// Return the maximum density in Angstrom^-3. /// /// This value is used as an estimate for a liquid phase for phase /// equilibria and other iterations. It is not explicitly meant to /// be a mathematical limit for the density (if those exist in the /// equation of state anyways). fn compute_max_density<D: DualNum<f64> + Copy>(&self, molefracs: &DVector<D>) -> D; /// Evaluate the reduced Helmholtz energy density of each individual contribution /// and return them together with a string representation of the contribution. fn reduced_helmholtz_energy_density_contributions<D: DualNum<f64> + Copy>( &self, state: &StateHD<D>, ) -> Vec<(&'static str, D)>; } impl<C: Deref<Target = T> + Clone, T: ResidualDyn, D: DualNum<f64> + Copy> Residual<Dyn, D> for C { type Real = Self; type Lifted<D2: DualNum<f64, Inner = D> + Copy> = Self; fn re(&self) -> Self::Real { self.clone() } fn lift<D2: DualNum<f64, Inner = D> + Copy>(&self) -> Self::Lifted<D2> { self.clone() } fn components(&self) -> usize { ResidualDyn::components(self.deref()) } fn compute_max_density(&self, molefracs: &DVector<D>) -> D { ResidualDyn::compute_max_density(self.deref(), molefracs) } fn reduced_helmholtz_energy_density_contributions( &self, state: &StateHD<D, Dyn>, ) -> Vec<(&'static str, D)> { ResidualDyn::reduced_helmholtz_energy_density_contributions(self.deref(), state) } } /// A residual Helmholtz energy model. pub trait Residual<N: Dim = Dyn, D: DualNum<f64> + Copy = f64>: Clone where DefaultAllocator: Allocator<N>, { /// Return the number of components in the system. fn components(&self) -> usize; /// Return a generic composition vector for a pure component. /// /// Panics if N is not Dyn(1) or Const<1>. fn pure_molefracs() -> OVector<D, N> { OVector::from_element_generic(N::from_usize(1), U1, D::one()) } /// The residual model with only the real parts of the model parameters. type Real: Residual<N>; /// The residual model with the model parameters lifted to a higher dual number. type Lifted<D2: DualNum<f64, Inner = D> + Copy>: Residual<N, D2>; /// Return the real part of the residual model. fn re(&self) -> Self::Real; /// Return the lifted residual model. fn lift<D2: DualNum<f64, Inner = D> + Copy>(&self) -> Self::Lifted<D2>; /// Return the maximum density in Angstrom^-3. /// /// This value is used as an estimate for a liquid phase for phase /// equilibria and other iterations. It is not explicitly meant to /// be a mathematical limit for the density (if those exist in the /// equation of state anyways). fn compute_max_density(&self, molefracs: &OVector<D, N>) -> D; /// Evaluate the reduced Helmholtz energy density of each individual contribution /// and return them together with a string representation of the contribution. fn reduced_helmholtz_energy_density_contributions( &self, state: &StateHD<D, N>, ) -> Vec<(&'static str, D)>; /// Evaluate the residual reduced Helmholtz energy density $\beta f^\mathrm{res}$. fn reduced_residual_helmholtz_energy_density(&self, state: &StateHD<D, N>) -> D { self.reduced_helmholtz_energy_density_contributions(state) .iter() .fold(D::zero(), |acc, (_, a)| acc + a) } /// Evaluate the molar Helmholtz energy of each individual contribution /// and return them together with a string representation of the contribution. fn molar_helmholtz_energy_contributions( &self, temperature: D, molar_volume: D, molefracs: &OVector<D, N>, ) -> Vec<(&'static str, D)> { let state = StateHD::new(temperature, molar_volume, molefracs); self.reduced_helmholtz_energy_density_contributions(&state) .into_iter() .map(|(n, f)| (n, f * temperature * molar_volume)) .collect() } /// Evaluate the residual molar Helmholtz energy $a^\mathrm{res}$. fn residual_molar_helmholtz_energy( &self, temperature: D, molar_volume: D, molefracs: &OVector<D, N>, ) -> D { let state = StateHD::new(temperature, molar_volume, molefracs); self.reduced_residual_helmholtz_energy_density(&state) * temperature * molar_volume } /// Evaluate the residual Helmholtz energy $A^\mathrm{res}$. fn residual_helmholtz_energy(&self, temperature: D, volume: D, moles: &OVector<D, N>) -> D { let state = StateHD::new_density(temperature, &(moles / volume)); self.reduced_residual_helmholtz_energy_density(&state) * temperature * volume } /// Evaluate the residual Helmholtz energy $A^\mathrm{res}$. fn residual_helmholtz_energy_unit( &self, temperature: Temperature<D>, volume: Volume<D>, moles: &Moles<OVector<D, N>>, ) -> Energy<D> { let temperature = temperature.into_reduced(); let total_moles = moles.sum(); let molar_volume = (volume / total_moles).into_reduced(); let molefracs = moles / total_moles; let state = StateHD::new(temperature, molar_volume, &molefracs); Pressure::from_reduced(self.reduced_residual_helmholtz_energy_density(&state) * temperature) * volume } /// Check if the provided optional molar concentration is consistent with the /// equation of state. /// /// In general, the number of elements in `molefracs` needs to match the number /// of components of the equation of state. For a pure component, however, /// no molefracs need to be provided. fn validate_molefracs(&self, molefracs: &Option<OVector<D, N>>) -> FeosResult<OVector<D, N>> { let l = molefracs.as_ref().map_or(1, |m| m.len()); if self.components() == l { match molefracs { Some(m) => Ok(m.clone()), None => Ok(OVector::from_element_generic( N::from_usize(1), U1, D::one(), )), } } else { Err(FeosError::IncompatibleComponents(self.components(), l)) } } /// Calculate the maximum density. /// /// This value is used as an estimate for a liquid phase for phase /// equilibria and other iterations. It is not explicitly meant to /// be a mathematical limit for the density (if those exist in the /// equation of state anyways). fn max_density(&self, molefracs: &Option<OVector<D, N>>) -> FeosResult<Density<D>> { let x = self.validate_molefracs(molefracs)?; Ok(Density::from_reduced(self.compute_max_density(&x))) } /// Calculate the second virial coefficient $B(T)$ fn second_virial_coefficient( &self, temperature: Temperature<D>, molefracs: &Option<OVector<D, N>>, ) -> MolarVolume<D> { let x = self.validate_molefracs(molefracs).unwrap(); let (_, _, d2f) = second_derivative( partial2( |rho, &t, x| { let state = StateHD::new_virial(t, rho, x); self.lift() .reduced_residual_helmholtz_energy_density(&state) }, &temperature.into_reduced(), &x, ), D::from(0.0), ); Quantity::from_reduced(d2f * 0.5) } /// Calculate the third virial coefficient $C(T)$ fn third_virial_coefficient( &self, temperature: Temperature<D>, molefracs: &Option<OVector<D, N>>, ) -> Quot<MolarVolume<D>, Density<D>> { let x = self.validate_molefracs(molefracs).unwrap(); let (_, _, _, d3f) = third_derivative( partial2( |rho, &t, x| { let state = StateHD::new_virial(t, rho, x); self.lift() .reduced_residual_helmholtz_energy_density(&state) }, &temperature.into_reduced(), &x, ), D::from(0.0), ); Quantity::from_reduced(d3f / 3.0) } /// Calculate the temperature derivative of the second virial coefficient $B'(T)$ fn second_virial_coefficient_temperature_derivative( &self, temperature: Temperature<D>, molefracs: &Option<OVector<D, N>>, ) -> Quot<MolarVolume<D>, Temperature<D>> { let (_, db_dt) = first_derivative( partial( |t, x| self.lift().second_virial_coefficient(t, x), molefracs, ), temperature, ); db_dt } /// Calculate the temperature derivative of the third virial coefficient $C'(T)$ fn third_virial_coefficient_temperature_derivative( &self, temperature: Temperature<D>, molefracs: &Option<OVector<D, N>>, ) -> Quot<Quot<MolarVolume<D>, Density<D>>, Temperature<D>> { let (_, dc_dt) = first_derivative( partial(|t, x| self.lift().third_virial_coefficient(t, x), molefracs), temperature, ); dc_dt } // The following methods are used in phase equilibrium algorithms /// calculates a_res, p, dp_drho fn p_dpdrho(&self, temperature: D, density: D, molefracs: &OVector<D, N>) -> (D, D, D) { let molar_volume = density.recip(); let (a, da, d2a) = second_derivative( partial2( |molar_volume, &t, x| { self.lift() .residual_molar_helmholtz_energy(t, molar_volume, x) }, &temperature, molefracs, ), molar_volume, ); ( a * density, -da + temperature * density, molar_volume * molar_volume * d2a + temperature, ) } /// calculates p, dp_drho, d2p_drho2 fn p_dpdrho_d2pdrho2( &self, temperature: D, density: D, molefracs: &OVector<D, N>, ) -> (D, D, D) { let molar_volume = density.recip(); let (_, da, d2a, d3a) = third_derivative( partial2( |molar_volume, &t, x| { self.lift() .residual_molar_helmholtz_energy(t, molar_volume, x) }, &temperature, molefracs, ), molar_volume, ); ( -da + temperature * density, molar_volume * molar_volume * d2a + temperature, -molar_volume * molar_volume * molar_volume * (d2a * 2.0 + molar_volume * d3a), ) } /// calculates p, mu_res, dp_drho, dmu_drho #[expect(clippy::type_complexity)] fn dmu_drho( &self, temperature: D, partial_density: &OVector<D, N>, ) -> (D, OVector<D, N>, OVector<D, N>, OMatrix<D, N, N>) where N: Gradients, DefaultAllocator: Allocator<N, N>, { let (f_res, mu_res, dmu_res) = N::hessian( |rho, &t| { let state = StateHD::new_density(t, &rho); self.lift() .reduced_residual_helmholtz_energy_density(&state) * t }, partial_density, &temperature, ); let p = mu_res.dot(partial_density) - f_res + temperature * partial_density.sum(); let dmu = dmu_res + OMatrix::from_diagonal(&partial_density.map(|d| temperature / d)); let dp = &dmu * partial_density; (p, mu_res, dp, dmu) } /// calculates p, mu_res, dp_dv, dmu_dv fn dmu_dv( &self, temperature: D, molar_volume: D, molefracs: &OVector<D, N>, ) -> (D, OVector<D, N>, D, OVector<D, N>) where N: Gradients, { let (_, mu_res, a_res_v, mu_res_v) = N::partial_hessian( |x, v, &t| self.lift().residual_helmholtz_energy(t, v, &x), molefracs, molar_volume, &temperature, ); let p = -a_res_v + temperature / molar_volume; let mu_v = mu_res_v.map(|m| m - temperature / molar_volume); let p_v = mu_v.dot(molefracs) / molar_volume; (p, mu_res, p_v, mu_v) } /// calculates dp_dt, dmu_res_dt fn dmu_dt(&self, temperature: D, partial_density: &OVector<D, N>) -> (D, OVector<D, N>) where N: Gradients, { let (_, _, f_res_t, mu_res_t) = N::partial_hessian( |rho, t, _: &()| { let state = StateHD::new_density(t, &rho); self.lift() .reduced_residual_helmholtz_energy_density(&state) * t }, partial_density, temperature, &(), ); let p_t = -f_res_t + partial_density.dot(&mu_res_t) + partial_density.sum(); (p_t, mu_res_t) } } /// Reference values and residual entropy correlations for entropy scaling. pub trait EntropyScaling<N: Dim = Dyn, D: DualNum<f64> + Copy = f64> where DefaultAllocator: Allocator<N>, { fn viscosity_reference( &self, temperature: Temperature<D>, volume: Volume<D>, moles: &Moles<OVector<D, N>>, ) -> Viscosity<D>; fn viscosity_correlation(&self, s_res: D, x: &OVector<D, N>) -> D; fn diffusion_reference( &self, temperature: Temperature<D>, volume: Volume<D>, moles: &Moles<OVector<D, N>>, ) -> Diffusivity<D>; fn diffusion_correlation(&self, s_res: D, x: &OVector<D, N>) -> D; fn thermal_conductivity_reference( &self, temperature: Temperature<D>, volume: Volume<D>, moles: &Moles<OVector<D, N>>, ) -> ThermalConductivity<D>; fn thermal_conductivity_correlation(&self, s_res: D, x: &OVector<D, N>) -> D; } impl<C: Deref<Target = T>, T: EntropyScaling<N, D>, N: Dim, D: DualNum<f64> + Copy> EntropyScaling<N, D> for C where DefaultAllocator: Allocator<N>, { fn viscosity_reference( &self, temperature: Temperature<D>, volume: Volume<D>, moles: &Moles<OVector<D, N>>, ) -> Viscosity<D> { self.deref().viscosity_reference(temperature, volume, moles) } fn viscosity_correlation(&self, s_res: D, x: &OVector<D, N>) -> D { self.deref().viscosity_correlation(s_res, x) } fn diffusion_reference( &self, temperature: Temperature<D>, volume: Volume<D>, moles: &Moles<OVector<D, N>>, ) -> Diffusivity<D> { self.deref().diffusion_reference(temperature, volume, moles) } fn diffusion_correlation(&self, s_res: D, x: &OVector<D, N>) -> D { self.deref().diffusion_correlation(s_res, x) } fn thermal_conductivity_reference( &self, temperature: Temperature<D>, volume: Volume<D>, moles: &Moles<OVector<D, N>>, ) -> ThermalConductivity<D> { self.deref() .thermal_conductivity_reference(temperature, volume, moles) } fn thermal_conductivity_correlation(&self, s_res: D, x: &OVector<D, N>) -> D { self.deref().thermal_conductivity_correlation(s_res, x) } } /// Dummy implementation for [EquationOfState](super::EquationOfState)s that only contain an ideal gas contribution. pub struct NoResidual(pub usize); impl Subset for NoResidual { fn subset(&self, component_list: &[usize]) -> Self { Self(component_list.len()) } } impl ResidualDyn for NoResidual { fn components(&self) -> usize { self.0 } fn compute_max_density<D: DualNum<f64> + Copy>(&self, _: &DVector<D>) -> D { D::one() } fn reduced_helmholtz_energy_density_contributions<D: DualNum<f64> + Copy>( &self, _: &StateHD<D>, ) -> Vec<(&'static str, D)> { vec![] } }
Rust
3D
feos-org/feos
crates/feos-core/src/parameter/model_record.rs
.rs
10,964
345
use super::{AssociationRecord, BinaryAssociationRecord, Identifier, IdentifierOption}; use crate::FeosResult; use crate::errors::FeosError; use indexmap::IndexSet; use num_traits::Zero; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; use std::fmt; use std::fs::File; use std::io::BufReader; use std::ops::Deref; use std::path::Path; /// A collection of parameters with an arbitrary identifier. #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Record<I, M, A> { pub identifier: I, #[serde(skip_serializing_if = "f64::is_zero")] #[serde(default)] pub molarweight: f64, #[serde(flatten)] pub model_record: M, #[serde(skip_serializing_if = "Vec::is_empty")] #[serde(default = "Vec::new")] pub association_sites: Vec<AssociationRecord<A>>, } /// A collection of parameters of a pure substance. pub type PureRecord<M, A> = Record<Identifier, M, A>; /// Parameters describing an individual segment of a molecule. pub type SegmentRecord<M, A> = Record<String, M, A>; impl<I, M, A> Record<I, M, A> { /// Create a new `ModelRecord`. pub fn new(identifier: I, molarweight: f64, model_record: M) -> Self { Self::with_association(identifier, molarweight, model_record, vec![]) } /// Create a new `ModelRecord` including association information. pub fn with_association( identifier: I, molarweight: f64, model_record: M, association_sites: Vec<AssociationRecord<A>>, ) -> Self { Self { identifier, molarweight, model_record, association_sites, } } /// Update the `PureRecord` from segment counts. /// /// The [FromSegments] trait needs to be implemented for the model record. pub fn from_segments<S>(identifier: I, segments: S) -> FeosResult<Self> where M: FromSegments, S: IntoIterator<Item = (SegmentRecord<M, A>, f64)>, { let mut molarweight = 0.0; let mut model_segments = Vec::new(); let association_sites = segments .into_iter() .flat_map(|(s, n)| { molarweight += s.molarweight * n; model_segments.push((s.model_record, n)); s.association_sites.into_iter().map(move |record| { AssociationRecord::with_id( record.id, record.parameters, record.na * n, record.nb * n, record.nc * n, ) }) }) .collect(); let model_record = M::from_segments(&model_segments)?; Ok(Self::with_association( identifier, molarweight, model_record, association_sites, )) } } impl<M, A> PureRecord<M, A> { /// Create pure substance parameters from a json file. pub fn from_json<P, S>( substances: &[S], file: P, identifier_option: IdentifierOption, ) -> FeosResult<Vec<Self>> where P: AsRef<Path>, S: Deref<Target = str>, M: DeserializeOwned, A: DeserializeOwned, { // create list of substances let mut queried: HashSet<&str> = substances.iter().map(|s| s.deref()).collect(); // raise error on duplicate detection if queried.len() != substances.len() { return Err(FeosError::IncompatibleParameters( "A substance was defined more than once.".to_string(), )); } let f = File::open(file)?; let reader = BufReader::new(f); // use stream in the future let file_records: Vec<Self> = serde_json::from_reader(reader)?; let mut records: HashMap<&str, Self> = HashMap::with_capacity(substances.len()); // build map, draining list of queried substances in the process for record in file_records { if let Some(id) = record.identifier.as_str(identifier_option) { queried.take(id).map(|id| records.insert(id, record)); } // all parameters parsed if queried.is_empty() { break; } } // report missing parameters if !queried.is_empty() { return Err(FeosError::ComponentsNotFound(format!("{queried:?}"))); }; // collect into vec in correct order Ok(substances .iter() .map(|s| records.remove(s.deref()).unwrap()) .collect()) } /// Creates parameters from substance information stored in multiple json files. pub fn from_multiple_json<P, S>( input: &[(Vec<S>, P)], identifier_option: IdentifierOption, ) -> FeosResult<Vec<Self>> where P: AsRef<Path>, S: Deref<Target = str>, M: DeserializeOwned, A: DeserializeOwned, { // total number of substances queried let nsubstances = input .iter() .fold(0, |acc, (substances, _)| acc + substances.len()); // queried substances with removed duplicates let queried: IndexSet<String> = input .iter() .flat_map(|(substances, _)| substances) .map(|substance| substance.to_string()) .collect(); // check if there are duplicates if queried.len() != nsubstances { return Err(FeosError::IncompatibleParameters( "A substance was defined more than once.".to_string(), )); } let mut records: Vec<Self> = Vec::with_capacity(nsubstances); // collect parameters from files into single map for (substances, file) in input { records.extend(Self::from_json(substances, file, identifier_option)?); } Ok(records) } } impl<M, A> SegmentRecord<M, A> { /// Read a list of `SegmentRecord`s from a JSON file. pub fn from_json<P: AsRef<Path>>(file: P) -> FeosResult<Vec<Self>> where M: DeserializeOwned, A: DeserializeOwned, { Ok(serde_json::from_reader(BufReader::new(File::open(file)?))?) } } impl<M: Serialize, A: Serialize> fmt::Display for PureRecord<M, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s = serde_json::to_string(self).unwrap().replace("\"", ""); let s = s.replace(",", ", ").replace(":", ": "); write!(f, "PureRecord({})", &s[1..s.len() - 1]) } } impl<M: Serialize, A: Serialize> fmt::Display for SegmentRecord<M, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s = serde_json::to_string(self).unwrap().replace("\"", ""); let s = s.replace(",", ", ").replace(":", ": "); write!(f, "SegmentRecord({})", &s[1..s.len() - 1]) } } /// Trait for models that implement a homosegmented group contribution /// method pub trait FromSegments: Clone { /// Constructs the record from a list of segment records with their /// number of occurences. fn from_segments(segments: &[(Self, f64)]) -> FeosResult<Self>; } /// Trait for models that implement a homosegmented group contribution /// method and have a combining rule for binary interaction parameters. pub trait FromSegmentsBinary: Clone { /// Constructs the binary record from a list of segment records with /// their number of occurences. fn from_segments_binary(segments: &[(Self, f64, f64)]) -> FeosResult<Self>; } impl FromSegmentsBinary for () { fn from_segments_binary(_: &[(Self, f64, f64)]) -> FeosResult<Self> { Ok(()) } } /// A collection of parameters that model interactions between two substances. #[derive(Serialize, Deserialize, Clone, Debug)] pub struct BinaryRecord<I, B, A> { /// Identifier of the first component pub id1: I, /// Identifier of the second component pub id2: I, /// Binary interaction parameter(s) #[serde(flatten)] pub model_record: Option<B>, /// Binary association records #[serde(skip_serializing_if = "Vec::is_empty")] #[serde(default = "Vec::new")] pub association_sites: Vec<BinaryAssociationRecord<A>>, } /// A collection of parameters that model interactions between two segments. pub type BinarySegmentRecord<M, A> = BinaryRecord<String, M, A>; impl<I, B, A> BinaryRecord<I, B, A> { /// Crates a new `BinaryRecord`. pub fn new(id1: I, id2: I, model_record: Option<B>) -> Self { Self::with_association(id1, id2, model_record, vec![]) } /// Crates a new `BinaryRecord` including association sites. pub fn with_association( id1: I, id2: I, model_record: Option<B>, association_sites: Vec<BinaryAssociationRecord<A>>, ) -> Self { Self { id1, id2, model_record, association_sites, } } /// Read a list of `BinaryRecord`s from a JSON file. pub fn from_json<P: AsRef<Path>>(file: P) -> FeosResult<Vec<Self>> where I: DeserializeOwned, B: DeserializeOwned, A: DeserializeOwned, { Ok(serde_json::from_reader(BufReader::new(File::open(file)?))?) } } impl<I: Serialize + Clone, B: Serialize + Clone, A: Serialize + Clone> fmt::Display for BinaryRecord<I, B, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s = serde_json::to_string(self).unwrap().replace("\"", ""); let s = s.replace(",", ", ").replace(":", ": "); write!(f, "BinaryRecord({})", &s[1..s.len() - 1]) } } #[cfg(test)] mod test { use super::*; #[derive(Serialize, Deserialize, Debug, Default, Clone)] struct TestModelRecordSegments { a: f64, } #[test] fn deserialize() { let r = r#" { "identifier": { "cas": "123-4-5" }, "molarweight": 16.0426, "a": 0.1 } "#; let record: PureRecord<TestModelRecordSegments, ()> = serde_json::from_str(r).expect("Unable to parse json."); assert_eq!(record.identifier.cas, Some("123-4-5".into())) } #[test] fn deserialize_list() { let r = r#" [ { "identifier": { "cas": "1" }, "molarweight": 1.0, "a": 1.0 }, { "identifier": { "cas": "2" }, "molarweight": 2.0, "a": 2.0 } ]"#; let records: Vec<PureRecord<TestModelRecordSegments, ()>> = serde_json::from_str(r).expect("Unable to parse json."); assert_eq!(records[0].identifier.cas, Some("1".into())); assert_eq!(records[1].identifier.cas, Some("2".into())) } }
Rust
3D
feos-org/feos
crates/feos-core/src/parameter/mod.rs
.rs
33,221
950
//! Structures and traits that can be used to build model parameters for equations of state. use crate::errors::*; use indexmap::{IndexMap, IndexSet}; use itertools::Itertools; use nalgebra::{DMatrix, DVector, Scalar}; use quantity::{GRAM, MOL, MolarWeight}; use serde::Serialize; use serde::de::DeserializeOwned; use std::array; use std::collections::HashMap; use std::fs::File; use std::io::BufReader; use std::ops::Deref; use std::path::Path; mod association; mod chemical_record; mod identifier; mod model_record; pub use association::{ AssociationParameters, AssociationRecord, AssociationSite, BinaryAssociationRecord, CombiningRule, }; pub use chemical_record::{ChemicalRecord, GroupCount}; pub use identifier::{Identifier, IdentifierOption}; pub use model_record::{ BinaryRecord, BinarySegmentRecord, FromSegments, FromSegmentsBinary, PureRecord, Record, SegmentRecord, }; #[derive(Clone)] pub struct PureParameters<M, C> { pub identifier: String, pub model_record: M, pub count: C, pub component_index: usize, } impl<M: Clone> PureParameters<M, ()> { fn from_pure_record(model_record: M, component_index: usize) -> Self { Self { identifier: "".into(), model_record, count: (), component_index, } } } impl<M: Clone, C> PureParameters<M, C> { fn from_segment_record<A>( segment: &SegmentRecord<M, A>, count: C, component_index: usize, ) -> Self { Self { identifier: segment.identifier.clone(), model_record: segment.model_record.clone(), count, component_index, } } } #[derive(Clone, Copy)] pub struct BinaryParameters<B, C> { pub id1: usize, pub id2: usize, pub model_record: B, pub count: C, } impl<B, C> BinaryParameters<B, C> { pub fn new(id1: usize, id2: usize, model_record: B, count: C) -> Self { Self { id1, id2, model_record, count, } } } pub struct GenericParameters<P, B, A, Bo, C, Data> { pub pure: Vec<PureParameters<P, C>>, pub binary: Vec<BinaryParameters<B, ()>>, pub bonds: Vec<BinaryParameters<Bo, C>>, pub association: AssociationParameters<A>, pub molar_weight: MolarWeight<DVector<f64>>, data: Data, } pub type Parameters<P, B, A> = GenericParameters<P, B, A, (), (), (Vec<PureRecord<P, A>>, Vec<BinaryRecord<usize, B, A>>)>; pub type GcParameters<P, B, A, Bo, C> = GenericParameters< P, B, A, Bo, C, ( Vec<ChemicalRecord>, Vec<SegmentRecord<P, A>>, Option<Vec<BinarySegmentRecord<B, A>>>, Vec<BinarySegmentRecord<Bo, ()>>, ), >; pub type IdealGasParameters<I> = Parameters<I, (), ()>; impl<P, B, A, Bo, C, Data> GenericParameters<P, B, A, Bo, C, Data> { pub fn collate<F, T: Scalar + Copy, const N: usize>(&self, f: F) -> [DVector<T>; N] where F: Fn(&P) -> [T; N], { array::from_fn(|i| { DVector::from_vec(self.pure.iter().map(|pr| f(&pr.model_record)[i]).collect()) }) } pub fn collate_binary<F, T: Scalar + Default + Copy, const N: usize>( &self, f: F, ) -> [DMatrix<T>; N] where F: Fn(&B) -> [T; N], { array::from_fn(|i| { let mut b_mat = DMatrix::from_element(self.pure.len(), self.pure.len(), T::default()); for br in &self.binary { let b = f(&br.model_record)[i]; b_mat[(br.id1, br.id2)] = b; b_mat[(br.id2, br.id1)] = b; } b_mat }) } pub fn collate_ab<F, T: Scalar + Copy, const N: usize>(&self, f: F) -> [DMatrix<Option<T>>; N] where F: Fn(&A) -> [T; N], { let a = &self.association; array::from_fn(|i| { let mut b_mat = DMatrix::from_element(a.sites_a.len(), a.sites_b.len(), None); for br in &a.binary_ab { b_mat[(br.id1, br.id2)] = Some(f(&br.model_record)[i]); } b_mat }) } pub fn collate_cc<F, T: Scalar + Copy, const N: usize>(&self, f: F) -> [DMatrix<Option<T>>; N] where F: Fn(&A) -> [T; N], { let a = &self.association; array::from_fn(|i| { let mut b_mat = DMatrix::from_element(a.sites_c.len(), a.sites_c.len(), None); for br in &a.binary_cc { b_mat[(br.id1, br.id2)] = Some(f(&br.model_record)[i]); } b_mat }) } } impl<P: Clone, B: Clone, A: CombiningRule<P> + Clone> Parameters<P, B, A> { pub fn new( pure_records: Vec<PureRecord<P, A>>, binary_records: Vec<BinaryRecord<usize, B, A>>, ) -> FeosResult<Self> { let association_parameters = AssociationParameters::new(&pure_records, &binary_records)?; let (molar_weight, pure) = pure_records .iter() .enumerate() .map(|(i, pr)| { ( pr.molarweight, PureParameters::from_pure_record(pr.model_record.clone(), i), ) }) .unzip(); let binary = binary_records .iter() .filter_map(|br| { br.model_record .clone() .map(|m| BinaryParameters::new(br.id1, br.id2, m, ())) }) .collect(); Ok(Self { pure, binary, bonds: vec![], association: association_parameters, molar_weight: DVector::from_vec(molar_weight) * (GRAM / MOL), data: (pure_records, binary_records), }) } /// Creates parameters for a pure component from a pure record. pub fn new_pure(pure_record: PureRecord<P, A>) -> FeosResult<Self> { Self::new(vec![pure_record], vec![]) } /// Creates parameters for a binary system from pure records and an optional /// binary interaction parameter. pub fn new_binary( pure_records: [PureRecord<P, A>; 2], binary_record: Option<B>, binary_association_records: Vec<BinaryAssociationRecord<A>>, ) -> FeosResult<Self> { let binary_record = vec![BinaryRecord::with_association( 0, 1, binary_record, binary_association_records, )]; Self::new(pure_records.to_vec(), binary_record) } /// Creates parameters from records for pure substances and possibly binary parameters. pub fn from_records( pure_records: Vec<PureRecord<P, A>>, binary_records: Vec<BinaryRecord<Identifier, B, A>>, identifier_option: IdentifierOption, ) -> FeosResult<Self> { let binary_records = Self::binary_matrix_from_records(&pure_records, &binary_records, identifier_option)?; Self::new(pure_records, binary_records) } /// Creates parameters from model records with default values for the molar weight, /// identifiers, association sites, and binary interaction parameters. pub fn from_model_records(model_records: Vec<P>) -> FeosResult<Self> { let pure_records = model_records .into_iter() .map(|r| PureRecord::new(Default::default(), Default::default(), r)) .collect(); Self::new(pure_records, vec![]) } } impl<P: Clone, B: Clone, A: Clone> Parameters<P, B, A> { /// Helper function to build matrix from list of records in correct order. pub fn binary_matrix_from_records( pure_records: &[PureRecord<P, A>], binary_records: &[BinaryRecord<Identifier, B, A>], identifier_option: IdentifierOption, ) -> FeosResult<Vec<BinaryRecord<usize, B, A>>> { // Build Hashmap (id, id) -> BinaryRecord let binary_map: HashMap<_, _> = { binary_records .iter() .filter_map(|br| { let id1 = br.id1.as_str(identifier_option); let id2 = br.id2.as_str(identifier_option); id1.and_then(|id1| { id2.map(|id2| ((id1, id2), (&br.model_record, &br.association_sites))) }) }) .collect() }; // look up pure records in Hashmap pure_records .iter() .enumerate() .array_combinations() .chain( // Somehow there is no array_combinations_with_replacement in itertools // ii combinations are not intuitive here, but potentially needed for // molecules with multiple association sites. pure_records .iter() .enumerate() .map(|(i, p)| [(i, p), (i, p)]), ) .map(|[(i1, p1), (i2, p2)]| { let Some(id1) = p1.identifier.as_str(identifier_option) else { return Err(FeosError::MissingParameters(format!( "No {} for pure record {} ({}).", identifier_option, i1, p1.identifier ))); }; let Some(id2) = p2.identifier.as_str(identifier_option) else { return Err(FeosError::MissingParameters(format!( "No {} for pure record {} ({}).", identifier_option, i2, p2.identifier ))); }; Ok([(i1, id1), (i2, id2)]) }) .filter_map(|x| { x.map(|[(i1, id1), (i2, id2)]| { let records = if let Some(&(b, a)) = binary_map.get(&(id1, id2)) { Some((b, a.clone())) } else if let Some(&(b, a)) = binary_map.get(&(id2, id1)) { let a = a .iter() .cloned() .map(|a| BinaryAssociationRecord::with_id(a.id2, a.id1, a.parameters)) .collect(); Some((b, a)) } else { None }; records.map(|(b, a)| BinaryRecord::with_association(i1, i2, b.clone(), a)) }) .transpose() }) .collect() } } impl<P: Clone, B: Clone, A: CombiningRule<P> + Clone> Parameters<P, B, A> { /// Creates parameters from substance information stored in json files. pub fn from_json<F, S>( substances: Vec<S>, file_pure: F, file_binary: Option<F>, identifier_option: IdentifierOption, ) -> FeosResult<Self> where F: AsRef<Path>, S: Deref<Target = str>, P: DeserializeOwned, B: DeserializeOwned, A: DeserializeOwned, { Self::from_multiple_json(&[(substances, file_pure)], file_binary, identifier_option) } /// Creates parameters from substance information stored in multiple json files. pub fn from_multiple_json<F, S>( input: &[(Vec<S>, F)], file_binary: Option<F>, identifier_option: IdentifierOption, ) -> FeosResult<Self> where F: AsRef<Path>, S: Deref<Target = str>, P: DeserializeOwned, B: DeserializeOwned, A: DeserializeOwned, { let records = PureRecord::from_multiple_json(input, identifier_option)?; let binary_records = if let Some(path) = file_binary { let file = File::open(path)?; let reader = BufReader::new(file); serde_json::from_reader(reader)? } else { Vec::new() }; Self::from_records(records, binary_records, identifier_option) } /// Creates parameters from the molecular structure and segment information. /// /// The [FromSegments] trait needs to be implemented for the model record /// and the binary interaction parameters. pub fn from_segments( chemical_records: Vec<ChemicalRecord>, segment_records: &[SegmentRecord<P, A>], binary_segment_records: Option<&[BinarySegmentRecord<B, A>]>, ) -> FeosResult<Self> where P: FromSegments, B: FromSegmentsBinary + Default, { let segment_map: HashMap<_, _> = segment_records.iter().map(|s| (&s.identifier, s)).collect(); // Calculate the pure records from the GC method. let (group_counts, pure_records): (Vec<_>, _) = chemical_records .into_iter() .map(|cr| { let (identifier, group_counts, _) = GroupCount::into_groups(cr); let groups = group_counts .iter() .map(|(s, c)| { segment_map.get(s).map(|&x| (x.clone(), *c)).ok_or_else(|| { FeosError::MissingParameters(format!("No segment record found for {s}")) }) }) .collect::<FeosResult<Vec<_>>>()?; let pure_record = PureRecord::from_segments(identifier, groups)?; Ok::<_, FeosError>((group_counts, pure_record)) }) .collect::<Result<Vec<_>, _>>()? .into_iter() .unzip(); // Map: (id1, id2) -> model_record // empty, if no binary segment records are provided let binary_map: HashMap<_, _> = binary_segment_records .into_iter() .flat_map(|seg| seg.iter()) .filter_map(|br| br.model_record.as_ref().map(|b| ((&br.id1, &br.id2), b))) .collect(); // full matrix of binary records from the gc method. // If a specific segment-segment interaction is not in the binary map, // the default value is used. let binary_records = group_counts .iter() .enumerate() .array_combinations() .map(|[(i, sc1), (j, sc2)]| { let mut vec = Vec::new(); for (id1, n1) in sc1.iter() { for (id2, n2) in sc2.iter() { let binary = binary_map .get(&(id1, id2)) .or_else(|| binary_map.get(&(id2, id1))) .copied() .cloned() .unwrap_or_default(); vec.push((binary, *n1, *n2)); } } B::from_segments_binary(&vec).map(|br| BinaryRecord::new(i, j, Some(br))) }) .collect::<Result<_, _>>()?; Self::new(pure_records, binary_records) } /// Creates parameters from segment information stored in json files. /// /// The [FromSegments] trait needs to be implemented for both the model record /// and the ideal gas record. pub fn from_json_segments<F>( substances: &[&str], file_pure: F, file_segments: F, file_binary: Option<F>, identifier_option: IdentifierOption, ) -> FeosResult<Self> where F: AsRef<Path>, P: FromSegments + DeserializeOwned, B: FromSegmentsBinary + DeserializeOwned + Default, A: DeserializeOwned, { let queried: IndexSet<_> = substances.iter().copied().collect(); let file = File::open(file_pure)?; let reader = BufReader::new(file); let chemical_records: Vec<ChemicalRecord> = serde_json::from_reader(reader)?; let mut record_map: HashMap<_, _> = chemical_records .into_iter() .filter_map(|record| { record .identifier .as_str(identifier_option) .map(|i| i.to_owned()) .map(|i| (i, record)) }) .collect(); // Compare queried components and available components let available: IndexSet<_> = record_map .keys() .map(|identifier| identifier as &str) .collect(); if !queried.is_subset(&available) { let missing: Vec<_> = queried.difference(&available).cloned().collect(); let msg = format!("{missing:?}"); return Err(FeosError::ComponentsNotFound(msg)); }; // collect all pure records that were queried let chemical_records: Vec<_> = queried .into_iter() .filter_map(|identifier| record_map.remove(identifier)) .collect(); // Read segment records let segment_records: Vec<SegmentRecord<P, A>> = SegmentRecord::from_json(file_segments)?; // Read binary records let binary_records = file_binary .map(|file_binary| { let reader = BufReader::new(File::open(file_binary)?); let binary_records: FeosResult<Vec<BinarySegmentRecord<B, A>>> = Ok(serde_json::from_reader(reader)?); binary_records }) .transpose()?; Self::from_segments( chemical_records, &segment_records, binary_records.as_deref(), ) } pub fn identifiers(&self) -> Vec<&Identifier> { self.data.0.iter().map(|pr| &pr.identifier).collect() } /// Return a parameter set containing the subset of components specified in `component_list`. /// /// # Panics /// /// Panics if index in `component_list` is out of bounds pub fn subset(&self, component_list: &[usize]) -> Self { let (pure_records, binary_records) = &self.data; let pure_records = component_list .iter() .map(|&i| pure_records[i].clone()) .collect(); let comp_map: HashMap<_, _> = component_list .iter() .enumerate() .map(|(i, &c)| (c, i)) .collect(); let binary_records = binary_records .iter() .filter_map(|br| { let id1 = comp_map.get(&br.id1); let id2 = comp_map.get(&br.id2); id1.and_then(|&id1| { id2.map(|&id2| BinaryRecord::new(id1, id2, br.model_record.clone())) }) }) .collect(); Self::new(pure_records, binary_records).unwrap() } /// Return scalar pure parameters as map. /// /// This function is not particularly efficient and mostly relevant in situations /// in which the type information is thrown away on purpose (i.e., FFI) pub fn pure_parameters(&self) -> IndexMap<String, DVector<f64>> where P: Serialize, { let na: Vec<_> = self.association.sites_a.iter().map(|s| s.n).collect(); let nb: Vec<_> = self.association.sites_b.iter().map(|s| s.n).collect(); let nc: Vec<_> = self.association.sites_c.iter().map(|s| s.n).collect(); let pars: IndexSet<_> = self .pure .iter() .flat_map(|p| to_map(&p.model_record).into_keys()) .collect(); pars.into_iter() .map(|p| { let [pars] = self.collate(|r| [to_map(r).get(&p).copied().unwrap_or_default()]); (p, pars) }) .chain( na.iter() .any(|&n| n > 0.0) .then(|| ("na".into(), DVector::from(na))), ) .chain( nb.iter() .any(|&n| n > 0.0) .then(|| ("nb".into(), DVector::from(nb))), ) .chain( nc.iter() .any(|&n| n > 0.0) .then(|| ("nc".into(), DVector::from(nc))), ) .collect() } /// Return scalar binary interaction parameters as map. /// /// This function is not particularly efficient and mostly relevant in situations /// in which the type information is thrown away on purpose (i.e., FFI) pub fn binary_parameters(&self) -> IndexMap<String, DMatrix<f64>> where B: Serialize, { let pars: IndexSet<String> = self .binary .iter() .flat_map(|b| to_map(&b.model_record).into_keys()) .collect(); pars.into_iter() .map(|p| { let [pars] = self.collate_binary(|b| [to_map(b)[&p]]); (p, pars) }) .collect() } /// Return scalar association parameters (AB) as map. /// /// This function is not particularly efficient and mostly relevant in situations /// in which the type information is thrown away on purpose (i.e., FFI) pub fn association_parameters_ab(&self) -> IndexMap<String, DMatrix<f64>> where A: Serialize, { let pars: IndexSet<String> = self .association .binary_ab .iter() .flat_map(|a| to_map(&a.model_record).into_keys()) .collect(); pars.into_iter() .map(|p| { let [pars] = self.collate_ab(|a| [to_map(a).get(&p).copied().unwrap_or_default()]); let pars = pars.map(|p| p.unwrap_or(f64::NAN)); (p, pars) }) .collect() } /// Return scalar association parameters (CC) as map. /// /// This function is not particularly efficient and mostly relevant in situations /// in which the type information is thrown away on purpose (i.e., FFI) pub fn association_parameters_cc(&self) -> IndexMap<String, DMatrix<f64>> where A: Serialize, { let pars: IndexSet<String> = self .association .binary_cc .iter() .flat_map(|a| to_map(&a.model_record).into_keys()) .collect(); pars.into_iter() .map(|mut p| { let [pars] = self.collate_cc(|a| [to_map(a)[&p]]); let pars = pars.map(|p| p.unwrap_or(f64::NAN)); if p.ends_with("ab") { let _ = p.split_off(p.len() - 2); } p.push_str("cc"); (p, pars) }) .collect() } } fn to_map<R: Serialize>(record: R) -> IndexMap<String, f64> { serde_json::from_value(serde_json::to_value(&record).unwrap()).unwrap() } impl<P, B, A, Bo> GcParameters<P, B, A, Bo, f64> { pub fn segment_counts(&self) -> DVector<f64> { DVector::from_vec(self.pure.iter().map(|pr| pr.count).collect()) } } impl<P: Clone, B: Clone, A: CombiningRule<P> + Clone, Bo: Clone, C: GroupCount + Default> GcParameters<P, B, A, Bo, C> { pub fn from_segments_hetero( chemical_records: Vec<ChemicalRecord>, segment_records: &[SegmentRecord<P, A>], binary_segment_records: Option<&[BinarySegmentRecord<B, A>]>, ) -> FeosResult<Self> where Bo: Default, { let mut bond_records = Vec::new(); for s1 in segment_records.iter() { for s2 in segment_records.iter() { bond_records.push(BinarySegmentRecord::new( s1.identifier.clone(), s2.identifier.clone(), Some(Bo::default()), )); } } Self::from_segments_with_bonds( chemical_records, segment_records, binary_segment_records, &bond_records, ) } pub fn from_segments_with_bonds( chemical_records: Vec<ChemicalRecord>, segment_records: &[SegmentRecord<P, A>], binary_segment_records: Option<&[BinarySegmentRecord<B, A>]>, bond_records: &[BinarySegmentRecord<Bo, ()>], ) -> FeosResult<Self> { let segment_map: HashMap<_, _> = segment_records.iter().map(|s| (&s.identifier, s)).collect(); let mut bond_records_map = HashMap::new(); for bond_record in bond_records { bond_records_map.insert((&bond_record.id1, &bond_record.id2), bond_record); bond_records_map.insert((&bond_record.id2, &bond_record.id1), bond_record); } let mut groups = Vec::new(); let mut association_sites = Vec::new(); let mut bonds = Vec::new(); let mut molar_weight: DVector<f64> = DVector::zeros(chemical_records.len()); for (i, cr) in chemical_records.iter().enumerate() { let (_, group_counts, bond_counts) = C::into_groups(cr.clone()); let n = groups.len(); for (s, c) in &group_counts { let Some(&segment) = segment_map.get(s) else { return Err(FeosError::MissingParameters(format!( "No segment record found for {s}" ))); }; molar_weight[i] += segment.molarweight * c.into_f64(); groups.push(PureParameters::from_segment_record(segment, *c, i)); association_sites.push(segment.association_sites.clone()); } for ([a, b], c) in bond_counts { let id1 = &group_counts[a].0; let id2 = &group_counts[b].0; let Some(&bond) = bond_records_map.get(&(id1, id2)) else { return Err(FeosError::MissingParameters(format!( "No bond record found for {id1}-{id2}" ))); }; let Some(bond) = bond.model_record.as_ref() else { return Err(FeosError::MissingParameters(format!( "No bond record found for {id1}-{id2}" ))); }; bonds.push(BinaryParameters::new(a + n, b + n, bond.clone(), c)); } } let mut binary_records = Vec::new(); let mut binary_association_records = Vec::new(); if let Some(binary_segment_records) = binary_segment_records { let mut binary_segment_records_map = HashMap::new(); for binary_record in binary_segment_records { binary_segment_records_map .insert((&binary_record.id1, &binary_record.id2), binary_record); binary_segment_records_map .insert((&binary_record.id2, &binary_record.id1), binary_record); } for [(i1, s1), (i2, s2)] in groups.iter().enumerate().array_combinations() { if s1.component_index != s2.component_index { let id1 = &s1.identifier; let id2 = &s2.identifier; if let Some(&br) = binary_segment_records_map.get(&(id1, id2)) { if let Some(br) = &br.model_record { binary_records.push(BinaryParameters::new(i1, i2, br.clone(), ())); } if !br.association_sites.is_empty() { binary_association_records.push(BinaryParameters::new( i1, i2, br.association_sites.clone(), (), )) } } } } } let association_parameters = AssociationParameters::new_hetero( &groups, &association_sites, &binary_association_records, )?; Ok(Self { pure: groups, binary: binary_records, bonds, association: association_parameters, molar_weight: molar_weight * (GRAM / MOL), data: ( chemical_records, segment_records.to_vec(), binary_segment_records.map(|b| b.to_vec()), bond_records.to_vec(), ), }) } /// Creates parameters from segment information stored in json files. /// /// The [FromSegments] trait needs to be implemented for both the model record /// and the ideal gas record. pub fn from_json_segments_hetero<F>( substances: &[&str], file_pure: F, file_segments: F, file_binary: Option<F>, identifier_option: IdentifierOption, ) -> FeosResult<Self> where F: AsRef<Path>, P: DeserializeOwned, B: DeserializeOwned + Default, A: DeserializeOwned, Bo: Default, { let (chemical_records, segment_records, binary_records) = Self::read_json( substances, file_pure, file_segments, file_binary, identifier_option, )?; Self::from_segments_hetero( chemical_records, &segment_records, binary_records.as_deref(), ) } /// Creates parameters from segment information stored in json files. /// /// The [FromSegments] trait needs to be implemented for both the model record /// and the ideal gas record. pub fn from_json_segments_with_bonds<F>( substances: &[&str], file_pure: F, file_segments: F, file_binary: Option<F>, file_bonds: F, identifier_option: IdentifierOption, ) -> FeosResult<Self> where F: AsRef<Path>, P: DeserializeOwned, B: DeserializeOwned + Default, A: DeserializeOwned, Bo: DeserializeOwned, { let (chemical_records, segment_records, binary_records) = Self::read_json( substances, file_pure, file_segments, file_binary, identifier_option, )?; // Read bond records let bond_records: Vec<_> = BinaryRecord::from_json(file_bonds)?; Self::from_segments_with_bonds( chemical_records, &segment_records, binary_records.as_deref(), &bond_records, ) } #[expect(clippy::type_complexity)] fn read_json<F>( substances: &[&str], file_pure: F, file_segments: F, file_binary: Option<F>, identifier_option: IdentifierOption, ) -> FeosResult<( Vec<ChemicalRecord>, Vec<SegmentRecord<P, A>>, Option<Vec<BinarySegmentRecord<B, A>>>, )> where F: AsRef<Path>, P: DeserializeOwned, B: DeserializeOwned + Default, A: DeserializeOwned, { let queried: IndexSet<_> = substances.iter().copied().collect(); let file = File::open(file_pure)?; let reader = BufReader::new(file); let chemical_records: Vec<ChemicalRecord> = serde_json::from_reader(reader)?; let mut record_map: HashMap<_, _> = chemical_records .into_iter() .filter_map(|record| { record .identifier .as_str(identifier_option) .map(|i| i.to_owned()) .map(|i| (i, record)) }) .collect(); // Compare queried components and available components let available: IndexSet<_> = record_map .keys() .map(|identifier| identifier as &str) .collect(); if !queried.is_subset(&available) { let missing: Vec<_> = queried.difference(&available).cloned().collect(); let msg = format!("{missing:?}"); return Err(FeosError::ComponentsNotFound(msg)); }; // collect all pure records that were queried let chemical_records = queried .into_iter() .filter_map(|identifier| record_map.remove(identifier)) .collect(); // Read segment records let segment_records = SegmentRecord::from_json(file_segments)?; // Read binary records let binary_records = file_binary .map(|file_binary| BinaryRecord::from_json(file_binary)) .transpose()?; Ok((chemical_records, segment_records, binary_records)) } pub fn component_index(&self) -> Vec<usize> { self.pure.iter().map(|pr| pr.component_index).collect() } pub fn identifiers(&self) -> Vec<&Identifier> { self.data.0.iter().map(|cr| &cr.identifier).collect() } /// Return a parameter set containing the subset of components specified in `component_list`. /// /// # Panics /// /// Panics if index in `component_list` is out of bounds pub fn subset(&self, component_list: &[usize]) -> Self { let (chemical_records, segment_records, binary_segment_records, bond_records) = &self.data; let chemical_records = component_list .iter() .map(|&i| chemical_records[i].clone()) .collect(); Self::from_segments_with_bonds( chemical_records, segment_records, binary_segment_records.as_deref(), bond_records, ) .unwrap() } }
Rust
3D
feos-org/feos
crates/feos-core/src/parameter/association.rs
.rs
11,068
321
use super::{BinaryParameters, BinaryRecord, GroupCount, PureParameters}; use crate::{FeosResult, parameter::PureRecord}; use nalgebra::DVector; use num_traits::Zero; use serde::{Deserialize, Serialize}; use std::collections::HashMap; /// Pure component association parameters. #[derive(Serialize, Deserialize, Clone, Debug)] pub struct AssociationRecord<A> { #[serde(skip_serializing_if = "String::is_empty")] #[serde(default)] pub id: String, #[serde(flatten)] pub parameters: Option<A>, /// \# of association sites of type A #[serde(skip_serializing_if = "f64::is_zero")] #[serde(default)] pub na: f64, /// \# of association sites of type B #[serde(skip_serializing_if = "f64::is_zero")] #[serde(default)] pub nb: f64, /// \# of association sites of type C #[serde(skip_serializing_if = "f64::is_zero")] #[serde(default)] pub nc: f64, } impl<A> AssociationRecord<A> { pub fn new(parameters: Option<A>, na: f64, nb: f64, nc: f64) -> Self { Self::with_id(Default::default(), parameters, na, nb, nc) } pub fn with_id(id: String, parameters: Option<A>, na: f64, nb: f64, nc: f64) -> Self { Self { id, parameters, na, nb, nc, } } } /// Binary association parameters. #[derive(Serialize, Deserialize, Clone, Debug)] pub struct BinaryAssociationRecord<A> { // Identifier of the association site on the first molecule. #[serde(skip_serializing_if = "String::is_empty")] #[serde(default)] pub id1: String, // Identifier of the association site on the second molecule. #[serde(skip_serializing_if = "String::is_empty")] #[serde(default)] pub id2: String, // Binary association parameters #[serde(flatten)] pub parameters: A, } impl<A> BinaryAssociationRecord<A> { pub fn new(parameters: A) -> Self { Self::with_id(Default::default(), Default::default(), parameters) } pub fn with_id(id1: String, id2: String, parameters: A) -> Self { Self { id1, id2, parameters, } } } #[derive(Clone, Debug)] pub struct AssociationSite { pub assoc_comp: usize, pub id: String, pub n: f64, } impl AssociationSite { fn new(assoc_comp: usize, id: String, n: f64) -> Self { Self { assoc_comp, id, n } } } pub trait CombiningRule<P> { fn combining_rule(comp_i: &P, comp_j: &P, parameters_i: &Self, parameters_j: &Self) -> Self; } impl<P> CombiningRule<P> for () { fn combining_rule(_: &P, _: &P, _: &Self, _: &Self) {} } /// Parameter set required for the SAFT association Helmoltz energy /// contribution and functional. #[derive(Clone)] pub struct AssociationParameters<A> { pub component_index: DVector<usize>, pub sites_a: Vec<AssociationSite>, pub sites_b: Vec<AssociationSite>, pub sites_c: Vec<AssociationSite>, pub binary_ab: Vec<BinaryParameters<A, ()>>, pub binary_cc: Vec<BinaryParameters<A, ()>>, } impl<A: Clone> AssociationParameters<A> { pub fn new<P, B>( pure_records: &[PureRecord<P, A>], binary_records: &[BinaryRecord<usize, B, A>], ) -> FeosResult<Self> where A: CombiningRule<P>, { let mut sites_a = Vec::new(); let mut sites_b = Vec::new(); let mut sites_c = Vec::new(); let mut pars_a = Vec::new(); let mut pars_b = Vec::new(); let mut pars_c = Vec::new(); for (i, record) in pure_records.iter().enumerate() { for site in record.association_sites.iter() { if site.na > 0.0 { sites_a.push(AssociationSite::new(i, site.id.clone(), site.na)); pars_a.push(&site.parameters); } if site.nb > 0.0 { sites_b.push(AssociationSite::new(i, site.id.clone(), site.nb)); pars_b.push(&site.parameters); } if site.nc > 0.0 { sites_c.push(AssociationSite::new(i, site.id.clone(), site.nc)); pars_c.push(&site.parameters); } } } let record_map: HashMap<_, _> = binary_records .iter() .flat_map(|br| { br.association_sites.iter().flat_map(|a| { [ ((br.id1, br.id2, &a.id1, &a.id2), &a.parameters), ((br.id2, br.id1, &a.id2, &a.id1), &a.parameters), ] }) }) .collect(); let mut binary_ab = Vec::new(); for ((a, site_a), pa) in sites_a.iter().enumerate().zip(&pars_a) { for ((b, site_b), pb) in sites_b.iter().enumerate().zip(&pars_b) { if let Some(&record) = record_map.get(&(site_a.assoc_comp, site_b.assoc_comp, &site_a.id, &site_b.id)) { binary_ab.push(BinaryParameters::new(a, b, record.clone(), ())); } else if let (Some(pa), Some(pb)) = (pa, pb) { binary_ab.push(BinaryParameters::new( a, b, A::combining_rule( &pure_records[site_a.assoc_comp].model_record, &pure_records[site_b.assoc_comp].model_record, pa, pb, ), (), )); } } } let mut binary_cc = Vec::new(); for ((a, site_a), pa) in sites_c.iter().enumerate().zip(&pars_c) { for ((b, site_b), pb) in sites_c.iter().enumerate().zip(&pars_c) { if let Some(&record) = record_map.get(&(site_a.assoc_comp, site_b.assoc_comp, &site_a.id, &site_b.id)) { binary_cc.push(BinaryParameters::new(a, b, record.clone(), ())); } else if let (Some(pa), Some(pb)) = (pa, pb) { binary_cc.push(BinaryParameters::new( a, b, A::combining_rule( &pure_records[site_a.assoc_comp].model_record, &pure_records[site_b.assoc_comp].model_record, pa, pb, ), (), )); } } } let component_index = DVector::from_vec((0..pure_records.len()).collect()); Ok(Self { component_index, sites_a, sites_b, sites_c, binary_ab, binary_cc, }) } pub fn new_hetero<P, C: GroupCount>( groups: &[PureParameters<P, C>], association_sites: &[Vec<AssociationRecord<A>>], binary_records: &[BinaryParameters<Vec<BinaryAssociationRecord<A>>, ()>], ) -> FeosResult<Self> where A: CombiningRule<P>, { let mut sites_a = Vec::new(); let mut sites_b = Vec::new(); let mut sites_c = Vec::new(); let mut pars_a = Vec::new(); let mut pars_b = Vec::new(); let mut pars_c = Vec::new(); for (i, (record, sites)) in groups.iter().zip(association_sites).enumerate() { for site in sites.iter() { if site.na > 0.0 { let na = site.na * record.count.into_f64(); sites_a.push(AssociationSite::new(i, site.id.clone(), na)); pars_a.push(&site.parameters) } if site.nb > 0.0 { let nb = site.nb * record.count.into_f64(); sites_b.push(AssociationSite::new(i, site.id.clone(), nb)); pars_b.push(&site.parameters) } if site.nc > 0.0 { let nc = site.nc * record.count.into_f64(); sites_c.push(AssociationSite::new(i, site.id.clone(), nc)); pars_c.push(&site.parameters) } } } let record_map: HashMap<_, _> = binary_records .iter() .flat_map(|br| { br.model_record.iter().flat_map(|a| { [ ((br.id1, br.id2, &a.id1, &a.id2), &a.parameters), ((br.id2, br.id1, &a.id2, &a.id1), &a.parameters), ] }) }) .collect(); let mut binary_ab = Vec::new(); for ((a, site_a), pa) in sites_a.iter().enumerate().zip(&pars_a) { for ((b, site_b), pb) in sites_b.iter().enumerate().zip(&pars_b) { if let Some(&record) = record_map.get(&(site_a.assoc_comp, site_b.assoc_comp, &site_a.id, &site_b.id)) { binary_ab.push(BinaryParameters::new(a, b, record.clone(), ())); } else if let (Some(pa), Some(pb)) = (pa, pb) { binary_ab.push(BinaryParameters::new( a, b, A::combining_rule( &groups[site_a.assoc_comp].model_record, &groups[site_b.assoc_comp].model_record, pa, pb, ), (), )); } } } let mut binary_cc = Vec::new(); for ((a, site_a), pa) in sites_c.iter().enumerate().zip(&pars_c) { for ((b, site_b), pb) in sites_c.iter().enumerate().zip(&pars_c) { if let Some(&record) = record_map.get(&(site_a.assoc_comp, site_b.assoc_comp, &site_a.id, &site_b.id)) { binary_cc.push(BinaryParameters::new(a, b, record.clone(), ())); } else if let (Some(pa), Some(pb)) = (pa, pb) { binary_cc.push(BinaryParameters::new( a, b, A::combining_rule( &groups[site_a.assoc_comp].model_record, &groups[site_b.assoc_comp].model_record, pa, pb, ), (), )); } } } let component_index = DVector::from_vec(groups.iter().map(|pr| pr.component_index).collect()); Ok(Self { component_index, sites_a, sites_b, sites_c, binary_ab, binary_cc, }) } pub fn is_empty(&self) -> bool { (self.sites_a.is_empty() | self.sites_b.is_empty()) & self.sites_c.is_empty() } }
Rust
3D
feos-org/feos
crates/feos-core/src/parameter/chemical_record.rs
.rs
5,911
190
use super::{Identifier, IdentifierOption}; use crate::{FeosError, FeosResult}; use indexmap::IndexMap; use itertools::Itertools; use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; use std::fs::File; use std::io::BufReader; use std::ops::Deref; use std::path::Path; // Auxiliary structure used to deserialize chemical records without explicit bond information. #[derive(Serialize, Deserialize)] struct ChemicalRecordJSON { identifier: Identifier, segments: Vec<String>, bonds: Option<Vec<[usize; 2]>>, } /// Chemical information of a substance. #[derive(Deserialize, Serialize, Debug, Clone)] #[serde(from = "ChemicalRecordJSON")] #[serde(into = "ChemicalRecordJSON")] pub struct ChemicalRecord { pub identifier: Identifier, pub segments: Vec<String>, pub bonds: Vec<[usize; 2]>, } impl From<ChemicalRecordJSON> for ChemicalRecord { fn from(record: ChemicalRecordJSON) -> Self { Self::new(record.identifier, record.segments, record.bonds) } } impl From<ChemicalRecord> for ChemicalRecordJSON { fn from(record: ChemicalRecord) -> Self { Self { identifier: record.identifier, segments: record.segments, bonds: Some(record.bonds), } } } impl ChemicalRecord { /// Create a new `ChemicalRecord`. /// /// If no bonds are given, the molecule is assumed to be linear. pub fn new( identifier: Identifier, segments: Vec<String>, bonds: Option<Vec<[usize; 2]>>, ) -> ChemicalRecord { let bonds = bonds.unwrap_or_else(|| { (0..segments.len() - 1) .zip(1..segments.len()) .map(|x| [x.0, x.1]) .collect() }); Self { identifier, segments, bonds, } } /// Create chemical records from a json file. pub fn from_json<P, S>( substances: &[S], file: P, identifier_option: IdentifierOption, ) -> FeosResult<Vec<Self>> where P: AsRef<Path>, S: Deref<Target = str>, { // create list of substances let mut queried: HashSet<&str> = substances.iter().map(|s| s.deref()).collect(); // raise error on duplicate detection if queried.len() != substances.len() { return Err(FeosError::IncompatibleParameters( "A substance was defined more than once.".to_string(), )); } let f = File::open(file)?; let reader = BufReader::new(f); // use stream in the future let file_records: Vec<Self> = serde_json::from_reader(reader)?; let mut records: HashMap<&str, Self> = HashMap::with_capacity(substances.len()); // build map, draining list of queried substances in the process for record in file_records { if let Some(id) = record.identifier.as_str(identifier_option) { queried.take(id).map(|id| records.insert(id, record)); } // all parameters parsed if queried.is_empty() { break; } } // report missing parameters if !queried.is_empty() { return Err(FeosError::ComponentsNotFound(format!("{queried:?}"))); }; // collect into vec in correct order Ok(substances .iter() .map(|s| records.remove(s.deref()).unwrap()) .collect()) } } impl std::fmt::Display for ChemicalRecord { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "ChemicalRecord(")?; write!(f, "\n\tidentifier={},", self.identifier)?; write!(f, "\n\tsegments={:?},", self.segments)?; write!(f, "\n\tbonds={:?}\n)", self.bonds) } } pub trait GroupCount: Copy { #[expect(clippy::type_complexity)] fn into_groups( chemical_record: ChemicalRecord, ) -> (Identifier, Vec<(String, Self)>, Vec<([usize; 2], Self)>); fn into_f64(self) -> f64; } impl GroupCount for f64 { fn into_groups( chemical_record: ChemicalRecord, ) -> (Identifier, Vec<(String, f64)>, Vec<([usize; 2], f64)>) { let mut group_counts = IndexMap::with_capacity(chemical_record.segments.len()); let segment_to_group: Vec<_> = chemical_record .segments .into_iter() .map(|si| { let entry = group_counts.entry(si); let index = entry.index(); *entry.or_insert(0.0) += 1.0; index }) .collect(); let mut bond_counts: IndexMap<_, _> = (0..group_counts.len()) .array_combinations() .chain((0..group_counts.len()).map(|i| [i, i])) .map(|g| (g, 0.0)) .collect(); for [i, j] in chemical_record.bonds { let [s1, s2] = [segment_to_group[i], segment_to_group[j]]; bond_counts.entry([s1, s2]).and_modify(|x| *x += 1.0); if s1 != s2 { bond_counts.entry([s2, s1]).and_modify(|x| *x += 1.0); } } let group_counts = group_counts.into_iter().collect(); let bond_counts = bond_counts.into_iter().filter(|(_, c)| *c > 0.0).collect(); (chemical_record.identifier, group_counts, bond_counts) } fn into_f64(self) -> f64 { self } } impl GroupCount for () { fn into_groups( chemical_record: ChemicalRecord, ) -> (Identifier, Vec<(String, ())>, Vec<([usize; 2], ())>) { let segments = chemical_record .segments .into_iter() .map(|s| (s, ())) .collect(); let bonds = chemical_record.bonds.into_iter().map(|b| (b, ())).collect(); (chemical_record.identifier, segments, bonds) } fn into_f64(self) -> f64 { 1.0 } }
Rust
3D
feos-org/feos
crates/feos-core/src/parameter/identifier.rs
.rs
4,814
164
use serde::{Deserialize, Serialize}; use std::fmt; use std::hash::{Hash, Hasher}; /// Possible variants to identify a substance. #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)] pub enum IdentifierOption { Cas, Name, IupacName, Smiles, Inchi, Formula, } impl fmt::Display for IdentifierOption { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let str = match self { IdentifierOption::Cas => "CAS", IdentifierOption::Name => "name", IdentifierOption::IupacName => "IUPAC name", IdentifierOption::Smiles => "SMILES", IdentifierOption::Inchi => "InChI", IdentifierOption::Formula => "formula", }; write!(f, "{str}") } } /// A collection of identifiers for a chemical structure or substance. #[derive(Serialize, Deserialize, Debug, Clone, Default)] pub struct Identifier { /// CAS number #[serde(default)] #[serde(skip_serializing_if = "Option::is_none")] pub cas: Option<String>, /// Commonly used english name #[serde(default)] #[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>, /// IUPAC name #[serde(default)] #[serde(skip_serializing_if = "Option::is_none")] pub iupac_name: Option<String>, /// SMILES key #[serde(default)] #[serde(skip_serializing_if = "Option::is_none")] pub smiles: Option<String>, /// InchI key #[serde(default)] #[serde(skip_serializing_if = "Option::is_none")] pub inchi: Option<String>, /// Chemical formula #[serde(default)] #[serde(skip_serializing_if = "Option::is_none")] pub formula: Option<String>, } impl Identifier { /// Create a new identifier. /// /// # Examples /// /// ```no_run /// # use feos_core::parameter::Identifier; /// let methanol = Identifier::new( /// Some("67-56-1"), /// Some("methanol"), /// Some("methanol"), /// Some("CO"), /// Some("InChI=1S/CH4O/c1-2/h2H,1H3"), /// Some("CH4O") /// ); pub fn new( cas: Option<&str>, name: Option<&str>, iupac_name: Option<&str>, smiles: Option<&str>, inchi: Option<&str>, formula: Option<&str>, ) -> Identifier { Identifier { cas: cas.map(Into::into), name: name.map(Into::into), iupac_name: iupac_name.map(Into::into), smiles: smiles.map(Into::into), inchi: inchi.map(Into::into), formula: formula.map(Into::into), } } pub fn as_str(&self, option: IdentifierOption) -> Option<&str> { match option { IdentifierOption::Cas => self.cas.as_deref(), IdentifierOption::Name => self.name.as_deref(), IdentifierOption::IupacName => self.iupac_name.as_deref(), IdentifierOption::Smiles => self.smiles.as_deref(), IdentifierOption::Inchi => self.inchi.as_deref(), IdentifierOption::Formula => self.formula.as_deref(), } } // returns the first available identifier in a somewhat arbitrary // prioritization. Used for readable outputs. pub fn as_readable_str(&self) -> Option<&str> { self.name .as_deref() .or(self.iupac_name.as_deref()) .or(self.smiles.as_deref()) .or(self.cas.as_deref()) .or(self.inchi.as_deref()) .or(self.formula.as_deref()) } } impl std::fmt::Display for Identifier { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut ids = Vec::new(); if let Some(n) = &self.cas { ids.push(format!("cas={n}")); } if let Some(n) = &self.name { ids.push(format!("name={n}")); } if let Some(n) = &self.iupac_name { ids.push(format!("iupac_name={n}")); } if let Some(n) = &self.smiles { ids.push(format!("smiles={n}")); } if let Some(n) = &self.inchi { ids.push(format!("inchi={n}")); } if let Some(n) = &self.formula { ids.push(format!("formula={n}")); } write!(f, "Identifier({})", ids.join(", ")) } } impl PartialEq for Identifier { fn eq(&self, other: &Self) -> bool { self.cas == other.cas } } impl Eq for Identifier {} impl Hash for Identifier { fn hash<H: Hasher>(&self, state: &mut H) { self.cas.hash(state); } } #[cfg(test)] mod test { use super::*; #[test] fn test_fmt() { let id = Identifier::new(None, Some("acetone"), None, Some("CC(=O)C"), None, None); assert_eq!(id.to_string(), "Identifier(name=acetone, smiles=CC(=O)C)"); } }
Rust
3D
feos-org/feos
crates/feos-core/src/phase_equilibria/phase_envelope.rs
.rs
5,518
158
use super::{PhaseDiagram, PhaseEquilibrium}; use crate::SolverOptions; use crate::equation_of_state::Residual; use crate::errors::FeosResult; use crate::state::{Contributions, State}; use nalgebra::DVector; use quantity::{Pressure, Temperature}; impl<E: Residual> PhaseDiagram<E, 2> { /// Calculate the bubble point line of a mixture with given composition. pub fn bubble_point_line( eos: &E, molefracs: &DVector<f64>, min_temperature: Temperature, npoints: usize, critical_temperature: Option<Temperature>, options: (SolverOptions, SolverOptions), ) -> FeosResult<Self> { let mut states = Vec::with_capacity(npoints); let sc = State::critical_point( eos, Some(molefracs), critical_temperature, None, SolverOptions::default(), )?; let max_temperature = min_temperature + (sc.temperature - min_temperature) * ((npoints - 2) as f64 / (npoints - 1) as f64); let temperatures = Temperature::linspace(min_temperature, max_temperature, npoints - 1); let mut vle: Option<PhaseEquilibrium<E, 2>> = None; for ti in &temperatures { // calculate new liquid point let p_init = vle .as_ref() .map(|vle| vle.vapor().pressure(Contributions::Total)); let vapor_molefracs = vle.as_ref().map(|vle| &vle.vapor().molefracs); vle = PhaseEquilibrium::bubble_point( eos, ti, molefracs, p_init, vapor_molefracs, options, ) .ok(); if let Some(vle) = vle.as_ref() { states.push(vle.clone()); } } states.push(PhaseEquilibrium::from_states(sc.clone(), sc)); Ok(PhaseDiagram::new(states)) } /// Calculate the dew point line of a mixture with given composition. pub fn dew_point_line( eos: &E, molefracs: &DVector<f64>, min_temperature: Temperature, npoints: usize, critical_temperature: Option<Temperature>, options: (SolverOptions, SolverOptions), ) -> FeosResult<Self> { let mut states = Vec::with_capacity(npoints); let sc = State::critical_point( eos, Some(molefracs), critical_temperature, None, SolverOptions::default(), )?; let n_t = npoints / 2; let max_temperature = min_temperature + (sc.temperature - min_temperature) * ((n_t - 2) as f64 / (n_t - 1) as f64); let temperatures = Temperature::linspace(min_temperature, max_temperature, n_t - 1); let mut vle: Option<PhaseEquilibrium<E, 2>> = None; for ti in &temperatures { let p_init = vle .as_ref() .map(|vle| vle.vapor().pressure(Contributions::Total)); let liquid_molefracs = vle.as_ref().map(|vle| &vle.liquid().molefracs); vle = PhaseEquilibrium::dew_point(eos, ti, molefracs, p_init, liquid_molefracs, options) .ok(); if let Some(vle) = vle.as_ref() { states.push(vle.clone()); } } let n_p = npoints - n_t; if vle.is_none() { return Ok(PhaseDiagram::new(states)); } let min_pressure = vle.as_ref().unwrap().vapor().pressure(Contributions::Total); let p_c = sc.pressure(Contributions::Total); let max_pressure = min_pressure + (p_c - min_pressure) * ((n_p - 2) as f64 / (n_p - 1) as f64); let pressures = Pressure::linspace(min_pressure, max_pressure, n_p); for pi in &pressures { let t_init = vle.as_ref().map(|vle| vle.vapor().temperature); let liquid_molefracs = vle.as_ref().map(|vle| &vle.liquid().molefracs); vle = PhaseEquilibrium::dew_point(eos, pi, molefracs, t_init, liquid_molefracs, options) .ok(); if let Some(vle) = vle.as_ref() { states.push(vle.clone()); } } states.push(PhaseEquilibrium::from_states(sc.clone(), sc)); Ok(PhaseDiagram::new(states)) } /// Calculate the spinodal lines for a mixture with fixed composition. pub fn spinodal( eos: &E, molefracs: &DVector<f64>, min_temperature: Temperature, npoints: usize, critical_temperature: Option<Temperature>, options: SolverOptions, ) -> FeosResult<Self> { let mut states = Vec::with_capacity(npoints); let sc = State::critical_point( eos, Some(molefracs), critical_temperature, None, SolverOptions::default(), )?; let max_temperature = min_temperature + (sc.temperature - min_temperature) * ((npoints - 2) as f64 / (npoints - 1) as f64); let temperatures = Temperature::linspace(min_temperature, max_temperature, npoints - 1); for ti in &temperatures { let spinodal = State::spinodal(eos, ti, Some(molefracs), options).ok(); if let Some(spinodal) = spinodal { states.push(PhaseEquilibrium(spinodal)); } } states.push(PhaseEquilibrium::from_states(sc.clone(), sc)); Ok(PhaseDiagram::new(states)) } }
Rust