DPF API in C#: ansys_unit_system_id values / custom unit system before h5 serialisation?
Hello,
When I am using a hdf5dpf_generate_result_file() operator, I can provide an id for the unit system via:
var h5WriteOperator = new hdf5dpf_generate_result_file(); h5WriteOperator.inputs.ansys_unit_system_id.Connect(id);
where id is some integer. I can't seem to find anywhere a list of the available systems and what id they correspond to, could you point me in the right direction please?
My own investigation, by varying this id, and then getting the unit system from the ResultInfo when reading a file back in, yielded the following:
There are some repeats, which I've tabbed out. I found that setting the id = 3, or id > 16 gives the following error:
Setting id = 4 actually causes a stack overflow to occur:
h5WriteOperator.inputs.ansys_unit_system_id.Connect(4); h5WriteOperator.Connect(4, "V"); h5WriteOperator.Connect(5, velocityFieldsContainer); h5WriteOperator.Run();
--> Stack Overflow.
Is there any way I can set up a custom unit system and connect this to the hdf5dpf_generate_result_file() operator before serialisation? For my application I just need to make sure the length and force units are set correctly before the file is serialised.
Many thanks,
Fran Rourke
Answers
-
For my application I just need to make sure the length and force units are set correctly before the file is serialised.
Hi Fran!
I suggest performing the conversion of values into the required unit system using UnitsManager (Ans.Core.dll).var l_mm = Ansys.Core.Units.UnitsManager.ConvertUnit(node.X, "m", "mm"); Or check out this function UnitsManager.ConvertToUnitSystem
0 -
@Ramdane , @Paul Profizi
Maybe you can help here?ansys_unit_system_id
is not documented.0 -
Hi @Fran.Rourke,
Thank you for raising this.
We took a look and indeed the Enum for available unit systems is missing in the C# API.
This will be fixed.
We also notified the maintainers of the operator that some unit systems cause errors or crashes. We will work on that too.You already exposed what the different unit systems IDs correspond to, and if you want to double check, we have its CPython exposure defined here.
As for your question on providing a custom unit system to the operator via a Mechanical Python script, I do not see a way to create a custom DPF unit system in Mechanical with the current API. @Ayush Kumar what do you think?
1 -
@Paul Profizi @Fran.Rourke
I don't think either that creating a customer unit system is exposed.0