Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some issues regarding the use of pyvumat in Windows systems #1

Open
imyxc opened this issue May 20, 2024 · 38 comments
Open

Some issues regarding the use of pyvumat in Windows systems #1

imyxc opened this issue May 20, 2024 · 38 comments

Comments

@imyxc
Copy link

imyxc commented May 20, 2024

Your work is very commendable, but there are too many errors when running Abaqus using Windows system. Can you provide some simple examples for Windows system?

@jccrone
Copy link
Collaborator

jccrone commented Jun 18, 2024

Thank you for your interest in the code and I apologize for the delay in responding. I was trying to get access to Abaqus on a Windows machine, but I do not use Windows regularly, nor do I have access to one that has Abaqus on it. Could you provide an example of the errors you are receiving, perhaps they are not specific to Windows. Feel free to reach out via email, response times should be quicker.

@imyxc
Copy link
Author

imyxc commented Jul 11, 2024

Thank you very much for your reply. I will try to use Linux to configure the project in the future. If there are similar problems, I hope to obtain some answers from you.

@imyxc
Copy link
Author

imyxc commented Jul 12, 2024

I found that I couldn't find your contact information in the project. Can you provide an email so that I can contact you quickly?
Similarly, if possible, could you provide a specific Abaqus execution case to give us some guidance? Thank you very much for your reply, it will be of great help to us.

@jccrone
Copy link
Collaborator

jccrone commented Jul 12, 2024

It is harder to find within the user's guide than I thought. Please email me at joshua.crone.civ@army.mil and we can coordinate the best way to provide an example for Abaqus. Thanks.

@imyxc
Copy link
Author

imyxc commented Jul 17, 2024

I tried to compile it using the abaqus2024windows version, but I found that it still reported an error, which prompted me: End Compiling Single Precision Abaqus/Explicit User Subroutines
Begin Linking Single Precision Abaqus/Explicit User Subroutines
Creating library explict9.lib and object explict9.exp
Msvcrt.lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_initialize, referenced in function __scrt_initializes _crt
Msvcrt.lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_uninitialize, referenced in function __scrt_initialize
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_uninitialize_critical, referenced in function __scrt_dllmaain_uninitialize_critical
Msvcrt.lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_thread.attach, referenced in function __scrt_dllmaain_crt_thread.attach
Msvcrt.lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_thread_detach, referenced in function __scrt_dllmaain_crt_thread.attach
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol _is_c_terminal_complete, referenced in function __scrt_dllmain_uninitialize_c
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_initialize, referenced in function __scrt_initialize _crt
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_uninitialize, referenced in function __scrt_uninitiation_crt
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_uninitiation_critical, referenced in function __scrt_dllmain_uninitiation_critical
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_thread.attach, referenced in function __scrt_dllmaain_crt_thread.attach
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_thread_detach, referenced in function __scrt_dllmaain_crt_thread_detach
ExplicitU.dll: fatal error LNK1120: 11 unresolved external commands
Abaqus Error: Problem during linking - Single Precision Abaqus/Explicit User Subroutines.
This error may be due to a mismatch in the Abaqus user subroutine arguments.
These arguments sometimes change from release to release, so user subroutines
used with a previous release of Abaqus may need to be adjusted.
The Abaqus Make execution procedure exited with errors
I compiled using a basic umat.cpp and found no issues, which left me very confused. Is this a problem with Python?

@jccrone
Copy link
Collaborator

jccrone commented Jul 17, 2024

Unfortunately I am not familiar with running Abaqus on Windows or general c++ code compilation with Microsoft VS. What is in your local abaqus_v6.env file for 'compile_cpp' and 'link_sl'?

@imyxc
Copy link
Author

imyxc commented Jul 18, 2024

There should be no error in the configuration of 'compilale_cpp' and 'link_stl'. I followed the instructions to add the Python. h file directory and numpy directory. When compiling pyVUMAT.cpp, including<Python. h>, there was no error prompt,
I have some questions about this. If I add the directory where Abaqus installed Python. h and Numpy, where should I install PyTorch? Is it installed directly into the system environment? Or install it in the Python directory under the abaqus directory?

@jccrone
Copy link
Collaborator

jccrone commented Jul 18, 2024

The linking issue you are seeing would not be related to the PyTorch install (or any python package besides Numpy). I would like to see what commands are being called to compile and link the vumat. Can you provide 'compilale_cpp' and 'link_stl' or the output from Abaqus showing the commands for these steps?

To answer your question, which will be relevant after you get the vumat compiled:

I have been successful in creating a separate Python environment using conda and installing PyTorch there. This eliminates the need to install PyTorch in the Abaqus directory. You should make sure the version of Python is close to the version in the Abaqus build. For example, my Abaqus install uses Python3.10.5, so when I created my conda environment I specified 'python=3.10'. The actual version installed was 3.10.14, but that has not seemed to cause any issues.

Once you have your PyTorch install, you will want to ensure Python can find that path, as well as the path to the PyVUMAT modules. I do that by:

export PYTHONPATH=${PYVUMAT_DIR}:${HOME}/.conda/envs/pytorch3.10/lib/python3.10/site-packages:${PYTHONPATH}

where PYVUMAT_DIR is the top-level PyVUMAT directory, which should contain pyvumat/driver.py and
I've installed PyTorch in a conda environment called "pytorch3.10" in the directory '~/.conda/envs'. You should change the line based on your install directory and environment variable.

@imyxc
Copy link
Author

imyxc commented Jul 18, 2024

I'm very sorry, my Python version is incorrect, but I found that my Abauqs2022 has a built-in Python 3.7 folder. Does this mean that even Abaqus 2022 can use this program?

@imyxc
Copy link
Author

imyxc commented Jul 18, 2024

Uploading ac21bcea0e3e421401d18b0c0637afa.png…

@jccrone
Copy link
Collaborator

jccrone commented Jul 18, 2024

I am unable to view the png. Is it possible to copy the text into the comments?

@imyxc
Copy link
Author

imyxc commented Jul 18, 2024

Computer /usr/SIMULIA/Est...ucts/2022 /linux_a64 /tools / sMApy / python3.7;
In my abaqus installation path, there are both Python 2.7 and Python 3.7, both of which have Python. h header files. Does this mean that I can call pyVUMAT

@jccrone
Copy link
Collaborator

jccrone commented Jul 18, 2024

I had tried previously to use Python3 with older versions of Abaqus, but was unsuccessful. Despite that Python3 directory, my experience is that Abaqus still uses Python2 at runtime. I was unable to figure out how to force older Abaqus versions to use Python3 and the Abaqus support staff said Python3 is only available in the 2024 version. If you are going to use older versions of Abaqus, I would stick to Python packages that are compatible with Python2.

@imyxc
Copy link
Author

imyxc commented Jul 18, 2024

As you said, if I use Python 2 and PyTorch only supports Python on its own Does version 3.5 or above mean that I cannot use pyVUMAT on Abaqus 2022?

@jccrone
Copy link
Collaborator

jccrone commented Jul 18, 2024

I'm not sure what you are asking, but Abaqus 2022 runs Python2 and therefore any PyVUMAT model running on Abaqus 2022 must use Python2.

@imyxc
Copy link
Author

imyxc commented Jul 18, 2024

What I mean is that the deep learning module in pyVUMAT is built on PyTorch. However, PyTorch currently supports only Python 3.5 and above and does not support Python 2. Can we still use PyTorch with Python 2? Or do we need to independently construct a neural network model in Python 2 and complete its training and deployment?

@jccrone
Copy link
Collaborator

jccrone commented Jul 18, 2024

I have not used PyTorch with Python 2. I believe it is technically possible, but the version of PyTorch you need to use is quite old. If it is at all possible, I would recommend using Abaqus 2024.

@imyxc
Copy link
Author

imyxc commented Jul 18, 2024

This is unfortunate; I do not have the Linux version of Abaqus 2024, only the Windows version. Obtaining the Linux version might be difficult for me. Moreover, the Windows version of Abaqus cannot link to pyVUMAT, even though I have set Abaqus's Python as the PATH system variable. I believe there are many differences between the Windows and Linux versions of Abaqus. I will continue to try in hopes of achieving a better result.

@jccrone
Copy link
Collaborator

jccrone commented Jul 18, 2024

Yes, it is unfortunate that Abaqus did not convert to Python3 until this year.

I am willing to help you try to get PyVUMAT working with your Windows install. I can't promise we will get it working, but if we did, I imagine it would help other users in the future. To do so, I would need to see the commands Abaqus is calling for the compilation and linking in Windows.

@imyxc
Copy link
Author

imyxc commented Jul 18, 2024

Thank you very much. I am currently trying to use pyVUMAT on abaqus2024 for windows. windows version does not have libpython3.x.os file, it only has lib and dll files, I am trying to replace libpython3.x.os function, below I use compile_cpp and link_sl, in addition, I added the directory of the python310.dll dynamic library to the environment variable path, but unfortunately I failed. If you can provide some suggestions or comments, I would be very grateful!

compile_cpp='cl /c /W0 /MD /TP /EHsc /DNDEBUG /DWIN32 /DTP_IP /D_CONSOLE /DNTI /DFLT_LIC /DOL_DOC /D__LIB__ /DHKS_NT /D_WINDOWS_SOURCE /DFAR= /D_WINDOWS /DABQ_WIN86_64 %P /I%I /I"D:/abaqus" - I "D: / / win_b64 of abaqus/tools/SMApy/python3.10 / include" - I "D: / / win_b64 of abaqus/tools/SMApy/python3.10 / lib/site - packages/numpy/core/include" -I"D:/abaqus/SMABase/PublicInterfaces"'

link_sl='LINK /nologo /NOENTRY /INCREMENTAL:NO /subsystem:console /machine:AMD64 /NODEFAULTLIB:LIBC.LIB /NODEFAULTLIB:LIBCMT.LIB /DEFAULTLIB:OLDNAMES.LIB /DEFAULTLIB:LIBIFCOREMD.LIB /DEFAULTLIB:LIBIFPORTMD.LIB /DEFAULTLIB:LIBMMD.LIB /DEFAULTLIB:kernel32.lib /DEFAULTLIB:user32.lib /DEFAULTLIB:advapi32.lib /FIXED:NO /dll /def:%E /out:%U %F %A %L %B oldnames.lib user32.lib ws2_32.lib netapi32.lib advapi32.lib msvcrt.lib vcruntime.lib ucrt.lib / LIBPATH: "D: / / win_b64 of abaqus/tools/SMApy/python3.10 / libs"/DEFAULTLIB: python310. Lib '

Here's what I tried to run Times wrong:
Analysis initiated from SIMULIA established products
Abaqus JOB vumat1
Abaqus 2024
Abaqus License Manager checked out the following licenses:
Abaqus/Standard checked out 5 tokens from Flexnet server xxxxx
Begin Compiling Abaqus/Standard User Subroutines
7/19/2024 3:18:16 AM
Microsoft (R) C/C++ Optimization compiler for x64 version 19.36.32545
Copyright (C) Microsoft Corporation. All rights reserved.

pyVUMAT.cpp
End Compiling Abaqus/Standard User Subroutines
Begin Linking Abaqus/Standard User Subroutines
The library standardU.lib and object standardU.exp are being created
msvcrt.lib(utility.obj) : error LNK2019: cannot parse the external symbol __vcrt_initialize, which is referenced in the function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolvable external symbol __vcrt_uninitialize, which is referenced in function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: Unresolvable external symbol __vcrt_uninitialize_critical, which is referenced in function __scrt_dllmain_uninitialize_critical
msvcrt.lib(utility.obj) : error LNK2019: external symbol __vcrt_thread_attach that cannot be resolved. This symbol is referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: external symbol __vcrt_thread_detach that cannot be resolved. This symbol is referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: unparsed external symbol _is_c_termination_complete, which is referenced in function __scrt_dllmain_uninitialize_c
msvcrt.lib(utility.obj) : error LNK2019: external symbol __acrt_initialize that cannot be resolved, which is referenced in function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: external symbol __acrt_uninitialize that cannot be resolved, which is referenced in function __scrt_uninitialize_crt
msvcrt.lib(utility.obj) : error LNK2019: Unparsable external symbol __acrt_uninitialize_critical, referenced in function __scrt_dllmain_uninitialize_critical
msvcrt.lib(utility.obj) : error LNK2019: external symbol __acrt_thread_attach that cannot be resolved. This symbol is referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: cannot parse the external symbol __acrt_thread_detach, which is referenced in the function __scrt_dllmain_crt_thread_detach
standardU.dll: fatal error LNK1120: 11 external commands that cannot be resolved
Abaqus Error: Problem during linking - Abaqus/Standard User Subroutines.
This error may be due to a mismatch in the Abaqus user subroutine arguments.
These arguments sometimes change from release to release, so user subroutines
used with a previous release of Abaqus may need to be adjusted.
Abaqus/Analysis exited with errors

@jccrone
Copy link
Collaborator

jccrone commented Jul 18, 2024

It looks like you are using Abaqus/Standard. The VUMAT interface is separate from the UMAT interface. UMATs are for Abaqus/Standard and VUMATs are for Abaqus/Explicit. Therefore, PyVUMAT is used for Abaqus/Explicit. Please add the following lines in your input file, within the "STEP" block:

*DYNAMIC,EXPLICIT,DIRECT USER CONTROL
0.001,1.0

where the first number is the time step and the second is the total time. The provided example would simulate 1 unit of time in 1000 time steps. Adjust as necessary for your problem.

Also, if possible please add 'verbose=2' to your command line arguments to Abaqus. This should print the full commands Abaqus is using to compile pyVUMAT.cpp. Also, try adding 'double' to the command line so that double precision is used. I don't know that this will matter, but it will be consistent with how I run PyVUMAT in Abaqus.

@imyxc
Copy link
Author

imyxc commented Jul 18, 2024

I modified the code as you requested, and now I have a new error message:
Analysis initiated from SIMULIA established products
Abaqus JOB vumat
Abaqus 2024
USING MEMORY DOUG-LEA ALLOCATOR
DriverLM command: D:\abaqus\win_b64\code\bin\eliT_DriverLM.exe -job vumat -indir D:\abaqus\temp\PyVUMAT-main -explicit -verbose -tmpdir D:\abaqus\temp\22620_vumat_2520 -lmlog

Abaqus License Manager checked out the following licenses:
Abaqus/Explicit checked out 5 tokens from Flexnet server DESKTOP-RDM5J8D.
<9994 out of 9999 licenses remain available>.
DriverLM status: 0
Umbrella port: DESKTOP-RDM5J8D 51895
Platform: win86_64
Source extensions: f for f90 F90 c C c++ cpp
Object extension: obj
Shared library name: explicitU-D.dll
User subroutine archive file: explicitU-D_static.lib
Utility shared library file: explicitB-D
Threads Library: ABQSMAAbuBasicUtils
DMP Library: ABQMPI_api
MPI Libraries:
MPI Search Paths:
MPI Include Paths:
Found subroutine: vumat_
Found subroutine: vumat
Begin Compiling Double Precision Abaqus/Explicit User Subroutines
Compiling D:\abaqus\temp\PyVUMAT-main\pyVUMAT.cpp
Current directory: D:\abaqus\temp\22620_vumat_2520
File to compile: D:\abaqus\temp\22620_vumat_2520\pyVUMAT.cpp

cl /c /W0 /MD /TP /EHsc /DNDEBUG /DWIN32 /DTP_IP /D_CONSOLE /DNTI /DFLT_LIC /DOL_DOC /D__LIB__ /DHKS_NT /D_WINDOWS_SOURCE /DFAR= /D_WINDOWS /DABQ_WIN86_64 -DDPX /ID:\abaqus\temp\PyVUMAT-main /I"D:/abaqus" - I "D: / / win_b64 of abaqus/tools/SMApy/python3.10 / include" - I "D: / / win_b64 of abaqus/tools/SMApy/python3.10 / lib/site - packages/numpy/core/include" -i "D: / / SMABase of abaqus/PublicInterfaces" /I"." /I"D:\abaqus\win_b64\code\include" /I"D:\abaqus\win_b64.. \SMAUsubs\PublicInterfaces" pyVUMAT.cpp
Microsoft (R) C/C++ Optimization compiler for x64 version 19.36.32545
Copyright (C) Microsoft Corporation. All rights reserved.

pyVUMAT.cpp
End Compiling Double Precision Abaqus/Explicit User Subroutines
Begin Linking Double Precision Abaqus/Explicit User Subroutines
export.sym: vcosimulation
export.sym: vcosimulation0
export.sym: vdflux
export.sym: vdisp
export.sym: vdload
export.sym: vexternaldb
export.sym: vfabric
export.sym: vfilm
export.sym: vfric
export.sym: vfric_coef
export.sym: vfriction
export.sym: vhetval
export.sym: vsdvini
export.sym: vuamp
export.sym: vuanisohyper_inv
export.sym: vuanisohyper_strain
export.sym: vucharlength
export.sym: vucreepnetwork
export.sym: vuel
export.sym: vueos
export.sym: vueulgenprop
export.sym: vuexpan
export.sym: vufield
export.sym: vufluidexch
export.sym: vufluidexcheffarea
export.sym: vugens
export.sym: vuhard
export.sym: vuinflprop
export.sym: vuinter
export.sym: vuinter_cza
export.sym: vuinteraction
export.sym: vumat
export.sym: vumatht
export.sym: vumullins
export.sym: vuporepress
export.sym: vusdfld
export.sym: vusdfld_cza
export.sym: vusuperelashardmod
export.sym: vusuperelasplastmod
export.sym: vutemp
export.sym: vutrs
export.sym: vutrsnetwork
export.sym: vuviscosity
export.sym: vwave
export.sym: ? SMAUXpU_XP_finalize@@YAXAEAH@Z
export.sym: ? SMAUXpU_XP_initialize@@YAXAEAH@Z
export.sym: ? SMAUXpUsubs_XP_finalize@@YAXAEAH@Z
export.sym: ? SMAUXpUsubs_XP_initialize@@YAXAEAH@Z
export.sym: ? SMAUXpUsubs_XP_specific_finalize@@YAXAEAH@Z
export.sym: ? SMAUXpUsubs_XP_specific_initialize@@YAXAEAH@Z
export.sym: xplu_callallutils
export.sym: _forceCRTManifestCUR
Linking pyVUMAT.obj into user subroutine shared library explicitU-D.dll

LINK /nologo /NOENTRY /INCREMENTAL:NO /subsystem:console /machine:AMD64 /NODEFAULTLIB:LIBC.LIB /NODEFAULTLIB:LIBCMT.LIB /DEFAULTLIB:OLDNAMES.LIB /DEFAULTLIB:LIBIFCOREMD.LIB /DEFAULTLIB:LIBIFPORTMD.LIB /DEFAULTLIB:LIBMMD.LIB /DEFAULTLIB:kernel32.lib /DEFAULTLIB:user32.lib /DEFAULTLIB:advapi32.lib /FIXED:NO /dll /def:export.def /out:explicitU-D.dll pyVUMAT.obj "explicitU-D_static.lib" /LIBPATH:"D:\abaqus\win_b64\code\lib" ABQSMAShaShared-D.lib ABQSMAAspSupport.lib ABQSMAUsubsLib.lib ABQDMP_Core.lib ABQMPI_api.lib ABQSMAAbuBasicUtils.lib explicitB-D.lib ABQSMABasCoreUtils.lib ABQSMAEliLicenseModule.lib oldnames.lib user32.lib ws2_32.lib netapi32.lib Advapi32. The lib MSVCRT. Lib vcruntime. Lib ucrt. Lib/LIBPATH: D: / / win_b64 of abaqus/tools/SMApy python3.10 / libs /DEFAULTLIB:python310.lib
Creating library explicitU-D.lib and object explicitU-D.exp
msvcrt.lib(utility.obj) : error LNK2019: cannot parse the external symbol __vcrt_initialize, which is referenced in the function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolvable external symbol __vcrt_uninitialize, which is referenced in function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: Unresolvable external symbol __vcrt_uninitialize_critical, which is referenced in function __scrt_dllmain_uninitialize_critical
msvcrt.lib(utility.obj) : error LNK2019: external symbol __vcrt_thread_attach that cannot be resolved. This symbol is referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: external symbol __vcrt_thread_detach that cannot be resolved. This symbol is referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: unparsed external symbol _is_c_termination_complete, which is referenced in function __scrt_dllmain_uninitialize_c
msvcrt.lib(utility.obj) : error LNK2019: external symbol __acrt_initialize that cannot be resolved, which is referenced in function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: external symbol __acrt_uninitialize that cannot be resolved, which is referenced in function __scrt_uninitialize_crt
msvcrt.lib(utility.obj) : error LNK2019: Unparsable external symbol __acrt_uninitialize_critical, referenced in function __scrt_dllmain_uninitialize_critical
msvcrt.lib(utility.obj) : error LNK2019: external symbol __acrt_thread_attach that cannot be resolved. This symbol is referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: cannot parse the external symbol __acrt_thread_detach, which is referenced in the function __scrt_dllmain_crt_thread_detach
explicitU -d.ll: fatal error LNK1120: 11 external commands that cannot be resolved
Abaqus Error: Problem during linking - Double Precision Abaqus/Explicit User Subroutines.
This error may be due to a mismatch in the Abaqus user subroutine arguments.
These arguments sometimes change from release to release, so user subroutines
used with a previous release of Abaqus may need to be adjusted.
Exception: (<class 'driverExceptions.LinkError'>, LinkError('Double Precision Abaqus/Explicit User Subroutines'), <traceback object at 0x0000029EFD910740>)
Traceback (most recent call last):
File "SMAPylModules\SMAPylDriverPy.m\src\driverAnalysis.py", line 263, in run
File "SMAPylModules\SMAPylDriverPy.m\src\driverExplicit.py", line 144, in analyze
File "SMAPylModules\SMAPylDriverPy.m\src\driverSharedLibrary.py", line 402, in run
File "SMAPylModules\SMAPylDriverPy.m\src\driverSharedLibrary.py", line 779, in link
driverExceptions.LinkError: Double Precision Abaqus/Explicit User Subroutines
RESULTSFORMAT: ODB
SIMMODE: SFS
SIMEXT: .sim
Abaqus/Analysis exited with errors

@imyxc
Copy link
Author

imyxc commented Jul 19, 2024

This is all the operations I perform using Windows;
My conda environment is in E: \ anaconda \ envs \ pytorch
PATH
E:\abaqus2024\Products\win_b64\tools\SMApy\python3.10\include\Python.h
E:\abaqus2024\Products\win_b64\tools\SMApy\python3.10\lib\site-packages\numpy\core\include\numpy\arrayobject.h
E:\abaqus2024\Products\win_b64\code\bin\python310.dll
E:\abaqus2024\Products\win_b64\tools\SMApy\python3.10\python310.dll
E:\abaqus2024\Products\win_b64\tools\SMApy\python3.10\libs\python310.lib

compile_cpp='cl /c /W0 /MD /TP /EHsc /DNDEBUG /DWIN32 /DTP_IP /D_CONSOLE /DNTI /DFLT_LIC /DOL_DOC /D__LIB__ /DHKS_NT /D_WINDOWS_SOURCE /DFAR= /D_WINDOWS /DABQ_WIN86_64 %P /I%I /IE:/abaqus2024/Products /IE:/abaqus2024/Products/win_b64/tools/SMApy/python3.10/include /IE:/abaqus2024/Products/win_b64/tools/SMApy/python3.10/lib/site-packages/numpy/core/include'

link_sl='LINK /nologo /NOENTRY /INCREMENTAL:NO /subsystem:console /machine:AMD64 /NODEFAULTLIB:LIBC.LIB /NODEFAULTLIB:LIBCMT.LIB /DEFAULTLIB:OLDNAMES.LIB /DEFAULTLIB:LIBIFCOREMD.LIB /DEFAULTLIB:LIBIFPORTMD.LIB /DEFAULTLIB:LIBMMD.LIB /DEFAULTLIB:kernel32.lib /DEFAULTLIB:user32.lib /DEFAULTLIB:advapi32.lib /FIXED:NO /dll /def:%E /out:%U %F %A %L %B oldnames.lib user32.lib ws2_32.lib netapi32.lib advapi32.lib msvcrt.lib vcruntime.lib ucrt.lib /LIBPATH:"D:/abaqus/win_b64/tools/SMApy/python3.10/libs" /DEFAULTLIB:python310.lib'

Set PYTHONPATH, with the first being the pyvumat directory and the second being the path to packages such as pytorch:

set PYTHONPATH=E:\abaqus2024\temp\PyVUMAT-main;E:\anaconda\envs\pytorch\Lib\site-packages

At the same time, add the directory of python310.dll to the system variable path:

E:\abaqus2024\Products\win_b64\tools\SMApy\python3.10

Set configuration file:

set PYVUMAT_CONF_FILE=E:\abaqus2024\temp\PyVUMAT-main\pyvumat\svk\pyVumat_Conf_svkNN.ini

Execute program:

abaqus job=Job user=E:\abaqus2024\temp\PyVUMAT-main\pyvumat.cpp verbose=2 double

@jccrone
Copy link
Collaborator

jccrone commented Jul 19, 2024

I would like to confirm that the linking issue is related to Python and not other C++ libraries. Please copy the code below as a separate vumat and try running it with Abaqus to see if you can get past the compilation and linking. I have removed everything related to Python.

#include
#include
#include
#include

#if defined(ABQ_LINUX)
#include <aba_for_c.h>
#endif // ABQ_LINUX

namespace {
std::ofstream _logFile;
std::string _configFileName;
bool _isInitialized = false;

//
// Return a string to the ini config file
// Currently uses PYVUMAT_CONF_FILE environment variable
//
std::string
getConfFileName(std::ofstream & logFile)
{
std::string returnValue;

char const* tmpChar = getenv("PYVUMAT_CONF_FILE");
if ( tmpChar == NULL ) {
  
  //
  // Write warning that configure file was not found
  //
  std::stringstream message;
  message << "Error: Could not find the INI conf file."
      << "Make sure PYVUMAT_CONF_FILE environment variable "
      << " is set." << std::endl;
  logFile << message.str();
  returnValue.clear();
} else {

  //
  // Set the conf file name
  //
  returnValue = tmpChar;
}
return returnValue;

}
}

//
// VUMAT function called by FEM codes.
//
extern "C" void vumat_(
// Read only
const int *blockInfo, const int &ndir, const int &nshr, const int &nstatev,
const int &nfieldv, const int &nprops, const int &lanneal,
const double &stepTime, const double &totalTime, const double &dt,
const char *cmname, const double *coordMp, const double *charLength,
const double *props, const double *density, const double *strainInc,
const double *relSpinInc, const double *tempOld, const double *stretchOld,
const double *defgradOld, const double *fieldOld, const double *stressOld,
const double *stateOld, const double *enerInternOld,
const double *enerInelasOld, const double *tempNew, const double *stretchNew,
const double *defgradNew, const double *fieldNew,
// Write only
double *stressNew, double *stateNew, double *enerInternNew,
double *enerInelasNew )
{
//
// Perform initialization on the first step
//
if (!_isInitialized) {

//
// Create logging file
//
_logFile.open("vumat_c++.log",std::ofstream::app);
_logFile.precision(18);

//
// Get the INI configuration file
// 
_configFileName = getConfFileName(_logFile);

_isInitialized = true;

} /* End initialization */
return;
}

extern "C" void vumat(
// Read only
const int *blockInfo, const int &ndir, const int &nshr, const int &nstatev,
const int &nfieldv, const int &nprops, const int &lanneal,
const double &stepTime, const double &totalTime, const double &dt,
const char *cmname, const double *coordMp, const double *charLength,
const double *props, const double *density, const double *strainInc,
const double *relSpinInc, const double *tempOld, const double *stretchOld,
const double *defgradOld, const double *fieldOld, const double *stressOld,
const double *stateOld, const double *enerInternOld,
const double *enerInelasOld, const double *tempNew, const double *stretchNew,
const double *defgradNew, const double *fieldNew,
// Write only
double *stressNew, double *stateNew, double *enerInternNew,
double *enerInelasNew )
{
vumat_(blockInfo, ndir, nshr, nstatev,
nfieldv, nprops, lanneal,
stepTime, totalTime, dt,
cmname, coordMp, charLength,
props, density, strainInc,
relSpinInc, tempOld, stretchOld,
defgradOld, fieldOld, stressOld,
stateOld, enerInternOld,
enerInelasOld, tempNew, stretchNew,
defgradNew, fieldNew,
// Write only
stressNew, stateNew, enerInternNew,
enerInelasNew );
return;
}

@jccrone
Copy link
Collaborator

jccrone commented Jul 19, 2024

Looks like the include commands at the top of the code got partially stripped. They should read like this, but without spaces around the names of the headers:

#include < fstream >
#include < iostream >
#include < sstream >
#include < stdexcept >

@imyxc
Copy link
Author

imyxc commented Jul 19, 2024

Unfortunately, the error still exists when Python related parts are raised in a timely manner. I used a simple umat.cpp to execute without any problems. Do I need any corrections to the following code when using Windows?
#if defined(ABQ_LINUX)
#include<aba_for_c.h>
#endif // ABQ_LINUX

The following is the core information of the error message:
Linking test.obj into user subroutine shared library explicitU-D.dll

LINK /nologo /NOENTRY /INCREMENTAL:NO /subsystem:console /machine:AMD64 /NODEFAULTLIB:LIBC. LIB /NODEFAULTLIB:LIBCMT.LIB /DEFAULTLIB:OLDNAMES.LIB /DEFAULTLIB:LIBIFCOREMD.LIB /DEFAULTLIB:LIBIFPORTMD.LIB /DEFAULTLIB:LIBMMD.LIB /DEFAULTLIB:kernel32.lib /DEFAULTLIB:user32.lib /DEFAULTLIB:advapi32.lib /FIXED:NO /dll /def:export.def /out:explicitU-D.dll test.obj "explicitU-D_static.lib" /LIBPATH:"E:\abaqus2024\Products\win_b64\code\lib" ABQSMAShaShared-D.lib ABQSMAAspSupport.lib ABQSMAUsubsLib.lib ABQDMP_Core.lib ABQMPI_api.lib ABQSMAAbuBasicUtils.lib explicitB-D.lib ABQSMABasCoreUtils.lib ABQSMAEliLicenseModule.lib oldnames.lib user32.lib ws2_32.lib netapi32.lib advapi32.lib msvcrt.lib vcruntime.lib ucrt.lib /LIBPATH:E:/abaqus2024/Products/win_b64/tools/SMApy/python3.10/libs /DEFAULTLIB:python310.lib
Creating library explicitU-D-lib and object explicitU-D-exp
Msvcrt.lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_initialize, referenced in function __scrt_initializes _crt
Msvcrt.lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_uninitialize, referenced in function __scrt_initialize
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_uninitialize_critical, referenced in function __scrt_dllmaain_uninitialize_critical
Msvcrt.lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_thread.attach, referenced in function __scrt_dllmaain_crt_thread.attach
Msvcrt.lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_thread_detach, referenced in function __scrt_dllmaain_crt_thread.attach
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol _is_c_terminal_complete, referenced in function __scrt_dllmain_uninitialize_c
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_initialize, referenced in function __scrt_initialize _crt
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_uninitialize, referenced in function __scrt_uninitiation_crt
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_uninitiation_critical, referenced in function __scrt_dllmain_uninitiation_critical
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_thread.attach, referenced in function __scrt_dllmaain_crt_thread.attach
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_thread_detach, referenced in function __scrt_dllmaain_crt_thread_detach
ExplicitU-D-dll: fatal error LNK1120: 11 unresolved external commands
Abaqus Error: Problem during linking - Double Precision Abaqus/Explicit User Subroutines.
This error may be due to a mismatch in the Abaqus user subroutine arguments.
These arguments sometimes change from release to release, so user subroutines
used with a previous release of Abaqus may need to be adjusted.
Exception: (<class 'driverExceptions. LinkError'>, LinkError('Double Precision Abaqus/Explicit User Subroutines'), <traceback object at 0x000002B453A952C0>)
Traceback (most recent call last):
File "SMAPylModules\SMAPylDriverPy.m\src\driverAnalysis.py", line 263, in run
File "SMAPylModules\SMAPylDriverPy.m\src\driverExplicit.py", line 144, in analyze
File "SMAPylModules\SMAPylDriverPy.m\src\driverSharedLibrary.py", line 402, in run
File "SMAPylModules\SMAPylDriverPy.m\src\driverSharedLibrary.py", line 779, in link
driverExceptions.LinkError: Double Precision Abaqus/Explicit User Subroutines
RESULTSFORMAT: ODB
SIMMODE: SFS
SIMEXT: .sim
Abaqus/Analysis exited with errors

@imyxc
Copy link
Author

imyxc commented Jul 19, 2024

It seems that an error occurred during compilation, and I also encountered the same error when using abaqus make library=test.cpp

@imyxc
Copy link
Author

imyxc commented Jul 19, 2024

This is the executable Umat subroutine, and I have used it for calculations without any issues

#include
#include<omi_for_c.h>
extern "C" void FOR_NAME(umat, UMAT)(double* stress, double* statev, double* ddsdde, double* sse, double* spd,
double* scd, double* rpl, double* ddsddt, double* drplde, double* drpldt,
double* strain, double* dstrain, double* time, double* dtime, double* temp,
double* dtemp, double* predef, double* dpred, char* cmname, int* ndi,
int* nshr, int* ntens, int* nstatv, double* props, int* nprops,
double* coords, double* drot, double* pnewdt, double* celent, double* dfgrd0,
double* dfgrd1, int* noel, int* npt, int* layer, int* kspt,
int* jstep, int* kinc)
{
//get mat constants
if (nprops[0] < 2) return;
double E = props[0],v = props[1];
double G= E / (1 + v) / 2;
//Update stiffness matrix
double cfull[6][6]; memset(cfull, 0, sizeof(cfull));
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cfull[i][j] = E * v / (1 + v) / (1 - 2 * v);
}
cfull[i][i] = E * (1 - v) / (1 + v) / (1 - 2 * v);
cfull[i+3][i+3] = G;
}
//Update stress
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 6; j++)
{
stress[j] +=cfull[j][i] * dstrain[i];
}
}
//Update Jacobian matrix
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 6; j++)
{
ddsdde[6*i+j] = cfull[i][j];
}
}
return;
}

@jccrone
Copy link
Collaborator

jccrone commented Jul 19, 2024

You may be right about the aba_for_c.h, but let's first try removing all of the C++ features. Here is a test that only uses C. Please try running this code:

#include < stdio.h >
#include < stdlib.h >

#if defined(ABQ_LINUX)
#include <aba_for_c.h>
#endif // ABQ_LINUX

//
// VUMAT function called by FEM codes.
//
extern "C" void vumat_(
// Read only
const int *blockInfo, const int *ndirPtr, const int *nshrPtr, const int *nstatevPtr,
const int *nfieldvPtr, const int *npropsPtr, const int *lanneal,
const double *stepTime, const double *totalTime, const double *dt,
const char *cmname, const double *coordMp, const double *charLength,
const double *props, const double *density, const double *strainInc,
const double *relSpinInc, const double *tempOld, const double *stretchOld,
const double *defgradOld, const double *fieldOld, const double *stressOld,
const double *stateOld, const double *enerInternOld,
const double *enerInelasOld, const double *tempNew, const double *stretchNew,
const double *defgradNew, const double *fieldNew,
// Write only
double *stressNew, double *stateNew, double *enerInternNew,
double *enerInelasNew )
{

static FILE *_logFile;
static char *_configFileName;
static int _isInitialized = 0;

//
// Perform initialization on the first step
//
if (!_isInitialized) {

//
// Create logging file
//
_logFile = fopen("vumat_c.log","a");

//
// Get the INI configuration file
//
_configFileName = getenv("PYVUMAT_CONF_FILE");

if ( _configFileName == NULL ) {      
  //
  // Write warning that configure file was not found
  //
  fprintf(_logFile, "Error: Could not find the INI conf file.\n");
  fprintf(_logFile, "Make sure PYVUMAT_CONF_FILE environment variable is set.");
}

_isInitialized = 1;

} /* End initialization */

return;
}

extern "C" void vumat(
// Read only
const int *blockInfo, const int *ndir, const int *nshr, const int *nstatev,
const int *nfieldv, const int *nprops, const int *lanneal,
const double *stepTime, const double *totalTime, const double *dt,
const char *cmname, const double *coordMp, const double *charLength,
const double *props, const double *density, const double *strainInc,
const double *relSpinInc, const double *tempOld, const double *stretchOld,
const double *defgradOld, const double *fieldOld, const double *stressOld,
const double *stateOld, const double *enerInternOld,
const double *enerInelasOld, const double *tempNew, const double *stretchNew,
const double *defgradNew, const double *fieldNew,
// Write only
double *stressNew, double *stateNew, double *enerInternNew,
double *enerInelasNew )
{
vumat_(blockInfo, ndir, nshr, nstatev,
nfieldv, nprops, lanneal,
stepTime, totalTime, dt,
cmname, coordMp, charLength,
props, density, strainInc,
relSpinInc, tempOld, stretchOld,
defgradOld, fieldOld, stressOld,
stateOld, enerInternOld,
enerInelasOld, tempNew, stretchNew,
defgradNew, fieldNew,
// Write only
stressNew, stateNew, enerInternNew,
enerInelasNew );
return;
}

@imyxc
Copy link
Author

imyxc commented Jul 19, 2024

This seems to be no problem, using abaqu make library can compile, and at the same time, abaqus job=Job user=E: \ abaqus2024 \ temp \ PyVUMAT main \ test. cpp verbose=2 double also has almost no errors. Just my input file has some errors::

LINK /nologo /NOENTRY /INCREMENTAL:NO /subsystem:console /machine:AMD64 /NODEFAULTLIB:LIBC.LIB /NODEFAULTLIB:LIBCMT.LIB /DEFAULTLIB:OLDNAMES.LIB /DEFAULTLIB:LIBIFCOREMD.LIB /DEFAULTLIB:LIBIFPORTMD.LIB /DEFAULTLIB:LIBMMD.LIB /DEFAULTLIB:kernel32.lib /DEFAULTLIB:user32.lib /DEFAULTLIB:advapi32.lib /FIXED:NO /dll /def:export.def /out:explicitU-D.dll test.obj "explicitU-D_static.lib" /LIBPATH:"E:\abaqus2024\Products\win_b64\code\lib" ABQSMAShaShared-D.lib ABQSMAAspSupport.lib ABQSMAUsubsLib.lib ABQDMP_Core.lib ABQMPI_api.lib ABQSMAAbuBasicUtils.lib explicitB-D.lib ABQSMABasCoreUtils.lib ABQSMAEliLicenseModule.lib oldnames.lib user32.lib ws2_32.lib netapi32.lib advapi32.lib msvcrt.lib vcruntime.lib ucrt.lib /LIBPATH:E:/abaqus2024/Products/win_b64/tools/SMApy/python3.10/libs /DEFAULTLIB:python310.lib
creating explicitU-D.lib and explicitU-D.exp
End Linking Double Precision Abaqus/Explicit User Subroutines
7/19/2024 9:26:50 PM
Platform: win86_64
Source extensions: f for f90 F90 c C c++ cpp
Object extension: obj
Shared library name: explicitU.dll
User subroutine archive file: explicitU_static.lib
Utility shared library file: explicitB
Threads Library: ABQSMAAbuBasicUtils
DMP Library: ABQMPI_api
MPI Libraries:
MPI Search Paths:
MPI Include Paths:
Found subroutine: vumat_
Found subroutine: vumat
Begin Compiling Single Precision Abaqus/Package User Subroutines
7/19/2024 9:26:50 PM
Compiling E:\abaqus2024\temp\PyVUMAT-main\test.cpp
Current directory: C:\Users\Admin\AppData\Local\Temp\Admin_Job_14932
File to compile: C:\Users\Admin\AppData\Local\Temp\Admin_Job_14932\test.cpp

cl /c /W0 /MD /TP /EHsc /DNDEBUG /DWIN32 /DTP_IP /D_CONSOLE /DNTI /DFLT_LIC /DOL_DOC /D__LIB__ /DHKS_NT /D_WINDOWS_SOURCE /DFAR= /D_WINDOWS /DABQ_WIN86_64 /IE:\abaqus2024\temp\PyVUMAT-main /IE:/abaqus2024/Products /IE:/abaqus2024/Products/win_b64/tools/SMApy/python3.10/include /IE:/abaqus2024/Products/win_b64/tools/SMApy/python3.10/lib/site-packages/numpy/core/include /I"." /I"E:\abaqus2024\Products\win_b64\code\include" /I"E:\abaqus2024\Products\win_b64..\SMAUsubs\PublicInterfaces" test.cpp
....
....
LINK /nologo /NOENTRY /INCREMENTAL:NO /subsystem:console /machine:AMD64 /NODEFAULTLIB:LIBC.LIB /NODEFAULTLIB:LIBCMT.LIB /DEFAULTLIB:OLDNAMES.LIB /DEFAULTLIB:LIBIFCOREMD.LIB /DEFAULTLIB:LIBIFPORTMD.LIB /DEFAULTLIB:LIBMMD.LIB /DEFAULTLIB:kernel32.lib /DEFAULTLIB:user32.lib /DEFAULTLIB:advapi32.lib /FIXED:NO /dll /def:export.def /out:explicitU.dll test.obj "explicitU_static.lib" /LIBPATH:"E:\abaqus2024\Products\win_b64\code\lib" ABQSMAShaShared-D.lib ABQSMAAspSupport.lib ABQSMAUsubsLib.lib ABQDMP_Core.lib ABQMPI_api.lib ABQSMAAbuBasicUtils.lib explicitB.lib ABQSMABasCoreUtils.lib ABQSMAEliLicenseModule.lib oldnames.lib user32.lib ws2_32.lib netapi32.lib advapi32.lib msvcrt.lib vcruntime.lib ucrt.lib /LIBPATH:E:/abaqus2024/Products/win_b64/tools/SMApy/python3.10/libs /DEFAULTLIB:python310.lib
create explicitU.lib and obj explicitU.exp
End Linking Single Precision Abaqus/Package User Subroutines
7/19/2024 9:26:51 PM
Begin Analysis Input File Processor
7/19/2024 9:26:51 PM
Run pre.exe
Command: E:\abaqus2024\Products\win_b64\code\bin\pre.exe -explicit -messaging_mechanism DIRECT -job Job -indir E:\abaqus2024\temp\PyVUMAT-main -outdir E:\abaqus2024\temp\PyVUMAT-main -tmpdir C:\Users\Admin\AppData\Local\Temp\Admin_Job_14932 -inputFormat inp -resultsFormat odb -memory 64 -memory_parameter AUTOMATIC -sim E:\abaqus2024\temp\PyVUMAT-main\Job.sim -simwrk E:\abaqus2024\temp\PyVUMAT-main\Job -input Job -mp_mode THREADS -feature_enhanced -odb_output_requested -convert_sdi -umbrella_host PS2022BFHPMJZI -umbrella_port 56045 -dmp_solver -std_parallel -timeout 36000 -auto_calc_analysis
7/19/2024 9:26:56 PM
Phase Analysis Input File Processor status 1
File E:\abaqus2024\temp\PyVUMAT-main\Job.cid removed sucessfully.
Abaqus Error: Analysis Input File Processor exited with an error - Please see the
Job.dat file for possible error messages if the file exists.
Exception: (<class 'driverExceptions.AbaqusExecutionError'>, AbaqusExecutionError('Analysis Input File Processor', 1, 'Job'), <traceback object at 0x000002208DB9C200>)
Traceback (most recent call last):
File "SMAPylModules\SMAPylDriverPy.m\src\driverAnalysis.py", line 263, in run
File "SMAPylModules\SMAPylDriverPy.m\src\driverExplicit.py", line 200, in analyze
File "SMAPylModules\SMAPylDriverPy.m\src\driverExplicit.py", line 248, in runPre
File "SMAPylModules\SMAPylDriverPy.m\src\driverPhase.py", line 575, in run
File "SMAPylModules\SMAPylDriverPy.m\src\driverPhase.py", line 567, in _run
driverExceptions.AbaqusExecutionError: ('Analysis Input File Processor', 1, 'Job')
RESULTSFORMAT: ODB
SIMMODE: SFS
SIMEXT: .sim
Abaqus/Analysis exited with errors

@jccrone
Copy link
Collaborator

jccrone commented Jul 19, 2024

Well that is progress at least. Could you please try the previous C++ code again but I've changed the abaqus header (aba_for_c.h -> omi_for_c.h) and added FOR_NAME as you did in your UMAT. Note the extra spaces I had to include in the #include lines just to ensure GitHub does not remove them.

#include < fstream >
#include < iostream >
#include < sstream >
#include < stdexcept >

#include < omi_for_c.h >

namespace {
std::ofstream _logFile;
std::string _configFileName;
bool _isInitialized = false;

//
// Return a string to the ini config file
// Currently uses PYVUMAT_CONF_FILE environment variable
//
std::string
getConfFileName(std::ofstream & logFile)
{
std::string returnValue;

char const* tmpChar = getenv("PYVUMAT_CONF_FILE");
if ( tmpChar == NULL ) {
  
  //
  // Write warning that configure file was not found
  //
  std::stringstream message;
  message << "Error: Could not find the INI conf file."
      << "Make sure PYVUMAT_CONF_FILE environment variable "
      << " is set." << std::endl;
  logFile << message.str();
  returnValue.clear();
} else {

  //
  // Set the conf file name
  //
  returnValue = tmpChar;
}

return returnValue;

}

}

//
// VUMAT function called by FEM codes.
//
extern "C" void FOR_NAME(vumat, VUMAT)(
// Read only
const int *blockInfo, const int &ndir, const int &nshr, const int &nstatev,
const int &nfieldv, const int &nprops, const int &lanneal,
const double &stepTime, const double &totalTime, const double &dt,
const char *cmname, const double *coordMp, const double *charLength,
const double *props, const double *density, const double *strainInc,
const double *relSpinInc, const double *tempOld, const double *stretchOld,
const double *defgradOld, const double *fieldOld, const double *stressOld,
const double *stateOld, const double *enerInternOld,
const double *enerInelasOld, const double *tempNew, const double *stretchNew,
const double *defgradNew, const double *fieldNew,
// Write only
double *stressNew, double *stateNew, double *enerInternNew,
double *enerInelasNew )
{

//
// Perform initialization on the first step
//
if (!_isInitialized) {

//
// Create logging file
//
_logFile.open("vumat_c++.log",std::ofstream::app);
_logFile.precision(18);

//
// Get the INI configuration file
// 
_configFileName = getConfFileName(_logFile);

_isInitialized = true;

} /* End initialization */

return;
}

@imyxc
Copy link
Author

imyxc commented Jul 19, 2024

The problem seems to be here, an error occurred in this step, and the error message is similar to the previous one, which also cannot be compiled using abaqus make library.

Analysis initiated from SIMULIA established products
Abaqus JOB Job
Abaqus 2024
NOTE: "E:\abaqus2024\temp\usub" has been added to library search path
USING MEMORY DOUG-LEA ALLOCATOR
DriverLM command: E:\abaqus2024\Products\win_b64\code\bin\eliT_DriverLM.exe -job Job -indir E:\abaqus2024\temp\PyVUMAT-main -explicit -verbose -tmpdir C:\Users\Admin\AppData\Local\Temp\Admin_Job_15288 -lmlog
Checkout succeeded: explicit/EED04CCE516A
Abaqus License Manager checked out the following licenses:
Abaqus/Explicit checked out 5 tokens from Flexnet server PS2022BFHPMJZI.
<9994 out of 9999 licenses remain available>.
DriverLM status: 0
Umbrella port: PS2022BFHPMJZI 56696
Platform: win86_64
Source extensions: f for f90 F90 c C c++ cpp
Object extension: obj
Shared library name: explicitU-D.dll
User subroutine archive file: explicitU-D_static.lib
Utility shared library file: explicitB-D
Threads Library: ABQSMAAbuBasicUtils
DMP Library: ABQMPI_api
MPI Libraries:
MPI Search Paths:
MPI Include Paths:
Found subroutine: vumat
Begin Compiling Double Precision Abaqus/Explicit User Subroutines
Compiling E:\abaqus2024\temp\PyVUMAT-main\test.cpp
Current directory: C:\Users\Admin\AppData\Local\Temp\Admin_Job_15288
File to compile: C:\Users\Admin\AppData\Local\Temp\Admin_Job_15288\test.cpp

cl /c /W0 /MD /TP /EHsc /DNDEBUG /DWIN32 /DTP_IP /D_CONSOLE /DNTI /DFLT_LIC /DOL_DOC /D__LIB__ /DHKS_NT /D_WINDOWS_SOURCE /DFAR= /D_WINDOWS /DABQ_WIN86_64 -DDPX /IE:\abaqus2024\temp\PyVUMAT-main /IE:/abaqus2024/Products /IE:/abaqus2024/Products/win_b64/tools/SMApy/python3.10/include /IE:/abaqus2024/Products/win_b64/tools/SMApy/python3.10/lib/site-packages/numpy/core/include /I"." /I"E:\abaqus2024\Products\win_b64\code\include" /I"E:\abaqus2024\Products\win_b64..\SMAUsubs\PublicInterfaces" test.cpp
Microsoft (R) C/C++Optimized Compiler for x64 version 19.40.33808
Copyright (C) Microsoft Corporation. All rights reserved.

test.cpp
End Compiling Double Precision Abaqus/Explicit User Subroutines
Begin Linking Double Precision Abaqus/Explicit User Subroutines
export.sym: vcosimulation
export.sym: vcosimulation0
export.sym: vdflux
export.sym: vdisp
export.sym: vdload
export.sym: vexternaldb
export.sym: vfabric
export.sym: vfilm
export.sym: vfric
export.sym: vfric_coef
export.sym: vfriction
export.sym: vhetval
export.sym: vsdvini
export.sym: vuamp
export.sym: vuanisohyper_inv
export.sym: vuanisohyper_strain
export.sym: vucharlength
export.sym: vucreepnetwork
export.sym: vuel
export.sym: vueos
export.sym: vueulgenprop
export.sym: vuexpan
export.sym: vufield
export.sym: vufluidexch
export.sym: vufluidexcheffarea
export.sym: vugens
export.sym: vuhard
export.sym: vuinflprop
export.sym: vuinter
export.sym: vuinter_cza
export.sym: vuinteraction
export.sym: vumat
export.sym: vumatht
export.sym: vumullins
export.sym: vuporepress
export.sym: vusdfld
export.sym: vusdfld_cza
export.sym: vusuperelashardmod
export.sym: vusuperelasplastmod
export.sym: vutemp
export.sym: vutrs
export.sym: vutrsnetwork
export.sym: vuviscosity
export.sym: vwave
export.sym: ?SMAUXpU_XP_finalize@@ YAXAEAH@Z
export.sym: ?SMAUXpU_XP_initialize@@ YAXAEAH@Z
export.sym: ?SMAUXpUsubs_XP_finalize@@ YAXAEAH@Z
export.sym: ?SMAUXpUsubs_XP_initialize@@ YAXAEAH@Z
export.sym: ?SMAUXpUsubs_XP_specific_finalize@@ YAXAEAH@Z
export.sym: ?SMAUXpUsubs_XP_specific_initialize@@ YAXAEAH@Z
export.sym: xplu_callallutils
export.sym: _forceCRTManifestCUR
Linking test.obj into user subroutine shared library explicitU-D.dll

LINK /nologo /NOENTRY /INCREMENTAL:NO /subsystem:console /machine:AMD64 /NODEFAULTLIB:LIBC. LIB /NODEFAULTLIB:LIBCMT.LIB /DEFAULTLIB:OLDNAMES.LIB /DEFAULTLIB:LIBIFCOREMD.LIB /DEFAULTLIB:LIBIFPORTMD.LIB /DEFAULTLIB:LIBMMD.LIB /DEFAULTLIB:kernel32.lib /DEFAULTLIB:user32.lib /DEFAULTLIB:advapi32.lib /FIXED:NO /dll /def:export.def /out:explicitU-D.dll test.obj "explicitU-D_static.lib" /LIBPATH:"E:\abaqus2024\Products\win_b64\code\lib" ABQSMAShaShared-D.lib ABQSMAAspSupport.lib ABQSMAUsubsLib.lib ABQDMP_Core.lib ABQMPI_api.lib ABQSMAAbuBasicUtils.lib explicitB-D.lib ABQSMABasCoreUtils.lib ABQSMAEliLicenseModule.lib oldnames.lib user32.lib ws2_32.lib netapi32.lib advapi32.lib msvcrt.lib vcruntime.lib ucrt.lib /LIBPATH:E:/abaqus2024/Products/win_b64/tools/SMApy/python3.10/libs /DEFAULTLIB:python310.lib
Creating library explicitU-D-lib and object explicitU-D-exp
Msvcrt.lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_initialize, referenced in function __scrt_initializes _crt
Msvcrt.lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_uninitialize, referenced in function __scrt_initialize
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_uninitialize_critical, referenced in function __scrt_dllmaain_uninitialize_critical
Msvcrt.lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_thread.attach, referenced in function __scrt_dllmaain_crt_thread.attach
Msvcrt.lib (utility. obj): error LNK2019: Unresolvable external symbol __vcrt_thread_detach, referenced in function __scrt_dllmaain_crt_thread.attach
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol _is_c_terminal_complete, referenced in function __scrt_dllmain_uninitialize_c
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_initialize, referenced in function __scrt_initialize _crt
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_uninitialize, referenced in function __scrt_uninitiation_crt
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_uninitiation_critical, referenced in function __scrt_dllmain_uninitiation_critical
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_thread.attach, referenced in function __scrt_dllmaain_crt_thread.attach
Msvcrt. lib (utility. obj): error LNK2019: Unresolvable external symbol __acrt_thread_detach, referenced in function __scrt_dllmaain_crt_thread_detach
ExplicitU-D-dll: fatal error LNK1120: 11 unresolved external commands
Abaqus Error: Problem during linking - Double Precision Abaqus/Explicit User Subroutines.
This error may be due to a mismatch in the Abaqus user subroutine arguments.
These arguments sometimes change from release to release, so user subroutines
used with a previous release of Abaqus may need to be adjusted.
Exception: (<class 'driverExceptions. LinkError'>, LinkError('Double Precision Abaqus/Explicit User Subroutines'), <traceback object at 0x000002327F26E2C0>)
Traceback (most recent call last):
File "SMAPylModules\SMAPylDriverPy.m\src\driverAnalysis.py", line 263, in run
File "SMAPylModules\SMAPylDriverPy.m\src\driverExplicit.py", line 144, in analyze
File "SMAPylModules\SMAPylDriverPy.m\src\driverSharedLibrary.py", line 402, in run
File "SMAPylModules\SMAPylDriverPy.m\src\driverSharedLibrary.py", line 779, in link
driverExceptions.LinkError: Double Precision Abaqus/Explicit User Subroutines
RESULTSFORMAT: ODB
SIMMODE: SFS
SIMEXT: .sim
Abaqus/Analysis exited with errors

@jccrone
Copy link
Collaborator

jccrone commented Jul 19, 2024

Hmm...unfortunately I don't know anything about C++ compatibility on Windows, so without the ability to reproduce the error, I won't be able to figure out which C++ functionality is triggering this error. I can rewrite the pyVUMAT.cpp file to only use standard C, but it will take some time to implement, test across the various codes we use, and get it approved for public release by my organization. It will likely be a month or so before it would be ready to share. I understand if that is too long for your research needs.

@imyxc
Copy link
Author

imyxc commented Jul 19, 2024

Thank you very much for your help. I think if you can implement pyVUMAT using standard C, your work will help more people. As far as I know, most universities and individuals cannot obtain the free Linux version of abaqus2024, and Windows is still the first choice for non computer majors to use abaqus. If this job can be used on Windows, it will significantly enhance its influence.

@jccrone
Copy link
Collaborator

jccrone commented Jul 19, 2024

Yes, I agree. Thank you for the insight. It should not be hard to do, it will just take time to get it approved to share. When it is ready, I will reach out for you to test before pushing it to the repository. Expect to hear from me in a month, maybe sooner if the process moves quicker.

@imyxc
Copy link
Author

imyxc commented Jul 19, 2024

Thank you very much for your efforts. Your work may help a considerable number of students like me.

@jccrone
Copy link
Collaborator

jccrone commented Sep 12, 2024

Version 2.0 of PyVUMAT has been pushed to the repo. The C++ functionality has been removed. Based on preliminary testing, this should eliminate the issues you were seeing on Windows. But if any users continue to encounter issues, please reach out.

@imyxc
Copy link
Author

imyxc commented Sep 25, 2024

I'm very grateful for your help! The new code you provided works well on Windows, which is a significant help for us. The process is identical to what you described for Linux, and it works with Conda and other environments too. On Windows, we need to place the pyvumat program in the same folder as pytorch, such as path/to/anaconda/env/xxx/lib/site-packages. This folder should contain both the pyvumat and pytorch packages, because Windows doesn't allow multiple PYTHONPATH settings.
Thank you so much for your assistance! We're going to continue our work based on the solid foundation you've provided. Your work is highly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants