General utilities¶
Setup materials¶
This module contains functions that sets up material models
-
rollover.utils.setup_material_mod.add_material(the_model, material_spec, name)[source]¶ Add a material to the_model according to material_spec with name=name.
- Parameters
the_model (Model object (Abaqus)) – The model to which the sketch will be added
material_spec (dict) –
Dictionary containing the fields ‘material_model’ and ‘mpar’:
’material_model’: which material model to use, currently ‘elastic’, ‘chaboche’, and ‘user’ are supported.
’mpar’: Material parameters, please see function corresponding to ‘material_model’ below for detailed requirements
name (str (max len = 80)) – The name of the material
- Returns
None
- Return type
None
-
rollover.utils.setup_material_mod.setup_elastic(the_material, mpar)[source]¶ Setup elastic material behavior
- Parameters
the_material (Material object (Abaqus)) – The material to which elastic behavior will be added
mpar (dict) –
Dictionary containing the fields
’E’: Young’s modulus
’nu’: Poissons ratio
- Returns
None
- Return type
None
-
rollover.utils.setup_material_mod.setup_chaboche(the_material, mpar)[source]¶ Setup plastic material behavior with the chaboche model
- Parameters
the_material (Material object (Abaqus)) – The material to which elastic behavior will be added
mpar (dict) –
Dictionary containing the fields
’E’: Young’s modulus
’nu’: Poissons ratio
’Y0’: Initial yield limit
’Qinf’: Saturated isotropic yield limit increase
’biso’: Speed of saturation for isotropic hardening
’Cmod’: List of kinematic hardening modulii
’gamma’: List of kinematic saturation parameters
- Returns
None
- Return type
None
-
rollover.utils.setup_material_mod.setup_user(the_material, mpar)[source]¶ Setup user material behavior
- Parameters
the_material (Material object (Abaqus)) – The material to which elastic behavior will be added
mpar (dict) –
Dictionary containing the fields
’user_mpar_array’: List of user material parameters
’nstatv’: Number of state variables for user material model
- Returns
None
- Return type
None
Direct input file editing¶
This module enable direct editing of input keywords in the input file. Options not available in CAE can therefore be added via the scripting interface.
-
rollover.utils.inp_file_edit.add_at_end_of_cat(keyword_block, string_to_add, category, name)[source]¶ Add string_to_add just before the end of the category of type category with name name.
- Parameters
keyword_block (KeywordBlock object (Abaqus)) – The Abaqus keywordBlock that contains the keyword to be written to the input file
string_to_add (str) – The string to add to the input file
category (str) – The category to search for (E.g. Part, Step)
name (str) – The name of the category to find (E.g. Part1-1, Step-1)
- Returns
None
- Return type
None
-
rollover.utils.inp_file_edit.add_after(keyword_block, string_to_add, find_strings=None)[source]¶ Add string_to_add after the first line in to keyword_block that contains all strings in find_strings.
- Parameters
keyword_block (KeywordBlock object (Abaqus)) – The Abaqus keywordBlock that contains the keyword to be written to the input file
string_to_add (str) – The string to add to the input file
find_strings (list[ str ]) – List of strings that the line prior after which string_to_add should be added must contain. If find_strings = None, add in beginning of the input file
- Returns
None
- Return type
None
-
rollover.utils.inp_file_edit.add_before(keyword_block, string_to_add, find_strings=None)[source]¶ Add string_to_add before the first line in to keyword_block that contains all strings in find_strings.
- Parameters
keyword_block (KeywordBlock object (Abaqus)) – The Abaqus keywordBlock that contains the keyword to be written to the input file
string_to_add (str) – The string to add to the input file
find_strings (list[ str ]) – List of strings that the line prior after which string_to_add should be added must contain. If find_strings = None, add in beginning of the input file
- Returns
None
- Return type
None
-
rollover.utils.inp_file_edit.find_strings_in_iterable(iterable, find_strings, min_ind=0)[source]¶ Find the lowest index >= min_ind of a string in iterable that contains all strings in find_strings
- Parameters
iterable (An iterable of strings) – An iterable object containing strings. Must support iteration (i.e.
for item in iterable) and be subscriptable (i.e.iterable[3:]).find_strings – List of strings that the the item in iterable must contain to be found.
min_ind – The index from which the search will start
- Returns
None
- Return type
None
Naming module¶
Define names to be used throughout the code. All names that are referenced within multiple functions should be defined in this module. Recommended to import as “import naming_mod as names” Hence, the variables will not contain name, and will be written as e.g. names.step0
-
rollover.utils.naming_mod.cycle_str(cycle_nr)[source]¶ Get string format for cycle number, use to get consistency with how many zeros are padded. :param cycle_nr: The cycle number :type cycle_nr: int
- Returns
String with the cycle number
- Return type
str
-
rollover.utils.naming_mod.get_step_rolling(cycle_nr=1)[source]¶ Get the step name for rolling step in cycle cycle_nr :param cycle_nr: The cycle number :type cycle_nr: int
- Returns
The step name
- Return type
str
-
rollover.utils.naming_mod.get_step_return(cycle_nr=2)[source]¶ Get the step name for return step in cycle cycle_nr :param cycle_nr: The cycle number :type cycle_nr: int
- Returns
The step name
- Return type
str
Abaqus python general tools¶
-
rollover.utils.abaqus_python_tools.setup_log_file(log_file='abaqus_python.log')[source]¶ Create a new log file, use at beginning to avoid appending to old file. Not required, but makes log output more readable.
- Parameters
log_file (str) – path to log file
-
rollover.utils.abaqus_python_tools.log(message, log_file='abaqus_python.log')[source]¶ Write log message to STDOUT and logfile. If STDOUT redirected by Abaqus, also write to shell (otherwise it can be hidden)
- Parameters
message (str) – The message to write to log file/stdout
log_file (str) – Path to log file to append to. Created if non-existent.
- Returns
None
General python tools¶
General utility functions, that are kept here for convenience. If more functions that can be grouped are added, these may be collected in a new file instead.
-
rollover.utils.general.get_arguments(function, num_first=0)[source]¶ Given a function, return all its arguments and the mandatory arguments. This can be used to check **kwargs type of input. num_first skips the first num_first arguments (that are mandatory)
- Parameters
function (class 'function') – The function whose arguments should be obtained
num_first (int) – How many arguments to skip in the beginning
returns: Lists of all arguments and mandatory arguments rtype: list[ list[ str ] ]
-
rollover.utils.general.extract_function_args(function, arg_dict, num_first=0)[source]¶ Given a function and a dictionary containing possible arguments, return a new dictionary containing only the arguments accepted by the function (i.e. remove any keywords that are not arguments to the function). Doesn’t give an error if a mandatory argument is missing.
- Parameters
function (class 'function') – The function whose arguments should be obtained
arg_dict (dict) – Dictionary containing possible function arguments
num_first (int) – How many arguments to skip in the beginning
- Returns
Dictionary with acceptable function arguments
- Return type
dict
Python 2 enhanced support for json¶
Module for loading and saving using json. Simplifies syntax and removes unicode strings (converts to regular strings)
-
rollover.utils.json_io.save(filename, contents)[source]¶ Save contents to filename with the json file format
- Parameters
filename (str) – The name of the file to be saved
contents (dict) – Dictionary to be saved to json
- Returns
None
- Return type
None
-
rollover.utils.json_io.read(filename)[source]¶ Load contents from filename with the json file format
For Python 2, unicode strings within the loaded dictionary are converted to regular strings. (In Python 3 unicode is str)
- Parameters
filename (str) – The name of the file to be loaded
- Returns
Dictionary to be saved to json
- Rtype contents
dict
-
rollover.utils.json_io.u_to_str_in_dict(dict_to_convert)[source]¶ Convert unicode entries a dictionary
Unicode strings within the loaded dictionary are converted to regular strings. This is only required for Python 2.
- Parameters
filename (str) – The name of the file to be loaded
- Returns
Dictionary to be saved to json
- Rtype contents
dict