Need help with linking MOOSE to external application

664 views
Skip to first unread message

Stephen Thomas

unread,
Feb 11, 2015, 9:55:57 AM2/11/15
to moose...@googlegroups.com
Dear MOOSE users,

I am trying to couple LAMMPS with MOOSE such that certain regions of the simulations can use molecular dynamics to simulate heat transport and the rest of the domain uses finite element analysis. For a start, I am trying to use the nodal temperatures obtained from the Atc module in LAMMPS as the boundary condition for a larger mesh being processed in MOOSE. The BC may be corrected every time step based on the values obtained from LAMMPS. For achieving this I need to be able to compile and link the external code to MOOSE. I have compiled LAMMPS as a library and have the ability to invoke it from a simple C++ driver code. I need some guidance to
1) compile the MOOSE code to include the external code and let it drive the MOOSE simulation or vice versa.
2) modifying boundary conditions every time step.

Thank you,
Stephen Thomas.

Graduate Student
Department of Materials Science and Engineering,
1910 University Drive
Boise State University, Boise, ID 83725.

Cody Permann

unread,
Feb 11, 2015, 10:33:50 AM2/11/15
to moose...@googlegroups.com
Hi Stephen,

Not surprisingly we like to use MOOSE as the driver since we have the ability to modify source or create new objects to interact with the varying interfaces of 3rd party codes.  Our Makefiles create libraries for every MOOSE-based application so compiling a MOOSE-based library and a LAMMPS library into a final executable should be straightforward. 

First off, you'll need to start a new application if you haven't already done so:

After that you have a few decisions about how you want to deal with LAMMPS, are you going to manage it completely separately from your application or are you going to add it in as a submodule or "contrib"? At any rate, once you have the library available you should be able to simply add it to your new application's Makefile through the variable "ADDITIONAL_LIBS". If you want to see how we compile our final executable take a look at this file near the bottom:

That's it for compiling them together, now you'll just need to work out the details of when to call the other simulation. You can simply make calls to it at specific places during your solve or you might choose to use our Multiapps and Transfers system to assist you in coupling. You have a lot of options here. Take a look at the Multiapps and Transfers section in the workshop slides and also look at all of the tests in the test/tests/transfers and test/tests/multiapps directories to get ideas of how you might make this work.

Hope this is enough to get you started.
Cody

--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at http://groups.google.com/group/moose-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/9d95d59c-abb5-4761-8067-f5abc17b3534%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephen Thomas

unread,
Apr 6, 2015, 3:10:00 PM4/6/15
to moose...@googlegroups.com
Hi Cody,

I finally got restarted with the task of coupling LAMMPS with MOOSE. For starters, I created a new application, and did the following:
    - added a new kernel (made a copy of an existing kernel from moose modules, renamed it and added  to the new application folder)
    - registered the kernel object in the new application
    - in the new kernel's header file, I included the LAMMPS header files inorder to make test calls to functions in lammps.
    - I added the path to the lammps library (.a file) in the Makefile in my new application folder
              ###############################################################################
              # Additional special case targets should be added here
              ADDITIONAL_LIBS       := /home/sthomas/lammps/lammps-ro/src/liblammps_ubuntu.a

At this stage I am at a loss since I am not very familiar with the make system. The header files are present in the lammps folder. I do not want to copy the lammps header files into the moose application's include directory since there are many of them. Could you please suggest a method to add the include path to the lammps folder? Do I need to modify the /moose/framework/app.mk to include this path?

Thank you,
Stephen Thomas.

Cody Permann

unread,
Apr 6, 2015, 3:19:35 PM4/6/15
to moose...@googlegroups.com
You don't have to modify app.mk. Instead create a new file "animal".mk in your application which is automatically read and used when you compile your application. You can modify whatever you want in your own file to include additional files.

Cody

Daniel Schwen

unread,
Apr 6, 2015, 3:32:50 PM4/6/15
to moose...@googlegroups.com, Yongfeng Zhang
Hello Stephen,
Yongfeng Zhang can probably chime in (he worked a bit on coupling SPPARKS (the LAMMPS Monte Carlo sibling) to MOOSE, but let me make a remark.
Creating a Kernel is probably not the right way. You need to think about what you are trying to achieve. Which way are you trying to transfer data? When do you want to run MD steps? What atomic configuration will LAMMPS see? What are you doing with the LAMMPS results?
I suggest looking into User Objects. You could create a UO (rather than a Kernel) that includes the LAMMPS stuff. Your UO could run at a defined point (once per timestep maybe) and it could prepare a LAMMPS configuration, run LAMMPS, and project results back onto a mesh (concentration data for example).
Cheers,
Daniel

Stephen Thomas

unread,
Apr 6, 2015, 4:34:02 PM4/6/15
to moose...@googlegroups.com, Yongfen...@inl.gov
Hi Daniel,

Thanks for pointing out the effort on coupling SPPARKS. I look forward to hearing from Yongfeng Zhang.

I am trying to transfer data both ways. I would like to run the MD steps  every time step in MOOSE. The nodal temperature from MOOSE mesh will be transferred to LAMMPS mesh (mesh created by AtC module in LAMMPS)  and back every time step in MOOSE. The idea is to modify the boundary condition in MOOSE every time step based on the input from LAMMPS. I am not entirely sure if this is a valid idea, but is willing to give it a shot nevertheless.

Do you have slides explaining what UO does?

Thank you,
Stephen Thomas.

Daniel Schwen

unread,
Apr 6, 2015, 4:42:49 PM4/6/15
to moose...@googlegroups.com
will be transferred to LAMMPS mesh (mesh created by AtC module in LAMMPS)  and back every time step in MOOSE. The idea is to modify the boundary condition in MOOSE every time step based on the input from LAMMPS. I am not entirely sure if this is a valid idea, but is willing to give it a shot nevertheless.

Does not sound unreasonable. 
 
Do you have slides explaining what UO does?

There is some documentation on the wiki http://mooseframework.org/wiki/MooseSystems/UserObjects/
and in the workshop slides.

UserObjects are a good place to "do whatever you want" (they are the most flexible MOOSE system), such as custom coupling code.  The MOOSE guys probably have a better explanantion though :-).

Daniel

Wang (Non-US), Yaqi

unread,
Apr 6, 2015, 5:00:33 PM4/6/15
to moose-users, Yongfeng Zhang
Just to provide another possibility: you may consider using moose multiapp/transfer system.

Daniel Schwen

unread,
Apr 6, 2015, 5:04:11 PM4/6/15
to moose...@googlegroups.com, Yongfeng Zhang
Just to provide another possibility: you may consider using moose multiapp/transfer system.

Yes, you'll want to do that, but this not an alternative, it is another puzzle piece. You still need to make a MOOSE-Application that can talk to LAMMPS directly. That MOOSE-App can be coupled using multiapps and transfers to remap data between moose meshed etc.
Daniel

Stephen Thomas

unread,
Apr 6, 2015, 5:10:51 PM4/6/15
to moose...@googlegroups.com, Yongfen...@inl.gov
I see. So the MOOSE-Application will contain the UO which does the talking to LAMMPS ?

Stephen Thomas

unread,
Apr 6, 2015, 5:41:24 PM4/6/15
to moose...@googlegroups.com, Yongfen...@inl.gov
Also, could you point me towards examples of applications which have used UO and/or multiapp/transfer systems?

Cody Permann

unread,
Apr 6, 2015, 6:20:38 PM4/6/15
to moose...@googlegroups.com, Yongfen...@inl.gov
Your best bet for seeing simple examples is inside of the test suite itself.

test/tests/multapps
test/tests/transfers
test/tests/userobjects

--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at http://groups.google.com/group/moose-users.

yuezh...@gmail.com

unread,
Mar 3, 2019, 8:20:26 PM3/3/19
to moose-users
Hello Daniel,
I am now doing the work similar to Stephen. I wonder that how could I create an UserObject that can finish the work in your e-mail? In other words, I want to know the method that can include the LAMMPS in MOOSE so that the MOOSE would have the ability to call the functions in LAMMPS? If I need to add the path of LAMMPS in the UO, which function should I use?

Thank you,
Zhiying

在 2015年4月7日星期二 UTC+8上午3:32:50,Daniel Schwen写道:

Sebastian Schunert

unread,
Mar 3, 2019, 8:36:14 PM3/3/19
to moose...@googlegroups.com
I have started working on the infrastructure for that recently, here


with related PRs. Can you tell us a little bit about what exactly you want to do
with LAMMPS/MOOSE coupling. I'll tell you if we can do what you need already
or what has to be done to make it work. 

yuezh...@gmail.com

unread,
Mar 4, 2019, 12:43:12 AM3/4/19
to moose-users
Hello Sebastian,
I am sorry that I didn't express my opinion clearly. What I want to do is that how to create an UO that contains the external code (LAMMPS is just an example ) so that I can call the function of this external code or run it in my MOOSE application.

在 2019年3月4日星期一 UTC+8上午9:36:14,Sebastian Schunert写道:

Sebastian Schunert

unread,
Mar 4, 2019, 11:51:57 AM3/4/19
to moose...@googlegroups.com
One example would be Magpie (https://github.com/idaholab/magpie).
Look at the SPAARKS UO.
https://github.com/idaholab/magpie/blob/98b22898b2385fd3cfb3def118ea66ebc2ba9c8c/src/userobjects/SPPARKSUserObject.C#L1

This is one way you can do it with something that is structured like LAMMPS (I am assuming here that SPAARKS and LAMMPS are structured fairly similar).


yuezh...@gmail.com

unread,
Mar 4, 2019, 7:45:24 PM3/4/19
to moose-users
Hi Sebastian,
Thank you for your suggestion. I will try it right now.

Zhiying
在 2019年3月5日星期二 UTC+8上午12:51:57,Sebastian Schunert写道:
Reply all
Reply to author
Forward
0 new messages