From 2b9ee49d74cf89bb07e2b798e6e391fd5ac724c6 Mon Sep 17 00:00:00 2001 From: Alvin Noe Ladines <ladinesalvinnoe@gmail.com> Date: Tue, 15 Sep 2020 21:35:09 +0200 Subject: [PATCH] Fixed bug when files not found --- elasticparser/elastic_parser.py | 11 +++++++++++ elasticparser/elastic_properties.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/elasticparser/elastic_parser.py b/elasticparser/elastic_parser.py index 9edd624..daaeb62 100644 --- a/elasticparser/elastic_parser.py +++ b/elasticparser/elastic_parser.py @@ -30,6 +30,10 @@ class ElasticParserInterface: if method == 'energy': strain, energy = self.properties.get_strain_energy() + if not strain: + self.logger.warn('Error getting strain and energy data') + return + n_strains = self.properties.info['n_strains'] sec_strain_diagram = sec_scc.m_create(x_elastic_section_strain_diagrams) @@ -45,6 +49,10 @@ class ElasticParserInterface: '5th': poly_fit_2 - 2, '6th': poly_fit_2 - 2, '7th': poly_fit_2 - 3} energy_fit = self.properties.get_energy_fit() + if not energy_fit: + self.logger.warn('Error getting energy fit data') + return + for diagram_type in ['cross-validation', 'd2e']: for fit_order in energy_fit[diagram_type][0].keys(): sec_strain_diagram = sec_scc.m_create(x_elastic_section_strain_diagrams) @@ -73,6 +81,9 @@ class ElasticParserInterface: stress_fit = self.properties.get_stress_fit() for diagram_type in ['cross-validation', 'dtn']: + if stress_fit.get(diagram_type, None) is None: + continue + for si in range(6): for fit_order in stress_fit[diagram_type][si][0].keys(): sec_strain_diagram = sec_scc.m_create(x_elastic_section_strain_diagrams) diff --git a/elasticparser/elastic_properties.py b/elasticparser/elastic_properties.py index 815c53c..4047b06 100644 --- a/elasticparser/elastic_properties.py +++ b/elasticparser/elastic_properties.py @@ -297,7 +297,7 @@ class ElasticProperties: quantities = [ Quantity( - 'voigt', r'Symmetry[\s\S]+\n\s*\n([C\d\s\n]+)\n', + 'voigt', r'Symmetry[\s\S]+\n\s*\n([C\d\s\n\(\)\-\+\/\*]+)\n', str_operation=reshape, dtype=str), Quantity( 'elastic_constant', r'Elastic constant[\s\S]+in GPa\s*:\s*\n\n([\-\d\.\s\n]+)\n', -- GitLab