Hello,
I am trying to develop a script to do some fatigue calculations, but I noticed something weird and wanted to investigate further.
Hi,
I noticed when I use a function from an imported user module, the result is for some reason different than if I run the same function from the module itself.
I have following code which is a part of a module I will import into the main script:
```
from module_base import * #This will import the Ansys.Mechanical.DataModel.Enums items
import math #another modules you are using in the project
def Initialize(MyExtAPI, MyAnsys):
global ExtAPI; global Ansys
ExtAPI = MyExtAPI; Ansys = MyAnsys
def CalculateFatigueLife_DNV_Test(stress_range, SN_Curve,thickness,SCF=1,ref_thickness=25):
m1=3
log_a1=12.192
m2=5
log_a2=16.32
k=0.05
trans=1000000
log_N=log_a1-m1*math.log10(stress_range*SCF*math.pow(thickness/ref_thickness,k))
N = math.pow(10,log_N)
if(N>trans):
log_N=log_a2-m2*math.log10(stress_range*SCF*math.pow(thickness/ref_thickness,k))
N = math.pow(10,log_N)
return N
print(CalculateFatigueLife_DNV_Test(334.7,"C CP",30,1,25))
import math
import Ansys.ACT.Math as math_ACT
import mech_dpf
import Ans.DataProcessing as dpf
import sys
CodePath = r"D:\ANSYS Scripts"
if not CodePath in sys.path:
sys.path.append(CodePath)
import FatigueFunctions as FF #module with fatigue calculations functions
reload(FF)
FF.Initialize(ExtAPI, Ansys)
print(FF.CalculateFatigueLife_DNV(334.7,"C CP",30,1,25))
print("Test: "+repr(FF.CalculateFatigueLife_DNV_Test(334.7,"C CP",30,1,25)))
FF.Initialize(ExtAPI, Ansys)
print("Test: "+repr(FF.CalculateFatigueLife_DNV_Test(334.7,"C CP",30,1,25)))
```
The code above prints: "Test: 41498.544"
I don't understand why when I call the function from the main code I get the different result from running the same function from the imported module. Is this a bug? Did anyone come across this before? My end plan here is to develop a module I can import into other scripts to carry out calculations etc.
Thanks
Running the main script yields the following message