Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8f50fe8
added comments and added to density.py
coreen-mullen Jun 30, 2025
04a8e22
Editing density.py
coreen-mullen Jul 1, 2025
664fd68
Error fixing
ratzho Aug 5, 2025
0a5888d
resolve merge conflicts
ratzho Aug 6, 2025
19734cd
editing test
coreen-mullen Aug 11, 2025
9978153
'added base for ensemble score'
coreen-mullen Sep 4, 2025
60864da
Save local changes before merging
coreen-mullen Sep 5, 2025
b32df65
Save local changes before merging
coreen-mullen Sep 5, 2025
76a70a9
Resolved merge conflicts
coreen-mullen Sep 5, 2025
fd3d3cb
update scoring.py
coreen-mullen Sep 5, 2025
2f212f9
Merge branch 'develop' into develop
coreen-mullen Sep 8, 2025
4577d51
merging remote
ratzho Sep 8, 2025
55b5523
adding untracked files and adding edited testing.py
ratzho Sep 8, 2025
4377e7a
concluded all commits
ratzho Sep 9, 2025
649d3fd
fixing merge errors
ratzho Sep 9, 2025
1ca6783
Merge branch 'pr-branch' into develop
ratzho Sep 17, 2025
1eb24a0
Updating ensemble score.
ratzho Sep 24, 2025
506a561
updating ensemble
ratzho Sep 25, 2025
1c9bdcc
test
coreen-mullen Sep 25, 2025
81e93b6
adding hard coded target_var to fix error
coreen-mullen Sep 30, 2025
f408966
Merge branch 'develop' of https://github.com/FitSNAP/structure-genera…
coreen-mullen Oct 1, 2025
2c5dd56
'deleting extra testing files.'
coreen-mullen Oct 1, 2025
57682ab
edited scoring and grs.py for ensemble.
coreen-mullen Oct 6, 2025
4e155dc
Merge branch 'develop' of github.com:coreen-mullen/coreen_refactor in…
coreen-mullen Oct 6, 2025
db0bc62
editing GRS and scoring
coreen-mullen Oct 6, 2025
0610e9c
Delete GRSlib/DONTPUSHVER0FILES.py
coreen-mullen Oct 6, 2025
3eae13a
Delete GRSlib/motion/.gitignore
coreen-mullen Oct 6, 2025
53f9fab
deleting extra files in PR
coreen-mullen Oct 6, 2025
358575b
commiting before merge.
coreen-mullen Oct 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ docs/build/
# ignore MacOS generated files
*.DS_Store


#ignore openmpi folder
testing/openmpi-4.1.1/
Binary file added GRSlib/.GRS.py.swn
Binary file not shown.
Binary file added GRSlib/.GRS.py.swo
Binary file not shown.
61 changes: 45 additions & 16 deletions GRSlib/GRS.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from GRSlib.parallel_tools import ParallelTools
from GRSlib.io.input import Config
from GRSlib.converters.convert_factory import convert
from GRSlib.motion.scoring import Scoring, elems, get_desc_count
from GRSlib.motion.scoring_factory import scoring
from GRSlib.motion.motion import Gradient, Genetic
from GRSlib.motion.scoring import Scoring
from GRSlib.motion.motion import Gradient, Optimize, Create

import random, copy, os, glob, shutil
import numpy as np

Expand Down Expand Up @@ -165,6 +166,38 @@ def get_score(self,data):
raise RuntimeError(">>> Found unmatched BASIS for target and current descriptors")

return score
def get_ensemble(self,data):
print("get ensemble called.")
print("Using elems:",elems)
print("Ensemble Target")
scores=None
try:
scores = self.score.ensemble_score(
n_totconfig=10, # Example value
data_path='bcc.data', # Example value
cross_weight=1.0,
self_weight=1.0,
randomize_comps=False,
mincellsize=54,
maxcellsize=55,
target_comps={'W': 1.0}, # Ensure this is a dictionary
min_typ_global='box',
soft_strength=0.0,
nelements=len(elems), # Ensure elems is defined
n_descs=get_desc_count('coupling_coefficients.yace'), # Ensure this function is defined
mask=None, # Set this as needed
rand_comp=1) # Ensure this is defined correctly
print("Scores returned from ensemble_score:", scores)
except Exception as e:
print(f"An error occurred while calculating the ensemble score: {e}")
return None # Optionally return None or handle the error as needed
# Check if score was calculated
if scores is None or len(scores) == 0:
print("No scores were calculated returning None")
raise RuntimeError("Ensemble score could not be calculated.")

return scores # Ensure you return the score
#""" self.score = Scoring(data, self.current_desc, self.target_desc, self.prior_desc, self.pt, self.config)score = self.score.ensemble_score() return score"""

def propose_structure(self):
"""
Expand All @@ -187,21 +220,17 @@ def genetic_move(self,data):
#3) Hybridize, Mutate based on set of rules and probabilities
#4) Store socring information with best-of-generation and best-overall isolated
#5) Loop until generation limit or scoring residual below threshold
if data == None:
data = self.propose_structure()
self.descriptors['current']= self.convert_to_desc(data)
try:
self.descriptors['target'] = np.load(self.config.sections['TARGET'].target_fdesc)
except:
self.descriptors['target'] = self.convert_to_desc(self.config.sections['TARGET'].target_fname)

self.score = Scoring(self.pt, self.config, self.loss_func, data, self.descriptors) # Set scoring class to assign scores to moves
self.genmove = Optimize(self.pt, self.config, self.score) #Set desired motion class with scoring attached


#self.genmove.tournament_selection()
#for iterations in top_candidates[1], convert.ase_to_lammps
#self.write_output()
print("Called Genetic_Move")
if self.current_desc is None:
self.current_desc = self.propose_structure()
#if data == None:
#data = self.propose_structure()

self.descriptors['current'] = self.convert_to_desc(data)
self.descriptors['target'] = self.convert_to_desc(self.config.sections['TARGET'].target_fname)
self.genmove = Genetic(self.pt, self.config, data, self.descriptors)
#Dont want to make a func call the default here since the user will define this?
#Need a fallback to provide a good default if a genetic move is called.

# @self.pt.single_timeit
def gradient_move(self,data):
Expand Down
14 changes: 11 additions & 3 deletions GRSlib/Ver0_Files/opt_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,16 @@ def at_to_lmp(atoms,index,temperature=10000.0,min_typ='temp', coefftypes=True,so
return s


from crystal_enum import *
#from crystal_enum import *
from GRSlib.Ver0_Files.crystal_enum import *
def prim_crystal(elem_list):
all_prims = get_prim_structs(elem_list, multiatom=False)
myind = np.random.choice(range(len(all_prims)))
return all_prims[myind]


from hnf import *
#from hnf import *
from GRSlib.Ver0_Files.hnf import *
#elems[0],desired_size,volfrac=1.0,cubic=True,override_lat='fcc',override_a=2.98
def bulk_template(elem,desired_size,volfrac=1.0,cubic=True,override_lat=None,override_a=None):
if not override_a:
Expand Down Expand Up @@ -407,28 +409,34 @@ def internal_generate_cell(index,desired_size=4,template=None,desired_comps={'Ni
#from ase.build import bulk
#from ase import Atoms,Atom
chems = list(desired_comps.keys())
print(f"Generate new template for chemical: {chems[0]} with desired size: {desired_size}.")
template = Atoms([chems[0]]*desired_size)
atoms_base = bulk(chems[0])
vol_base = vnp.dot(vnp.cross(atoms_base.get_cell()[0],atoms_base.get_cell()[1]),atoms_base.get_cell()[2])
a_simp = vol_base**(1/3)
#cells = get_hnfs(hnf_trs=[desired_size])
cells_all = get_hnfs(hnf_trs=[desired_size])
print(f"Total cells generated: {len(cells_all)}")
toli = int((desired_size)**(1/3))
cells= limit_mats_len(cells_all,desired_size,tol=0.16)
#print ('ncells',len(cells))
try:
cell = a_simp * cells[vnp.random.choice(range(len(cells)))]
print(f"Selected cell shape:{cell}")
except ValueError:
cell = a_simp * cells_all [vnp.random.choice(range(len(cells_all)))]
print("ValueError encountered, using alt. cell.")
#print ('hnf',cell)
norms = np.array([np.linalg.norm(k) for k in cell])
norms /= (desired_size)
print(f"Normalized cell dimensions: {norms}")
#print('hnf norms',norms)
#cell = a_simp * cells[-2]
template.set_cell(cell)
template.set_scaled_positions(vnp.random.uniform(0,1,(desired_size,3)))
print(f"Template set with cell dimensions: {template.get_cell()}")
else:
tempalte = template
template = template

new_comps = {elem:int(round(len(template)*cmp))/len(template) for elem,cmp in desired_comps.items()}
print ('for structure of size:%d'% len(template),'desired compositions:', desired_comps,'will be replaced with', new_comps)
Expand Down
5 changes: 2 additions & 3 deletions GRSlib/converters/sections/lammps_ace.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _prepare_lammps(self):

compute_name='pace'
numtypes = len(self.config.sections['BASIS'].elements)
base_pace = "compute %s all pace coupling_coefficients.yace %s %s" % (compute_name,self.config.sections['BASIS'].bikflag,self.config.sections['BASIS'].dgradflag)
base_pace = "compute %s all pace coupling_coefficients.yace %d %d" % (compute_name,self.config.sections['BASIS'].bikflag,self.config.sections['BASIS'].dgradflag)
self._lmp.command(base_pace)
return compute_name

Expand Down Expand Up @@ -51,8 +51,7 @@ def _collect_lammps_single(self):
elems = elemstr4.split()
nelements = len(elems)
desclines = [line for line in lines if 'mu0' in line]

#ncols_pace = int(len(desclines)/nelements)

ncols_pace = int(len(desclines)/nelements) + nelements
nrows_pace = num_atoms
lmp_pace = _extract_compute_np(self._lmp, "pace", 0, 2, (nrows_pace, ncols_pace))
Expand Down
Loading