pyscal / atomRDF

atomRDF is a python tool for ontology-based creation, manipulation, and quering of structures. atomRDF uses the Computational Material Sample Ontology (CMSO).
https://atomrdf.pyscal.org
MIT License
10 stars 2 forks source link

Repeated structures do not have defect-related triples #158

Closed GuojingHuangAa closed 3 months ago

GuojingHuangAa commented 3 months ago

Hello Sarath, thanks for you efforts to the issue #156 . I have reinstalled my atomRDF. However, I could not see the changes in structure.py (also in the repo) file and the repeated structures still can not be annotated. Could you please give me a few instructions of that. Thank you so much.

srmnitc commented 3 months ago

Thanks @GuojingHuangAa for raising this issue.

The code changes are made here

Could you please confirm whether you tested for bulk structures or grain boundaries. For bulk structures, repeated structures are annotated, either using:

from atomrdf import KnowledgeGraph, System
kg = KnowledgeGraph()
struct_Fe = System.create.element.Fe(graph=kg, repetitions=(3,4,4))

or calling struct_Fe.modify.repeat.

For GB structures, adding repetitions when creating the structure does not work at the moment. #155 would have to be solved first. However, the modify.repeat still works (add the correct triples, but creates multiple GBs which is maybe something you do not want).

If it does not work for you, please give a small example and I will take a look. Thanks again!

GuojingHuangAa commented 3 months ago

Hi Sarath, thanks so much for your reply. I thought the function didn't work because the repeated GB is not shown in kg.query_sample: I created gb like this:

gb = System.create.defect.grain_boundary(axis=[1,-1,0], sigma=3, gb_plane=[1,1,-2],
                                         element = 'Fe',
                                         structure = 'bcc',
                                         lattice_constant = 2.83441,
                                         uc_a=2, uc_b=2,
                                         overlap = 0.0,
                                         graph = kg)

and one sample is shown on the datafram with kg.query_sample:

res = kg.query_sample([kg.ontology.terms.pldo.SymmetricalTiltGrainBoundary, 
                     kg.ontology.terms.pldo.hasSigmaValue])
res

and I repeated the structure and queried again

gb2 = gb.modify.repeat(repetitions=(1,1,2))
res = kg.query_sample([kg.ontology.terms.pldo.SymmetricalTiltGrainBoundary, 
                     kg.ontology.terms.pldo.hasSigmaValue])
res

and there is still one sample shown on the dataframe But now I found that when I run kg.visualise(workflow_view=False, layout='dot', hide_types=False), two samples are visualized, so I think the repeated function is working well?

srmnitc commented 3 months ago

@GuojingHuangAa Thanks for the clarification. The repeat function is workin, but you have spotted another issue which also needs to be fixed. What is happening is that when the repeat function is called, it does create a new structure and annotate it as expected; but the GB related triples are not copied. Thanks for reporting this, I will fix it.