sensotwin.stress_selection.configuration

  1from .. import read_vtt, write_vtt
  2from ..store_connection import LocalStoreConnection, FusekiConnection, StoreConnection
  3from pyiron_base import HasHDF
  4import pandas as pd
  5import datetime
  6
  7class WindSpeedDataSet:
  8    """Data set containing information about wind speed and corresponding rotation speed and pitch angle of wind turbines.
  9
 10    expects vtk table structure according to following definition:
 11    
 12    "windspeed_mpers": float (wind speed in m/s)
 13    "pitch_angle_deg": float (pitch angle of individual blades in °, 0 = vertical)
 14    "rpm": float (rotations per minute)
 15    """
 16    NECESSARY_KEYS = ["windspeed_mpers", "pitch_angle_deg", "rpm"]
 17    def __init__(self, vtt_path: str):
 18        """Initialise data set from file and check if necessary columns are present.
 19
 20        Args:
 21            vtt_path: full or relative path of .vtt file containing cell information table
 22        """
 23        self._file_path = vtt_path
 24        self._dataframe = read_vtt.get_dataframe(self._file_path)
 25        self._dataframe["pitch_angle_deg"] = self._dataframe["pitch_angle_deg"].apply(lambda x: abs(x))
 26        self.check_data_source()
 27
 28    def get_data(self):
 29        """Return all wind speed data"""
 30        return self._dataframe
 31
 32    def get_single_entry(self, wind_speed: float) -> pd.DataFrame:
 33        """Return entry with chosen wind speed"""
 34        return self._dataframe.loc[self._dataframe.windspeed_mpers == wind_speed].iloc[0]
 35
 36    def check_data_source(self):
 37        """Check if data source contains all necessary keys.
 38        
 39        Raises:
 40            KeyError: If any key as defined in NECESSARY_KEYS is not found
 41        """
 42        for key in self.NECESSARY_KEYS:
 43            if key not in self._dataframe:
 44                raise KeyError("'{}' not found in input data '{}'".format(key, self._file_path))
 45
 46    def __str__(self):
 47        return "WindSpeedDataSet with {} entries from {} m/s to {} ms/s".format(len(self._dataframe),self._dataframe["windspeed_mpers"].min(), self._dataframe["windspeed_mpers"].max())
 48
 49    def __repr__(self):
 50        return self.__str__()
 51
 52
 53class StressStrainInputDataSet(HasHDF):
 54    """Input data set for future simulation containing operational parameters.
 55
 56    Contains relevant information of used wind profile like wind speed and rotations per minute in addition 
 57    to amount of the time simulation is supposed to run; implements pyiron HasHDF interface for automatic HDF5
 58    serialization during job execution for storage
 59    """
 60    def __init__(self, uniq_id: int=None, wind_speed: float=None, rotation_speed: float=None, pitch_angle: float=None, 
 61                 total_rotations: float=None, duration: float=None, conn: StoreConnection=None):
 62        """Initialize object.
 63        
 64        Args:
 65            uniq_id: id unique to the chosen store for this object class
 66            wind_speed: Wind speed in m/s
 67            rotation_speed: Rotation speed in rotations per minute
 68            pitch_angle: Pitch angle of wind turbine blades in ° (0 is vertical)
 69            total_rotations: Total number of rotations over the course of simulation (duration * rotation speed)
 70            duration: Total maximum duration of simulation in years
 71            conn: Any subclass instance of StoreConnection
 72        """
 73        self._id = uniq_id
 74        self._wind_speed = wind_speed
 75        self._rotation_speed = rotation_speed
 76        self._pitch_angle = pitch_angle
 77        self._total_rotations = total_rotations
 78        self._duration = duration
 79        self._store_connection = conn
 80
 81    def get_id(self) -> int:
 82        """Return id of object."""
 83        return self._id
 84
 85    def get_wind_speed(self) -> float:
 86        """Return wind speed in m/s of object."""
 87        return self._wind_speed
 88
 89    def get_rotation_speed(self) -> float:
 90        """Return rotations per minute of object."""
 91        return self._rotation_speed
 92
 93    def get_pitch_angle(self) -> float:
 94        """Return wind turbine blade pitch angle in ° of object."""
 95        return self._pitch_angle
 96
 97    def get_total_rotations(self) -> float:
 98        """Return total number of rotations of object."""
 99        return self._total_rotations
100
101    def get_duration(self) -> float:
102        """Return maximum duration of simulation."""
103        return self._duration
104
105    def generate_input_set_display_label(self) -> str:
106        """Return string display for object in list displays."""
107        return "Wind: {} m/s, {} rot/min, {} years".format(self._wind_speed, self._rotation_speed, self._duration)
108
109    @staticmethod
110    def get_id_from_ontology_iri(label: str) -> str:
111        """Extract id from full ontology instance iri."""
112        return int(label.split("_")[-1])
113
114    def generate_ontology_label(self) -> str:
115        """Generate ontology instance iri from object."""
116        return "__StressStrainInputDataSet_{}".format(self._id)
117
118    def save_entry_to_store(self):
119        """Save object to store connection passed during initialization."""
120        label = self.generate_ontology_label()
121        query = """
122            INSERT {{
123                senso:{label}_WindSpeed a senso:WindSpeed ;
124                    co:value {wind_speed} .
125                senso:{label}_WindRotationSpeed a senso:WindRotationSpeed ;
126                    co:value {rotation_speed} .
127                senso:{label}_WindPitchAngle a senso:WindPitchAngle ;
128                    co:value {pitch_angle} .
129                senso:{label}_WindTotalRotations a senso:WindTotalRotations ;
130                    co:value {total_rotations} .
131                senso:{label}_WindDuration a senso:WindDuration ;
132                    co:value {duration} .
133                  
134                senso:{label} a senso:WindDataSimulationInputSet ;
135                    co:composedOf senso:{label}_WindSpeed ;
136                    co:composedOf senso:{label}_WindRotationSpeed ;
137                    co:composedOf senso:{label}_WindPitchAngle ;
138                    co:composedOf senso:{label}_WindTotalRotations ;
139                    co:composedOf senso:{label}_WindDuration .
140            }} WHERE {{ }}
141            """.format(label=label, wind_speed=self._wind_speed, rotation_speed=self._rotation_speed, 
142                       pitch_angle=self._pitch_angle, total_rotations=self._total_rotations, duration=self._duration)
143        self._store_connection.update_data(query)
144
145    @staticmethod
146    def get_all_entries_from_store(conn: StoreConnection) -> dict:
147        """Get all instances of StressStrainInputDataSet from store connection passed during initialization.
148
149        Args:
150            conn: Any subclass instance of StoreConnection
151        Returns:
152            dict of int -> StressStrainInputDataSet
153        """
154        query = """
155            SELECT ?x ?windSpeed ?rotSpeed ?pitch ?totalRot ?duration
156            WHERE {
157                ?x a senso:WindDataSimulationInputSet .
158                {
159                    ?x co:composedOf ?speed_comp .
160                    ?speed_comp a senso:WindSpeed .
161                    ?speed_comp co:value ?windSpeed .
162                }
163                {
164                    ?x co:composedOf ?rotspeed_comp .
165                    ?rotspeed_comp a senso:WindRotationSpeed .
166                    ?rotspeed_comp co:value ?rotSpeed .
167                }
168                {
169                    ?x co:composedOf ?pitch_comp .
170                    ?pitch_comp a senso:WindPitchAngle .
171                    ?pitch_comp co:value ?pitch .
172                }
173                {
174                    ?x co:composedOf ?rot_comp .
175                    ?rot_comp a senso:WindTotalRotations .
176                    ?rot_comp co:value ?totalRot .
177                }
178                {
179                    ?x co:composedOf ?duration_comp .
180                    ?duration_comp a senso:WindDuration .
181                    ?duration_comp co:value ?duration .
182                }
183            }
184            """
185        result = {}
186        for x in conn.get_data(query):
187            uniq_id = StressStrainInputDataSet.get_id_from_ontology_iri(x[0])
188            result[uniq_id] = StressStrainInputDataSet(uniq_id=uniq_id, wind_speed=float(x[1]), rotation_speed=float(x[2]), 
189                                                      pitch_angle=float(x[3]), total_rotations=int(x[4]), duration=float(x[5]), conn=conn)
190        return result
191
192    def __str__(self):
193        return "ID: {}, Wind Speed: {} m/s, Rotations: {}/min, Pitch Angle: {}°, Total Rotations: {}, Duration: {}y, Source: {}".format(
194            self._id, self._wind_speed, self._rotation_speed, self._pitch_angle, self._total_rotations, self._duration, self._store_connection)
195
196    def __repr__(self):
197        return "StressStrainInputDataSet(uniq_id={uniq_id}, wind_speed={wind_speed}, rotation_speed={rotation_speed}, pitch_angle={pitch_angle}, total_rotations={total_rotations}, duration={duration}, conn={conn})".format(
198            uniq_id = self._id,
199            wind_speed = self._wind_speed,
200            rotation_speed = self._rotation_speed,
201            pitch_angle = self._pitch_angle,
202            total_rotations = self._total_rotations,
203            duration = self._duration,
204            conn = repr(self._store_connection)
205        )
206
207    def _to_hdf(self, hdf=None, group_name=None):
208        with hdf.open("stress_strain_input_data") as hdf_store:
209            hdf_store["_id"] = self._id
210            hdf_store["_wind_speed"] = self._wind_speed
211            hdf_store["_rotation_speed"] = self._rotation_speed
212            hdf_store["_pitch_angle"] = self._pitch_angle
213            hdf_store["_total_rotations"] = self._total_rotations
214            hdf_store["_duration"] = self._duration
215            hdf_store["_store_connection"] = repr(self._store_connection)
216
217    def _from_hdf(self, hdf=None, version=None):
218        pass
219
220    def from_hdf_args(hdf):
221        with hdf.open("stress_strain_input_data") as hdf_store:
222            arg_dict = {
223                "uniq_id": hdf_store["_id"],
224                "wind_speed": hdf_store["_wind_speed"],
225                "rotation_speed": hdf_store["_rotation_speed"],
226                "pitch_angle": hdf_store["_pitch_angle"],
227                "total_rotations": hdf_store["_total_rotations"],
228                "duration": hdf_store["_duration"],
229                "conn": eval(hdf_store["_store_connection"])
230            }
231        return arg_dict
class WindSpeedDataSet:
 8class WindSpeedDataSet:
 9    """Data set containing information about wind speed and corresponding rotation speed and pitch angle of wind turbines.
10
11    expects vtk table structure according to following definition:
12    
13    "windspeed_mpers": float (wind speed in m/s)
14    "pitch_angle_deg": float (pitch angle of individual blades in °, 0 = vertical)
15    "rpm": float (rotations per minute)
16    """
17    NECESSARY_KEYS = ["windspeed_mpers", "pitch_angle_deg", "rpm"]
18    def __init__(self, vtt_path: str):
19        """Initialise data set from file and check if necessary columns are present.
20
21        Args:
22            vtt_path: full or relative path of .vtt file containing cell information table
23        """
24        self._file_path = vtt_path
25        self._dataframe = read_vtt.get_dataframe(self._file_path)
26        self._dataframe["pitch_angle_deg"] = self._dataframe["pitch_angle_deg"].apply(lambda x: abs(x))
27        self.check_data_source()
28
29    def get_data(self):
30        """Return all wind speed data"""
31        return self._dataframe
32
33    def get_single_entry(self, wind_speed: float) -> pd.DataFrame:
34        """Return entry with chosen wind speed"""
35        return self._dataframe.loc[self._dataframe.windspeed_mpers == wind_speed].iloc[0]
36
37    def check_data_source(self):
38        """Check if data source contains all necessary keys.
39        
40        Raises:
41            KeyError: If any key as defined in NECESSARY_KEYS is not found
42        """
43        for key in self.NECESSARY_KEYS:
44            if key not in self._dataframe:
45                raise KeyError("'{}' not found in input data '{}'".format(key, self._file_path))
46
47    def __str__(self):
48        return "WindSpeedDataSet with {} entries from {} m/s to {} ms/s".format(len(self._dataframe),self._dataframe["windspeed_mpers"].min(), self._dataframe["windspeed_mpers"].max())
49
50    def __repr__(self):
51        return self.__str__()

Data set containing information about wind speed and corresponding rotation speed and pitch angle of wind turbines.

expects vtk table structure according to following definition:

"windspeed_mpers": float (wind speed in m/s) "pitch_angle_deg": float (pitch angle of individual blades in °, 0 = vertical) "rpm": float (rotations per minute)

WindSpeedDataSet(vtt_path: str)
18    def __init__(self, vtt_path: str):
19        """Initialise data set from file and check if necessary columns are present.
20
21        Args:
22            vtt_path: full or relative path of .vtt file containing cell information table
23        """
24        self._file_path = vtt_path
25        self._dataframe = read_vtt.get_dataframe(self._file_path)
26        self._dataframe["pitch_angle_deg"] = self._dataframe["pitch_angle_deg"].apply(lambda x: abs(x))
27        self.check_data_source()

Initialise data set from file and check if necessary columns are present.

Args: vtt_path: full or relative path of .vtt file containing cell information table

NECESSARY_KEYS = ['windspeed_mpers', 'pitch_angle_deg', 'rpm']
def get_data(self):
29    def get_data(self):
30        """Return all wind speed data"""
31        return self._dataframe

Return all wind speed data

def get_single_entry(self, wind_speed: float) -> pandas.core.frame.DataFrame:
33    def get_single_entry(self, wind_speed: float) -> pd.DataFrame:
34        """Return entry with chosen wind speed"""
35        return self._dataframe.loc[self._dataframe.windspeed_mpers == wind_speed].iloc[0]

Return entry with chosen wind speed

def check_data_source(self):
37    def check_data_source(self):
38        """Check if data source contains all necessary keys.
39        
40        Raises:
41            KeyError: If any key as defined in NECESSARY_KEYS is not found
42        """
43        for key in self.NECESSARY_KEYS:
44            if key not in self._dataframe:
45                raise KeyError("'{}' not found in input data '{}'".format(key, self._file_path))

Check if data source contains all necessary keys.

Raises: KeyError: If any key as defined in NECESSARY_KEYS is not found

class StressStrainInputDataSet(pyiron_base.interfaces.has_hdf.HasHDF):
 54class StressStrainInputDataSet(HasHDF):
 55    """Input data set for future simulation containing operational parameters.
 56
 57    Contains relevant information of used wind profile like wind speed and rotations per minute in addition 
 58    to amount of the time simulation is supposed to run; implements pyiron HasHDF interface for automatic HDF5
 59    serialization during job execution for storage
 60    """
 61    def __init__(self, uniq_id: int=None, wind_speed: float=None, rotation_speed: float=None, pitch_angle: float=None, 
 62                 total_rotations: float=None, duration: float=None, conn: StoreConnection=None):
 63        """Initialize object.
 64        
 65        Args:
 66            uniq_id: id unique to the chosen store for this object class
 67            wind_speed: Wind speed in m/s
 68            rotation_speed: Rotation speed in rotations per minute
 69            pitch_angle: Pitch angle of wind turbine blades in ° (0 is vertical)
 70            total_rotations: Total number of rotations over the course of simulation (duration * rotation speed)
 71            duration: Total maximum duration of simulation in years
 72            conn: Any subclass instance of StoreConnection
 73        """
 74        self._id = uniq_id
 75        self._wind_speed = wind_speed
 76        self._rotation_speed = rotation_speed
 77        self._pitch_angle = pitch_angle
 78        self._total_rotations = total_rotations
 79        self._duration = duration
 80        self._store_connection = conn
 81
 82    def get_id(self) -> int:
 83        """Return id of object."""
 84        return self._id
 85
 86    def get_wind_speed(self) -> float:
 87        """Return wind speed in m/s of object."""
 88        return self._wind_speed
 89
 90    def get_rotation_speed(self) -> float:
 91        """Return rotations per minute of object."""
 92        return self._rotation_speed
 93
 94    def get_pitch_angle(self) -> float:
 95        """Return wind turbine blade pitch angle in ° of object."""
 96        return self._pitch_angle
 97
 98    def get_total_rotations(self) -> float:
 99        """Return total number of rotations of object."""
100        return self._total_rotations
101
102    def get_duration(self) -> float:
103        """Return maximum duration of simulation."""
104        return self._duration
105
106    def generate_input_set_display_label(self) -> str:
107        """Return string display for object in list displays."""
108        return "Wind: {} m/s, {} rot/min, {} years".format(self._wind_speed, self._rotation_speed, self._duration)
109
110    @staticmethod
111    def get_id_from_ontology_iri(label: str) -> str:
112        """Extract id from full ontology instance iri."""
113        return int(label.split("_")[-1])
114
115    def generate_ontology_label(self) -> str:
116        """Generate ontology instance iri from object."""
117        return "__StressStrainInputDataSet_{}".format(self._id)
118
119    def save_entry_to_store(self):
120        """Save object to store connection passed during initialization."""
121        label = self.generate_ontology_label()
122        query = """
123            INSERT {{
124                senso:{label}_WindSpeed a senso:WindSpeed ;
125                    co:value {wind_speed} .
126                senso:{label}_WindRotationSpeed a senso:WindRotationSpeed ;
127                    co:value {rotation_speed} .
128                senso:{label}_WindPitchAngle a senso:WindPitchAngle ;
129                    co:value {pitch_angle} .
130                senso:{label}_WindTotalRotations a senso:WindTotalRotations ;
131                    co:value {total_rotations} .
132                senso:{label}_WindDuration a senso:WindDuration ;
133                    co:value {duration} .
134                  
135                senso:{label} a senso:WindDataSimulationInputSet ;
136                    co:composedOf senso:{label}_WindSpeed ;
137                    co:composedOf senso:{label}_WindRotationSpeed ;
138                    co:composedOf senso:{label}_WindPitchAngle ;
139                    co:composedOf senso:{label}_WindTotalRotations ;
140                    co:composedOf senso:{label}_WindDuration .
141            }} WHERE {{ }}
142            """.format(label=label, wind_speed=self._wind_speed, rotation_speed=self._rotation_speed, 
143                       pitch_angle=self._pitch_angle, total_rotations=self._total_rotations, duration=self._duration)
144        self._store_connection.update_data(query)
145
146    @staticmethod
147    def get_all_entries_from_store(conn: StoreConnection) -> dict:
148        """Get all instances of StressStrainInputDataSet from store connection passed during initialization.
149
150        Args:
151            conn: Any subclass instance of StoreConnection
152        Returns:
153            dict of int -> StressStrainInputDataSet
154        """
155        query = """
156            SELECT ?x ?windSpeed ?rotSpeed ?pitch ?totalRot ?duration
157            WHERE {
158                ?x a senso:WindDataSimulationInputSet .
159                {
160                    ?x co:composedOf ?speed_comp .
161                    ?speed_comp a senso:WindSpeed .
162                    ?speed_comp co:value ?windSpeed .
163                }
164                {
165                    ?x co:composedOf ?rotspeed_comp .
166                    ?rotspeed_comp a senso:WindRotationSpeed .
167                    ?rotspeed_comp co:value ?rotSpeed .
168                }
169                {
170                    ?x co:composedOf ?pitch_comp .
171                    ?pitch_comp a senso:WindPitchAngle .
172                    ?pitch_comp co:value ?pitch .
173                }
174                {
175                    ?x co:composedOf ?rot_comp .
176                    ?rot_comp a senso:WindTotalRotations .
177                    ?rot_comp co:value ?totalRot .
178                }
179                {
180                    ?x co:composedOf ?duration_comp .
181                    ?duration_comp a senso:WindDuration .
182                    ?duration_comp co:value ?duration .
183                }
184            }
185            """
186        result = {}
187        for x in conn.get_data(query):
188            uniq_id = StressStrainInputDataSet.get_id_from_ontology_iri(x[0])
189            result[uniq_id] = StressStrainInputDataSet(uniq_id=uniq_id, wind_speed=float(x[1]), rotation_speed=float(x[2]), 
190                                                      pitch_angle=float(x[3]), total_rotations=int(x[4]), duration=float(x[5]), conn=conn)
191        return result
192
193    def __str__(self):
194        return "ID: {}, Wind Speed: {} m/s, Rotations: {}/min, Pitch Angle: {}°, Total Rotations: {}, Duration: {}y, Source: {}".format(
195            self._id, self._wind_speed, self._rotation_speed, self._pitch_angle, self._total_rotations, self._duration, self._store_connection)
196
197    def __repr__(self):
198        return "StressStrainInputDataSet(uniq_id={uniq_id}, wind_speed={wind_speed}, rotation_speed={rotation_speed}, pitch_angle={pitch_angle}, total_rotations={total_rotations}, duration={duration}, conn={conn})".format(
199            uniq_id = self._id,
200            wind_speed = self._wind_speed,
201            rotation_speed = self._rotation_speed,
202            pitch_angle = self._pitch_angle,
203            total_rotations = self._total_rotations,
204            duration = self._duration,
205            conn = repr(self._store_connection)
206        )
207
208    def _to_hdf(self, hdf=None, group_name=None):
209        with hdf.open("stress_strain_input_data") as hdf_store:
210            hdf_store["_id"] = self._id
211            hdf_store["_wind_speed"] = self._wind_speed
212            hdf_store["_rotation_speed"] = self._rotation_speed
213            hdf_store["_pitch_angle"] = self._pitch_angle
214            hdf_store["_total_rotations"] = self._total_rotations
215            hdf_store["_duration"] = self._duration
216            hdf_store["_store_connection"] = repr(self._store_connection)
217
218    def _from_hdf(self, hdf=None, version=None):
219        pass
220
221    def from_hdf_args(hdf):
222        with hdf.open("stress_strain_input_data") as hdf_store:
223            arg_dict = {
224                "uniq_id": hdf_store["_id"],
225                "wind_speed": hdf_store["_wind_speed"],
226                "rotation_speed": hdf_store["_rotation_speed"],
227                "pitch_angle": hdf_store["_pitch_angle"],
228                "total_rotations": hdf_store["_total_rotations"],
229                "duration": hdf_store["_duration"],
230                "conn": eval(hdf_store["_store_connection"])
231            }
232        return arg_dict

Input data set for future simulation containing operational parameters.

Contains relevant information of used wind profile like wind speed and rotations per minute in addition to amount of the time simulation is supposed to run; implements pyiron HasHDF interface for automatic HDF5 serialization during job execution for storage

StressStrainInputDataSet( uniq_id: int = None, wind_speed: float = None, rotation_speed: float = None, pitch_angle: float = None, total_rotations: float = None, duration: float = None, conn: sensotwin.store_connection.StoreConnection = None)
61    def __init__(self, uniq_id: int=None, wind_speed: float=None, rotation_speed: float=None, pitch_angle: float=None, 
62                 total_rotations: float=None, duration: float=None, conn: StoreConnection=None):
63        """Initialize object.
64        
65        Args:
66            uniq_id: id unique to the chosen store for this object class
67            wind_speed: Wind speed in m/s
68            rotation_speed: Rotation speed in rotations per minute
69            pitch_angle: Pitch angle of wind turbine blades in ° (0 is vertical)
70            total_rotations: Total number of rotations over the course of simulation (duration * rotation speed)
71            duration: Total maximum duration of simulation in years
72            conn: Any subclass instance of StoreConnection
73        """
74        self._id = uniq_id
75        self._wind_speed = wind_speed
76        self._rotation_speed = rotation_speed
77        self._pitch_angle = pitch_angle
78        self._total_rotations = total_rotations
79        self._duration = duration
80        self._store_connection = conn

Initialize object.

Args: uniq_id: id unique to the chosen store for this object class wind_speed: Wind speed in m/s rotation_speed: Rotation speed in rotations per minute pitch_angle: Pitch angle of wind turbine blades in ° (0 is vertical) total_rotations: Total number of rotations over the course of simulation (duration * rotation speed) duration: Total maximum duration of simulation in years conn: Any subclass instance of StoreConnection

def get_id(self) -> int:
82    def get_id(self) -> int:
83        """Return id of object."""
84        return self._id

Return id of object.

def get_wind_speed(self) -> float:
86    def get_wind_speed(self) -> float:
87        """Return wind speed in m/s of object."""
88        return self._wind_speed

Return wind speed in m/s of object.

def get_rotation_speed(self) -> float:
90    def get_rotation_speed(self) -> float:
91        """Return rotations per minute of object."""
92        return self._rotation_speed

Return rotations per minute of object.

def get_pitch_angle(self) -> float:
94    def get_pitch_angle(self) -> float:
95        """Return wind turbine blade pitch angle in ° of object."""
96        return self._pitch_angle

Return wind turbine blade pitch angle in ° of object.

def get_total_rotations(self) -> float:
 98    def get_total_rotations(self) -> float:
 99        """Return total number of rotations of object."""
100        return self._total_rotations

Return total number of rotations of object.

def get_duration(self) -> float:
102    def get_duration(self) -> float:
103        """Return maximum duration of simulation."""
104        return self._duration

Return maximum duration of simulation.

def generate_input_set_display_label(self) -> str:
106    def generate_input_set_display_label(self) -> str:
107        """Return string display for object in list displays."""
108        return "Wind: {} m/s, {} rot/min, {} years".format(self._wind_speed, self._rotation_speed, self._duration)

Return string display for object in list displays.

@staticmethod
def get_id_from_ontology_iri(label: str) -> str:
110    @staticmethod
111    def get_id_from_ontology_iri(label: str) -> str:
112        """Extract id from full ontology instance iri."""
113        return int(label.split("_")[-1])

Extract id from full ontology instance iri.

def generate_ontology_label(self) -> str:
115    def generate_ontology_label(self) -> str:
116        """Generate ontology instance iri from object."""
117        return "__StressStrainInputDataSet_{}".format(self._id)

Generate ontology instance iri from object.

def save_entry_to_store(self):
119    def save_entry_to_store(self):
120        """Save object to store connection passed during initialization."""
121        label = self.generate_ontology_label()
122        query = """
123            INSERT {{
124                senso:{label}_WindSpeed a senso:WindSpeed ;
125                    co:value {wind_speed} .
126                senso:{label}_WindRotationSpeed a senso:WindRotationSpeed ;
127                    co:value {rotation_speed} .
128                senso:{label}_WindPitchAngle a senso:WindPitchAngle ;
129                    co:value {pitch_angle} .
130                senso:{label}_WindTotalRotations a senso:WindTotalRotations ;
131                    co:value {total_rotations} .
132                senso:{label}_WindDuration a senso:WindDuration ;
133                    co:value {duration} .
134                  
135                senso:{label} a senso:WindDataSimulationInputSet ;
136                    co:composedOf senso:{label}_WindSpeed ;
137                    co:composedOf senso:{label}_WindRotationSpeed ;
138                    co:composedOf senso:{label}_WindPitchAngle ;
139                    co:composedOf senso:{label}_WindTotalRotations ;
140                    co:composedOf senso:{label}_WindDuration .
141            }} WHERE {{ }}
142            """.format(label=label, wind_speed=self._wind_speed, rotation_speed=self._rotation_speed, 
143                       pitch_angle=self._pitch_angle, total_rotations=self._total_rotations, duration=self._duration)
144        self._store_connection.update_data(query)

Save object to store connection passed during initialization.

@staticmethod
def get_all_entries_from_store(conn: sensotwin.store_connection.StoreConnection) -> dict:
146    @staticmethod
147    def get_all_entries_from_store(conn: StoreConnection) -> dict:
148        """Get all instances of StressStrainInputDataSet from store connection passed during initialization.
149
150        Args:
151            conn: Any subclass instance of StoreConnection
152        Returns:
153            dict of int -> StressStrainInputDataSet
154        """
155        query = """
156            SELECT ?x ?windSpeed ?rotSpeed ?pitch ?totalRot ?duration
157            WHERE {
158                ?x a senso:WindDataSimulationInputSet .
159                {
160                    ?x co:composedOf ?speed_comp .
161                    ?speed_comp a senso:WindSpeed .
162                    ?speed_comp co:value ?windSpeed .
163                }
164                {
165                    ?x co:composedOf ?rotspeed_comp .
166                    ?rotspeed_comp a senso:WindRotationSpeed .
167                    ?rotspeed_comp co:value ?rotSpeed .
168                }
169                {
170                    ?x co:composedOf ?pitch_comp .
171                    ?pitch_comp a senso:WindPitchAngle .
172                    ?pitch_comp co:value ?pitch .
173                }
174                {
175                    ?x co:composedOf ?rot_comp .
176                    ?rot_comp a senso:WindTotalRotations .
177                    ?rot_comp co:value ?totalRot .
178                }
179                {
180                    ?x co:composedOf ?duration_comp .
181                    ?duration_comp a senso:WindDuration .
182                    ?duration_comp co:value ?duration .
183                }
184            }
185            """
186        result = {}
187        for x in conn.get_data(query):
188            uniq_id = StressStrainInputDataSet.get_id_from_ontology_iri(x[0])
189            result[uniq_id] = StressStrainInputDataSet(uniq_id=uniq_id, wind_speed=float(x[1]), rotation_speed=float(x[2]), 
190                                                      pitch_angle=float(x[3]), total_rotations=int(x[4]), duration=float(x[5]), conn=conn)
191        return result

Get all instances of StressStrainInputDataSet from store connection passed during initialization.

Args: conn: Any subclass instance of StoreConnection Returns: dict of int -> StressStrainInputDataSet

def from_hdf_args(hdf):
221    def from_hdf_args(hdf):
222        with hdf.open("stress_strain_input_data") as hdf_store:
223            arg_dict = {
224                "uniq_id": hdf_store["_id"],
225                "wind_speed": hdf_store["_wind_speed"],
226                "rotation_speed": hdf_store["_rotation_speed"],
227                "pitch_angle": hdf_store["_pitch_angle"],
228                "total_rotations": hdf_store["_total_rotations"],
229                "duration": hdf_store["_duration"],
230                "conn": eval(hdf_store["_store_connection"])
231            }
232        return arg_dict

Read arguments for instance creation from HDF5 file.

Args: hdf (ProjectHDFio): HDF5 group object

Returns: dict: arguments that can be **kwarg-passed to cls().

Inherited Members
pyiron_base.interfaces.has_hdf.HasHDF
from_hdf
to_hdf
rewrite_hdf