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 |
|---|---|---|---|---|---|---|---|
2D | lherron2/thermomaps-ising | thermomaps-root/tm/core/__init__.py | .py | 0 | 0 | null | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/tm/core/loader.py | .py | 12,578 | 459 | from torch.utils.data import Dataset
import torch
import numpy as np
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
class Transform:
"""
Base class for data transforms.
"""
def __init__(self, data):
"""
Initialize a Transform.
Args:
... | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/tm/core/utils.py | .py | 2,164 | 90 | import yaml
import torch.nn.functional as F
import numpy as np
import os
import re
def exists(x):
"""
Check if a variable exists (is not None).
Args:
x: Any variable.
Returns:
bool: True if the variable is not None, False otherwise.
"""
return x is not None
def default(val,... | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/tm/core/Prior_old.py | .py | 13,014 | 429 | import torch
from scipy.optimize import curve_fit
import numpy as np
from typing import Any, Callable, Dict, List
import logging
logging.basicConfig(level=logging.DEBUG)
def temperature_density_rescaling(std_temp, ref_temp):
"""
Calculate temperature density rescaling factor.
Args:
std_temp (torc... | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/tm/architectures/unet_2d_mid_attn.py | .py | 12,485 | 445 | import math
from functools import partial
from collections import namedtuple
import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange, reduce
from einops.layers.torch import Rearrange
# constants
ModelPrediction = namedtuple("ModelPrediction", ["pred_noise", "pred_x_st... | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/tm/architectures/UNet2D.py | .py | 12,922 | 454 | import math
from functools import partial
from collections import namedtuple
import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange, reduce
from einops.layers.torch import Rearrange
# constants
ModelPrediction = namedtuple("ModelPrediction", ["pred_noise", "pred_x_s... | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/tm/architectures/__init__.py | .py | 0 | 0 | null | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/tm/architectures/UNet2D_pbc.py | .py | 32,108 | 908 | import math
import copy
from pathlib import Path
from random import random
from functools import partial
from collections import namedtuple
from multiprocessing import cpu_count
import torch
from torch import nn, einsum
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
from torch.optim ... | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/tm/architectures/unet_1d.py | .py | 11,681 | 418 | import math
from functools import partial
import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange, reduce
# helpers functions
def exists(x):
return x is not None
def default(val, d):
if exists(val):
return val
return d() if callable(d) else d
de... | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/tm/architectures/UNet_PBC.py | .py | 32,108 | 908 | import math
import copy
from pathlib import Path
from random import random
from functools import partial
from collections import namedtuple
from multiprocessing import cpu_count
import torch
from torch import nn, einsum
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
from torch.optim ... | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/data/dataset.py | .py | 6,050 | 151 | from data.trajectory import Trajectory
from data.generic import Summary
from typing import List, Dict, Union, Iterable
from slurmflow.serializer import ObjectSerializer
from sklearn.model_selection import ShuffleSplit
from tm.core.loader import Loader
import numpy as np
import pandas as pd
import logging
import sys
lo... | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/data/__init__.py | .py | 0 | 0 | null | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/data/trajectory.py | .py | 7,609 | 196 | import os
import numpy as np
from data.observables import Observable
from data.generic import DataFormat, Summary
from typing import List, Optional, Dict, Union, Iterable
import collections
import logging
import sys
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHand... | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/data/generic.py | .py | 2,438 | 70 |
import pandas as pd
from typing import Any, Iterable, List
import logging
from slurmflow.serializer import ObjectSerializer
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
class Summary:
def __init__(self, **kwargs):
for key, value in kwargs.items():
setattr(... | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/data/utils.py | .py | 682 | 33 | import torch
import numpy as np
import re
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
import logging
def regex_list(regex, l):
"""
Filter a list using a regular expression.
Args:
regex (str): The regular expression pattern.
l (list): The list to be f... | Python |
2D | lherron2/thermomaps-ising | thermomaps-root/data/observables.py | .py | 4,162 | 129 |
import copy
import numpy as np
from abc import ABC, abstractmethod
from typing import Union, Type
from data.utils import ArrayWrapper
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
class Observable(ABC):
def __init__(self, name: str = None):
self.name = name
@abstr... | Python |
2D | kirchhausenlab/Cryosamba | setup.py | .py | 526 | 24 | from setuptools import setup
setup(
name="cryosamba",
version="0.1",
description="Arkash Jain added the automate folder CI/CD, reach out to him for assistance",
author="Jose Inacio da Costa Filho",
author_email="",
license="MIT",
install_requires=[
"torch",
"torchvision",
... | Python |
2D | kirchhausenlab/Cryosamba | advanced_instructions.md | .md | 11,041 | 220 | # Advanced instructions
## Table of Contents
1. [Installation](#installation) 🐍
2. [Training](#training)
- [Setup Training](#setup-training) 🛠️
- [Run Training](#run-training) 🚀
- [Visualization with TensorBoard](#visualization-with-tensorboard) 📈
3. [Inference](#inference)
- [Setup Inference](#setu... | Markdown |
2D | kirchhausenlab/Cryosamba | train.py | .py | 9,788 | 304 | import os, sys
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
import argparse
from time import time
import torch
from torch import GradScaler
from torch import autocast
from core.model import get_model, get_loss
from core.dataset import get_dataloader
from core.utils.utils import (
setup_run,
load_json,
logge... | Python |
2D | kirchhausenlab/Cryosamba | logging_config.py | .py | 1,752 | 59 | import logging
import logging.config
import sys
from pathlib import Path
# Set base directory for logs
BASE_DIR = Path(__file__).resolve().parent
LOGS_DIR = Path(BASE_DIR, "logs")
LOGS_DIR.mkdir(parents=True, exist_ok=True)
# making a logging config
logging_config = {
"version": 1,
"disable_existing_loggers":... | Python |
2D | kirchhausenlab/Cryosamba | __init__.py | .py | 143 | 5 | from __future__ import absolute_import
from . import automate, configs, core, requirements, scripts, tests
from .logging_config import logger
| Python |
2D | kirchhausenlab/Cryosamba | inference.py | .py | 8,649 | 267 | import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
import argparse
from time import time
import numpy as np
import torch
from torch import autocast
from core.dataset import get_dataloader
from core.model import get_model
from core.utils.data_utils import (
denormalize_imgs,
get_data,
get_overlap_pad,
... | Python |
2D | kirchhausenlab/Cryosamba | run_cryosamba.py | .py | 32,247 | 839 | import os
import sys
import shutil
import json
import subprocess
from functools import wraps
from pathlib import Path
from typing import Any, Dict, List, Optional, Union
import typer
from loguru import logger
from rich import print as rprint
from rich.console import Console
app = typer.Typer()
RUNS_DIR = os.path.joi... | Python |
2D | kirchhausenlab/Cryosamba | core/fusionnet.py | .py | 5,963 | 181 | import torch
import torch.nn as nn
import torch.nn.functional as F
from core.utils.nn_utils import ConvBlock, conv2, conv4, deconv, deconv3, warp_fn
class DownsampleImage(nn.Module):
def __init__(self, num_channels, padding_mode="zeros"):
super().__init__()
self.downsample_mask = nn.Sequential(
... | Python |
2D | kirchhausenlab/Cryosamba | core/biflownet.py | .py | 13,495 | 419 | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from core.utils.nn_utils import ConvBlock, backwarp, conv2, deconv, warp_fn
class ImportanceMask(nn.Module):
def __init__(self, mode):
super().__init__()
self.conv_img = ConvBlock(
in_channels=1, ou... | Python |
2D | kirchhausenlab/Cryosamba | core/model.py | .py | 3,207 | 112 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parallel import DistributedDataParallel as DDP
from core.dataset import DatasetBase
from core.biflownet import BiFlowNet
from core.fusionnet import FusionNet
class CharbonnierLoss(nn.Module):
def __init__(self, eps=1e-6):
su... | Python |
2D | kirchhausenlab/Cryosamba | core/dataset.py | .py | 4,145 | 127 | import os, glob
import numpy as np
import tifffile
import mrcfile
import torch
from torch.utils.data import Dataset, DataLoader, ConcatDataset
from torch.utils.data.distributed import DistributedSampler
from core.utils.data_utils import normalize_imgs, denormalize_imgs, augment_dataset
class DatasetBase(Dataset):
... | Python |
2D | kirchhausenlab/Cryosamba | core/utils/softsplat.py | .py | 25,936 | 668 | #!/usr/bin/env python
import collections
import os
import re
import typing
import cupy
import torch
##########################################################
objCudacache = {}
def cuda_int32(intIn: int):
return cupy.int32(intIn)
# end
def cuda_kernel(strFunction: str, strKernel: str, objVariables: typing... | Python |
2D | kirchhausenlab/Cryosamba | core/utils/__init__.py | .py | 0 | 0 | null | Python |
2D | kirchhausenlab/Cryosamba | core/utils/torch_utils.py | .py | 5,030 | 177 | import os
import torch
import torch.distributed as dist
import numpy as np
import random
from core.utils.utils import make_dir, load_json, save_json
### DDP utils
def sync_nodes(is_ddp):
if is_ddp:
dist.barrier()
else:
pass
def cleanup(is_ddp):
if is_ddp:
dist.destroy_process_g... | Python |
2D | kirchhausenlab/Cryosamba | core/utils/utils.py | .py | 3,313 | 137 | import os, glob
from distutils.util import strtobool
from easydict import EasyDict
import sys
import json
import shutil
from loguru import logger
from torch.utils.tensorboard import SummaryWriter
def listify(x):
return x if isinstance(x, list) else [x]
### File utils
def make_dir(path):
if not os.path.exi... | Python |
2D | kirchhausenlab/Cryosamba | core/utils/nn_utils.py | .py | 4,401 | 163 | import torch
import torch.nn as nn
import torch.nn.functional as F
from core.utils import softsplat
def backwarp(tenInput, tenFlow):
tenHor = (
torch.linspace(
-1.0 + (1.0 / tenFlow.shape[3]),
1.0 - (1.0 / tenFlow.shape[3]),
tenFlow.shape[3],
device=tenFlo... | Python |
2D | kirchhausenlab/Cryosamba | core/utils/data_utils.py | .py | 5,816 | 205 | import glob
import os
import mrcfile
import numpy as np
import tifffile as tif
import torch
import warnings
from core.utils.utils import make_dir
def get_overlap_pad(patch_overlap, device):
overlap_pad = patch_overlap
overlap_pad = [
[0, 0],
[overlap_pad[0] // 2, overlap_pad[0] // 2],
... | Python |
2D | kirchhausenlab/Cryosamba | automate/cryosamba_setup.py | .py | 4,991 | 143 | import logging
import os
import subprocess
import sys
import streamlit as st
from training_setup import handle_exceptions
from logging_config import logger
def run_command(command, shell=True):
process = subprocess.Popen(
command,
shell=shell,
stdout=subprocess.PIPE,
stderr=subpr... | Python |
2D | kirchhausenlab/Cryosamba | automate/file_selector.py | .py | 1,660 | 54 | import os
import streamlit as st
from logging_config import logger
def list_directories_in_directory(directory):
try:
with os.scandir(directory) as entries:
dirs = [entry.name for entry in entries if entry.is_dir()]
return dirs
except PermissionError:
st.error("Permission ... | Python |
2D | kirchhausenlab/Cryosamba | automate/run_inference.py | .py | 3,923 | 101 | import logging
import os
import subprocess
from functools import wraps
from typing import List
import streamlit as st
from file_selector import get_dir, list_directories_in_directory
from training_setup import handle_exceptions
from logging_config import logger
@handle_exceptions
def select_gpus() -> List[str]:
... | Python |
2D | kirchhausenlab/Cryosamba | automate/inference_setup.py | .py | 9,424 | 256 | import json
import logging
import os
from functools import wraps
from random import randint
import streamlit as st
from file_selector import get_dir, list_directories_in_directory
from training_setup import handle_exceptions
from logging_config import logger
def folder_exists(folder_path):
"""Check if the given... | Python |
2D | kirchhausenlab/Cryosamba | automate/test.py | .py | 5,022 | 132 | import logging
import os
import subprocess
import sys
from functools import wraps
import streamlit as st
from training_setup import handle_exceptions
from logging_config import logger
@handle_exceptions
def is_conda_installed() -> bool:
"""Run a subprocess to see if conda is installled or not"""
try:
... | Python |
2D | kirchhausenlab/Cryosamba | automate/run_training.py | .py | 5,004 | 118 | import logging
import os
import subprocess
import webbrowser
from functools import wraps
from typing import List
import streamlit as st
from file_selector import get_dir, list_directories_in_directory
from training_setup import handle_exceptions
from logging_config import logger
@handle_exceptions
def select_gpus()... | Python |
2D | kirchhausenlab/Cryosamba | automate/main.py | .py | 1,747 | 56 | import logging
import os
from test import setup_environment_for_cryosamba
import streamlit as st
from inference_setup import setup_inference
from run_inference import select_experiment_and_run
from run_training import select_experiment_and_run_training
from training_setup import setup_cryosamba_and_training
from logg... | Python |
2D | kirchhausenlab/Cryosamba | automate/training_setup.py | .py | 13,235 | 361 | import json
import logging
import os
from functools import wraps
from random import randint
import streamlit as st
from file_selector import get_dir, list_directories_in_directory
from logging_config import logger
def handle_exceptions(input_func):
"""Decorator for handling exceptions"""
@wraps(input_func)... | Python |
2D | kirchhausenlab/Cryosamba | automate/scripts/install_cryosamba.sh | .sh | 1,999 | 70 | #!/bin/bash
check_conda() {
STR="Conda installation not found"
if command -v conda &> /dev/null; then
STR="Conda is already installed"
echo $STR
fi
if [ "$STR" = "Conda installation not found" ]; then
echo "Installing conda, please hit yes and enter to install (this may take 3-... | Shell |
2D | kirchhausenlab/Cryosamba | automate/scripts/install_requirements_txt_for_ref.sh | .sh | 101 | 7 | #!/bin/bash
install_requirements(){
pip3 install pipreqs
pipreqs ../.
}
install_requirements
| Shell |
2D | kirchhausenlab/Cryosamba | automate/scripts/train_data.sh | .sh | 1,392 | 55 | #!/bin/bash
select_gpus(){
echo "The following GPU's are currently not in use"
nvidia-smi && nvidia-smi --query-gpu=index,utilization.gpu,memory.free,memory.total,memory.used --format=csv
echo "--"
echo ""
echo "Enter which GPU you want (seperate using commas, e.g. - 2,3)"
read -r gpu_indices
}... | Shell |
2D | kirchhausenlab/Cryosamba | automate/scripts/setup_experiment_training.sh | .sh | 3,569 | 140 | #!/bin/bash
make_folder() {
while true; do
echo "What do you want to name your experiment, type below: "
read -r input_name
if [ -z "$input_name" ]; then
echo "PLEASE ENTER A NAME, experiment name cannot be empty"
elif [ -d "../../$input_name" ]; then
echo "Experiment alre... | Shell |
2D | kirchhausenlab/Cryosamba | automate/scripts/run_inference.sh | .sh | 1,398 | 55 | #!/bin/bash
select_gpus(){
echo "The following GPU's are currently not in use"
nvidia-smi && nvidia-smi --query-gpu=index,utilization.gpu,memory.free,memory.total,memory.used --format=csv
echo "--"
echo ""
echo "Enter which GPU you want (seperate using commas, e.g. - 2,3)"
read -r gpu_indices
}... | Shell |
2D | kirchhausenlab/Cryosamba | automate/scripts/setup_inference.sh | .sh | 2,148 | 93 | #!/bin/bash
select_experiment_location(){
echo "Enter the name of the experiment you want to run inference for:"
read -r EXP_NAME
if [ ! -d "../../runs/$EXP_NAME" ]; then
echo "Experiment does not exist, please make one! You can run setup_experiment.sh to do so"
exit 1
fi
}
generate_config() {
base_config=$(ca... | Shell |
2D | kirchhausenlab/Cryosamba | automate/scripts/find_vulnerabilities.sh | .sh | 177 | 11 | #!/bin/bash
install_bandit_and_run_tests(){
conda activate cryosamba_env
conda install bandit
conda install bandit[toml]
bandit -r ../. -ll
}
install_bandit_and_run_tests
| Shell |
2D | kirchhausenlab/Cryosamba | automate/scripts/additional/setup_cron.sh | .sh | 325 | 14 | #!/bin/bash
## run a cron job every 24 hours to see if dependencies need to be updated or not
CURR_PATH="$(pwd)/update_env.sh"
LOG_FILE="$(pwd)/cron_update.log"
crontabl -l > mycron
echo "0 0 * * * $SCRIPT_PATH >> $LOG_FILE 2>&1" >> mycron
crontab mycron
rm mycron
echo "Cron job has been set up to run $CURR_PATH d... | Shell |
2D | kirchhausenlab/Cryosamba | automate/scripts/additional/update_env.sh | .sh | 330 | 10 | #!/bin/bash
## Update the environment in cases when libraries might be getting old or not
ENV_NAME="cryosamba_env"
YML_PATH="../../environment.yml"
conda deactivate
conda env update --name $ENV_NAME --file $YML_PATH --prune
conda activate $ENV_NAME
echo "$(date): Conda environment has been updated via cron job schedu... | Shell |
2D | kirchhausenlab/Cryosamba | tests/__init__.py | .py | 0 | 0 | null | Python |
2D | kirchhausenlab/Cryosamba | tests/run_e2e.sh | .sh | 970 | 13 | #!/bin/bash
#The test_sample folder has some sample data produced by running 500 iterations of cryosamba on a DGX A100 GPU with a batch size of
# 16 and max frame gap of 3. The following test recreates that scenario for users and will take around 15 minutes to run (both train and inference)
# Once you have the trainin... | Shell |
2D | kirchhausenlab/Cryosamba | tests/run_e2e.py | .py | 3,721 | 116 | """
The test_sample folder has some sample data produced by running 500 iterations of cryosamba on a DGX A100 GPU with a batch size of
16 and max frame gap of 3. The following test recreates that scenario for users and will take around 15 minutes to run (both train and inference)
Once you have the training and inferenc... | Python |
2D | kirchhausenlab/Cryosamba | tests/unit/test_run_automatic_train_file_creation.py | .py | 5,460 | 201 | import os
import sys
import subprocess
import unittest
import json
def run_bash_script(script_content):
# Write the script content to a temporary file
with open("temp_script.sh", "w") as f:
f.write(script_content)
# Make the script executable
os.chmod("temp_script.sh", 0o755)
# Run the s... | Python |
2D | kirchhausenlab/Cryosamba | tests/unit/test_trainConfig_gen.py | .py | 5,472 | 140 | import json
import os
import unittest
from pathlib import Path
from logging_config import logger
class TestTrainConfig(unittest.TestCase):
def setUp(self):
self.folder_name = "exp-random"
self.curr_path = Path(__file__).resolve().parent
self.path_to_experiments = self.curr_path.parent.par... | Python |
2D | kirchhausenlab/Cryosamba | tests/unit/test_inferenceConfig_generation.py | .py | 4,268 | 124 | import json
import os
import subprocess
import unittest
from pathlib import Path
from logging_config import logger
class TestInferenceConfig(unittest.TestCase):
def setUp(self):
self.folder_name = "exp-random"
self.curr_path = Path(__file__).resolve().parent
self.path_to_experiments = sel... | Python |
2D | kirchhausenlab/Cryosamba | tests/unit/__init__.py | .py | 0 | 0 | null | Python |
2D | kirchhausenlab/Cryosamba | tests/unit/test_setup_and_installation.py | .py | 3,337 | 101 | import os
import shlex
import subprocess
import sys
import unittest
from logging_config import logger
class TestCUDA_ENV(unittest.TestCase):
def run_command(self, command, shell=True):
"""
Run a shell command and return its output and error (if any).
"""
try:
process =... | Python |
2D | kirchhausenlab/Cryosamba | tests/unit/test_run_automatic_inference_file_creation.py | .py | 3,796 | 132 | import json
import os
import subprocess
import sys
import unittest
def run_bash_script(script_content):
with open("temp_script.sh", "w") as f:
f.write(script_content)
os.chmod("temp_script.sh", 0o755)
process = subprocess.Popen(
[
"./temp_script.sh",
],
stdout=s... | Python |
2D | kirchhausenlab/Cryosamba | tests/integration/__init__.py | .py | 1 | 2 | Python | |
2D | kirchhausenlab/Cryosamba | tests/integration/startup_and_setup.py | .py | 1,543 | 44 | import os
import shutil
import sys
import unittest
from tests.unit.test_inferenceConfig_generation import TestInferenceConfig
from tests.unit.test_run_automatic_inference_file_creation import (
TestInferenceRunCreation,
)
from tests.unit.test_run_automatic_train_file_creation import TestRunCreation
from tests.unit... | Python |
2D | giovannipizzi/SchrPoisson-2DMaterials | solver.ipynb | .ipynb | 22,187 | 536 | {
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Live demo of schrpoisson-2dmaterials"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This demo showcases the code developed as part of the following research work: \n",
"\n",
"A. Bussy, G. Pi... | Unknown |
2D | giovannipizzi/SchrPoisson-2DMaterials | input_examples/create_calc_input.py | .py | 2,037 | 60 | import json
## Change here if needed
#type_of_calc = "single_point"
type_of_calc = "map"
name_of_json_file = "example_calc_input.json"
if type_of_calc == "single_point" :
input_dict = {
"calculation": "single_point",
"smearing" : True,
"KbT" : 0.005,
"delta_x" : 0.5,
"m... | Python |
2D | giovannipizzi/SchrPoisson-2DMaterials | code/schrpoisson2D.py | .py | 71,997 | 1,569 | """
Main executable of the Schroedinger--Poisson solver for 2D materials.
See PDF documentation for its usage.
You need to pass on the command line the path to two JSON files, the first
to the materials properties, and the second to the calculation input flags:
python modulable_2Dschrpoisson.py {material_props}.jso... | Python |
2D | giovannipizzi/SchrPoisson-2DMaterials | code/schrpoisson_wire.f90 | .f90 | 18,289 | 554 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file contains the main logic for calculating the potential due to a single
!! wire and to an array of wires. These functions (that are the most expensive part
!! of the code) are then called from python.
!!
!!!!!!!!!!!!!!!!!!!!!... | Fortran |
2D | giovannipizzi/SchrPoisson-2DMaterials | docs/img/create_xsf.py | .py | 701 | 29 | import numpy as np
import ase
import ase.io
x_positions_1 = np.arange(0.0,7.0,3.0)
x_positions_2 = np.arange(10.0,31.0,4.0)
x_positions_3 = np.arange(33.0, 41.0, 3.0)
x_pos = np.append(x_positions_1, x_positions_2)
x_pos = np.append(x_pos,x_positions_3)
cell = ase.Atoms('C'*x_pos.size,
pbc=True,
... | Python |
2D | harshaa765/Bilinear-CZM-UMAT | Bilinear_CZM_UMAT.for | .for | 7,183 | 193 | ! Author: @Harshdeep_Sharma
! Affiliation: Indian Institute of Technology, Patna
! Find me @: Material Testing Lab, Block-3
! Lab Incharge: Dr. Akhilendra Singh
! Contact me: harshsharma52@gmail.com
! Desc: Bilinear UMAT (2D/3D Interfacial problems)
! Designed for standard solver and su... | Unknown |
2D | romankempt/hetbuilder | setup.py | .py | 2,187 | 79 | #!/usr/bin/env python
import re
from setuptools import find_packages
from pathlib import Path
import os
import sys
VERSIONFILE = "hetbuilder/__init__.py"
verstrline = open(VERSIONFILE, "rt").read()
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
if mo:
version = mo.group(1)
else... | Python |
2D | romankempt/hetbuilder | app/app.py | .py | 1,019 | 53 | from flask import (
Flask,
request,
Response,
redirect,
url_for,
render_template,
jsonify,
send_from_directory,
flash,
)
from flask_cors import CORS
import random
import sys
import json
from hetbuilder.atom_checks import check_atoms
app = Flask(__name__)
app = Flask(__name__, stat... | Python |
2D | romankempt/hetbuilder | backend/helper_classes.h | .h | 3,025 | 108 | #pragma once
#include "math_functions.h"
#include <iostream>
class CoincidencePairs
{
public:
int2dvec_t M;
int2dvec_t N;
CoincidencePairs(int2dvec_t &cM, int2dvec_t &cN)
{
M = cM;
N = cN;
};
int score() const;
};
// Two coincidence matrices are qualitatively the same if the... | Unknown |
2D | romankempt/hetbuilder | backend/helper_classes.cpp | .cpp | 528 | 18 | #include "helper_classes.h"
/**
* Yields a score to allow for sorting coincidence pairs by how "arbitrarily nice" they are.
*
* Prefers coincidence matrices that are symmetric and positive.
*/
int CoincidencePairs::score() const
{
int sum = this->M[0][0] + this->M[0][1] + this->M[1][0] + this->M[1][1];
in... | C++ |
2D | romankempt/hetbuilder | backend/interface_class.h | .h | 2,414 | 89 | #pragma once
#include "atom_class.h"
/**
* Container class for an interface after the coincidence lattice search.
*
* Contains the bottom layer and top layer in supercell form, as well as the
* stack thereof.
*
* Comparison operators are defined to allow for ordering and comparisons in a set.
*/
class Interface... | Unknown |
2D | romankempt/hetbuilder | backend/logging_functions.cpp | .cpp | 2,961 | 121 | #include <vector>
#include <iostream>
#include <map>
#ifdef _OPENMP
#include <omp.h>
#endif
#include "math_functions.h"
#include "logging_functions.h"
typedef std::vector<int> int1dvec_t;
typedef std::vector<double> double1dvec_t;
typedef std::vector<std::vector<int>> int2dvec_t;
typedef std::vector<std::vector<doub... | C++ |
2D | romankempt/hetbuilder | backend/math_functions.h | .h | 1,367 | 40 | #pragma once
#include <vector>
#include <array>
#include <cmath>
typedef std::vector<int> int1dvec_t;
typedef std::vector<double> double1dvec_t;
typedef std::vector<std::vector<int>> int2dvec_t;
typedef std::vector<std::vector<double>> double2dvec_t;
template <typename T1, typename T2>
std::vector<T1> basis_2x2_dot_2... | Unknown |
2D | romankempt/hetbuilder | backend/interface_class.cpp | .cpp | 86 | 6 | #include "interface_class.h"
/**
* score function was moved to CoincidencePairs
*/
| C++ |
2D | romankempt/hetbuilder | backend/atom_class.cpp | .cpp | 8,540 | 256 | #include "logging_functions.h"
#include "math_functions.h"
#include "atom_class.h"
#include "spglib.h"
#include "xtalcomp.h"
#include <algorithm>
// Prints lattice, positions, scaled positions and atomic numbers of atoms object.
void Atoms::print()
{
std::cout << "Lattice: " << std::endl;
print_2d_vector(thi... | C++ |
2D | romankempt/hetbuilder | backend/coincidence_algorithm.cpp | .cpp | 11,789 | 355 | #include <set>
// include <chrono>
// include <ctime>
#include <algorithm>
#include "logging_functions.h"
#include "math_functions.h"
#include "atom_class.h"
#include "atom_functions.h"
#include "helper_classes.h"
#include "interface_class.h"
#include "coincidence_algorithm.h"
#ifdef _OPENMP
#include <omp.h>
#endif
... | C++ |
2D | romankempt/hetbuilder | backend/coincidence_algorithm.h | .h | 1,768 | 51 | #pragma once
#include "logging_functions.h"
#include "math_functions.h"
#include "atom_class.h"
#include "atom_functions.h"
#include "helper_classes.h"
#include "interface_class.h"
typedef std::map<double, std::vector<CoincidencePairs>> angle_dict_t;
/**
* Class definition of the lattice coincidence algorithm.
*
*... | Unknown |
2D | romankempt/hetbuilder | backend/atom_functions.cpp | .cpp | 9,021 | 288 | #include <cmath>
#include "math_functions.h"
#include "logging_functions.h"
#include "atom_class.h"
#include "atom_functions.h"
using std::sin, std::cos, std::sqrt, std::pow, std::abs;
/**
* Find all lattice points contained in a supercell.
Adapted from pymatgen, which is available under MIT license:
The MI... | C++ |
2D | romankempt/hetbuilder | backend/math_functions.cpp | .cpp | 6,428 | 189 | #include <cmath>
#include <vector>
#include <array>
#include <set>
#include <map>
#include "math_functions.h"
using std::sin, std::cos, std::sqrt, std::pow, std::abs;
typedef std::vector<int> int1dvec_t;
typedef std::vector<double> double1dvec_t;
typedef std::vector<std::vector<int>> int2dvec_t;
typedef std::vector<... | C++ |
2D | romankempt/hetbuilder | backend/atom_class.h | .h | 2,862 | 110 | #pragma once
#include "math_functions.h"
#include "xtalcomp.h"
class Atoms
{
public:
double2dvec_t lattice;
double2dvec_t positions;
int1dvec_t atomic_numbers;
int numAtom;
int1dvec_t indices;
double1dvec_t magmoms;
// constructor if neither indices nor magmoms were provided
Atoms(dou... | Unknown |
2D | romankempt/hetbuilder | backend/pybindings.cpp | .cpp | 3,467 | 77 | #include <Python.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl_bind.h>
#include <pybind11/iostream.h>
#include "logging_functions.h"
#include "math_functions.h"
#include "atom_class.h"
#include "atom_functions.h"
#include "interface_class.h"
#include "coincidence_algorithm.h"
namespace py = pybind11;
type... | C++ |
2D | romankempt/hetbuilder | backend/atom_functions.h | .h | 306 | 10 | #pragma once
#include <vector>
double2dvec_t lattice_points_in_supercell(int2dvec_t &superCellMatrix);
Atoms make_supercell(Atoms &prim, int2dvec_t &superCellMatrix);
Atoms rotate_atoms_around_z(Atoms &atoms, double &theta);
Atoms stack_atoms(Atoms bottom, Atoms top, double &weight, double &distance); | Unknown |
2D | romankempt/hetbuilder | backend/logging_functions.h | .h | 613 | 24 | #pragma once
#include <vector>
#include <iostream>
#include <map>
typedef std::vector<int> int1dvec_t;
typedef std::vector<double> double1dvec_t;
typedef std::vector<std::vector<int>> int2dvec_t;
typedef std::vector<std::vector<double>> double2dvec_t;
template <typename T>
void print_1d_vector(std::vector<T> &vec);
... | Unknown |
2D | romankempt/hetbuilder | hetbuilder/backend_test.py | .py | 5,100 | 177 | """ Test functions for local testing, by copying the shared library hetbuilder_backend.so to hetbuilder/ """
from dataclasses import dataclass
from hetbuilder.algorithm import CoincidenceAlgorithm
from hetbuilder.plotting import InteractivePlot
from pathlib import Path
import ase.io
from ase.build import mx2
import... | Python |
2D | romankempt/hetbuilder | hetbuilder/__init__.py | .py | 460 | 18 | """hetbuilder"""
import sys
from distutils.version import LooseVersion
from pathlib import Path
if sys.version_info[0] == 2:
raise ImportError("Requires Python3. This is Python2.")
__version__ = "0.8.1"
PROJECT_ROOT_DIR = Path(__file__).absolute().parent
from hetbuilder.algorithm import Interface, CoincidenceA... | Python |
2D | romankempt/hetbuilder | hetbuilder/algorithm.py | .py | 14,116 | 385 | import ase.io
from ase.atoms import Atoms
from ase.spacegroup import Spacegroup
from ase.geometry import permute_axes
from ase.geometry.analysis import Analysis
from itertools import combinations_with_replacement
from dataclasses import dataclass
import numpy as np
from scipy.linalg import polar
from hetbuilder.lo... | Python |
2D | romankempt/hetbuilder | hetbuilder/plotting.py | .py | 10,810 | 366 | from dataclasses import dataclass, astuple
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
import matplotlib.cm as cm
from matplotlib.colors import ListedColormap, Normalize, LinearSegmentedColormap
from matplotlib import path, patches
import numpy as np
from itertools import product
from hetbu... | Python |
2D | romankempt/hetbuilder | hetbuilder/atom_checks.py | .py | 7,875 | 242 | import ase.io
from ase.geometry import permute_axes
from ase import neighborlist
from ase.data import covalent_radii
from ase.build import make_supercell
from ase.neighborlist import NeighborList, NewPrimitiveNeighborList
from spglib import find_primitive
import networkx as nx
import numpy as np
from collections im... | Python |
2D | romankempt/hetbuilder | hetbuilder/log.py | .py | 1,806 | 64 | import logging
import pretty_errors
from rich.logging import RichHandler
pretty_errors.configure(
separator_character="*",
filename_display=pretty_errors.FILENAME_EXTENDED,
line_number_first=True,
display_link=True,
lines_before=2,
lines_after=1,
line_color=pretty_errors.RED + "> " + prett... | Python |
2D | romankempt/hetbuilder | hetbuilder/utils.py | .py | 11,306 | 367 | from gettext import find
import matplotlib.pyplot as plt
import numpy as np
from math import sqrt
from itertools import islice
from ase.io.formats import string2index
from ase.utils import rotate
from ase.data import covalent_radii, atomic_numbers
from ase.data.colors import jmol_colors
from hetbuilder.algorithm imp... | Python |
2D | romankempt/hetbuilder | hetbuilder/cli.py | .py | 8,237 | 262 | #!/usr/bin/env python
from matplotlib.pyplot import step
import typer
from typer.params import Option, Argument
from typing import Optional, Tuple, List
from hetbuilder import __version__, CoincidenceAlgorithm, Interface, InteractivePlot
from hetbuilder.log import logger, set_verbosity_level
from hetbuilder.atom_check... | Python |
2D | romankempt/hetbuilder | docs/intro.md | .md | 2,783 | 93 | # Hetbuilder - builds heterostructure interfaces
[](https://zenodo.org/badge/latestdoi/358881237)
[](https://hetbuilder.readthedocs.io/en/latest/?badge=latest)
[.
[1]: https://doi.org/10.1021/acs.jpcc.6b01496 ". Phys. Chem. C 2016, 120, 20, 10895-10908"
Two 2D lattice bases (lattice vectors are given as column vectors) are given by:
```math
\mathbf{A} = \begin{pma... | Markdown |
2D | romankempt/hetbuilder | docs/conf.py | .py | 4,407 | 141 | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | Python |
2D | romankempt/hetbuilder | tests/performance_plot.py | .py | 993 | 43 | import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick
timings = [
0.04170293807983398,
0.15635199546813966,
0.22000808715820314,
0.3506165027618408,
0.5720492362976074,
1.0751613140106202,
4.725947093963623,
7.02956256866455,
103.4705885887146,
]
ncom... | Python |
2D | romankempt/hetbuilder | tests/test_backend.py | .py | 2,295 | 76 | import ase.io
from ase.atoms import Atoms
from ase.build import make_supercell
from pathlib import Path
from hetbuilder import PROJECT_ROOT_DIR
from hetbuilder.algorithm import cpp_atoms_to_ase_atoms, ase_atoms_to_cpp_atoms
from hetbuilder.hetbuilder_backend import (
double2dVector,
double1dVector,
int1d... | Python |
2D | romankempt/hetbuilder | tests/test_performance.py | .py | 927 | 32 | import ase.io
from pathlib import Path
from hetbuilder import PROJECT_ROOT_DIR
from hetbuilder.algorithm import CoincidenceAlgorithm
from hetbuilder.plotting import InteractivePlot
import numpy as np
import time
def test_scaling_performance():
bottom = ase.io.read(PROJECT_ROOT_DIR.joinpath("/tests/MoS2_2H_1l.x... | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.