@@ -639,7 +639,65 @@ def _initialize_graph(self):
639639 (CMSO .Vector , CMSO .hasUnit , URIRef ("http://qudt.org/vocab/unit/ANGSTROM" ))
640640 )
641641
642- def add_calculated_quantity (self , sample , propertyname , value , unit = None ):
642+ def add_output_of_simulation (self , simulation_term ,
643+ value ,
644+ property_label ,
645+ base_quantity = None ,
646+ unit = None ,
647+ has_simulation_algorithm = None ,
648+ has_computational_method = None ):
649+ """
650+ Create a new output of simulation in the graph. The types of different terms are defined in the ontology.
651+ Those should be access by kg.terms.ontolog.ontology_term.
652+
653+ Parameters
654+ ----------
655+ simulation_term : OntoTerm
656+ The term representing the simulation.
657+
658+ value : float
659+ The value of the output.
660+
661+ property_label : str
662+ The label of the property.
663+
664+ base_quantity : OntoTerm, optional
665+ The base quantity of the output. Default is None.
666+
667+ unit : OntoTerm, optional
668+ The unit of the output. Default is None.
669+
670+
671+ has_simulation_algorithm : OntoTerm, optional
672+ The simulation algorithm used. Default is None.
673+
674+ has_computational_method : OntoTerm, optional
675+ The computational method used. Default is None.
676+
677+ Returns
678+ -------
679+ URIRef
680+ The newly created output of simulation.
681+
682+ """
683+ main_id = str (uuid .uuid4 ())
684+ simulation_node = self .create_node (f"simulation:{ main_id } " , simulation_term )
685+ if has_simulation_algorithm is not None :
686+ self .add ((simulation_node , ASMO .usesSimulationAlgorithm , has_simulation_algorithm ))
687+ if has_computational_method is not None :
688+ self .add ((simulation_node , ASMO .hasComputationalMethod , has_computational_method ))
689+ if base_quantity is None :
690+ base_quantity = ASMO .CalculatedProperty
691+ prop = self .create_node (f"simulation:{ main_id } _{ property_label } " , base_quantity )
692+ self .add ((prop , ASMO .wasCalculatedBy , simulation_node ))
693+ self .add ((prop , RDFS .label , Literal (property_label )))
694+ self .add ((prop , ASMO .hasValue , Literal (value )))
695+ if unit is not None :
696+ self .add ((prop , ASMO .hasUnit , unit ))
697+ return prop
698+
699+
700+ def add_calculated_quantity (self , sample , propertyname , value , base_quantity = None , unit = None ):
643701 """
644702 Add a calculated quantity to a sample.
645703
@@ -669,8 +727,10 @@ def add_calculated_quantity(self, sample, propertyname, value, unit=None):
669727 >>> sample = graph.create_node("Sample1", CMSO.Sample)
670728 >>> graph.add_calculated_quantity(sample, "energy", "10.5", "eV")
671729 """
730+ if base_quantity is None :
731+ base_quantity = ASMO .CalculatedProperty
672732
673- prop = self .create_node (f"{ sample } _{ propertyname } " , CMSO . CalculatedProperty )
733+ prop = self .create_node (f"{ sample } _{ propertyname } " , base_quantity )
674734 self .add ((sample , CMSO .hasCalculatedProperty , prop ))
675735 self .add ((prop , RDFS .label , Literal (propertyname )))
676736 self .add ((prop , ASMO .hasValue , Literal (value )))
0 commit comments