ansys / pydpf-core

Data Processing Framework - Python Core
http://dpf.docs.pyansys.com/
MIT License
69 stars 25 forks source link

sqrt_fc issue and workarround #137

Open jlcuadros opened 2 years ago

jlcuadros commented 2 years ago

Hello There is no abs() nor sign() funtions, so I tried a workarround using sqr_fc and sqrt_fc but i think there is somethig wrong with sqrt_fc function:

Or am I missing something?

Thank you in advance and best regards

Jose Luis

Example:


>>> 
sq = dpf.operators.math.sqr_fc() 
sq.inputs.fields_container.Connect(sv_max)
aa=sq.outputs.fields_container.GetData()
op = dpf.operators.math.sqrt_fc(aa) 
op.inputs.fields_container.Connect(my_fields_container)
sv_maxa = op.outputs.fields_container.GetData()
>>> sv_max[0].Data
[-0.143837430514395, 0.0639757635071874,...
>>> aa[0].Data
[0.0206892064169835, 0.00409289831632757, ...
>>> sv_maxa[0].Data
[0.816496326286349, 1.22474414708361, ... #this is not correct we don not obatin abs(sv_max)!
>>> 
sq = dpf.operators.math.sqr_fc() 
sq.inputs.fields_container.Connect(sv_max)
bb=sq.outputs.fields_container.GetData()
op = dpf.operators.math.pow_fc() 
op.inputs.fields_container.Connect(bb)
op.inputs.factor.Connect(0.5)
sv_maxc = op.outputs.fields_container.GetData()
>>> bb[0].Data
[0.0206892064169835, 0.00409289831632757, ...
>>> 
sv_maxc[0].Data
[0.143837430514395, 0.0639757635071874, ... # this is correct: we obtain abs(sv_max)

Do you plan to add sign() and abs() functions in the future to this great tool?

akaszynski commented 2 years ago

Pinging @rlagha for follow-up.

rlagha commented 2 years ago

Hi @jlcuadros @akaszynski, this is the issues list that we are working on. I'll update you when this is fixed.