Merge branch 'lammps-gui' of github.com:akohlmey/lammps into lammps-gui

# Conflicts:
#	tools/lammps-gui/lammpsgui.cpp
This commit is contained in:
Axel Kohlmeyer
2023-07-29 21:11:38 -04:00
12 changed files with 284 additions and 9 deletions

View File

@ -798,7 +798,7 @@ include(Documentation)
############################################################################### ###############################################################################
# Install potential and force field files in data directory # Install potential and force field files in data directory
############################################################################### ###############################################################################
set(LAMMPS_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/lammps) set(LAMMPS_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/lammps)
install(DIRECTORY ${LAMMPS_POTENTIALS_DIR} DESTINATION ${LAMMPS_INSTALL_DATADIR}) install(DIRECTORY ${LAMMPS_POTENTIALS_DIR} DESTINATION ${LAMMPS_INSTALL_DATADIR})
if(BUILD_TOOLS) if(BUILD_TOOLS)
install(DIRECTORY ${LAMMPS_TOOLS_DIR}/msi2lmp/frc_files DESTINATION ${LAMMPS_INSTALL_DATADIR}) install(DIRECTORY ${LAMMPS_TOOLS_DIR}/msi2lmp/frc_files DESTINATION ${LAMMPS_INSTALL_DATADIR})
@ -866,6 +866,22 @@ if(ClangFormat_FOUND)
WORKING_DIRECTORY ${LAMMPS_SOURCE_DIR}) WORKING_DIRECTORY ${LAMMPS_SOURCE_DIR})
endif() endif()
# Packaging
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LAMMPS")
set(CPACK_PACKAGE_VENDOR "The LAMMPS Developers")
set(CPACK_PACKAGE_NAME "LAMMPS")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
if(CPACK_GENERATOR STREQUAL "DragNDrop")
set(CPACK_DMG_VOLUME_NAME "LAMMPS-macOS-universal")
set(CPACK_DMG_BACKGROUND_IMAGE "${LAMMPS_DIR}/cmake/packaging/LAMMPS_DMG_BACKGROUND")
set(CPACK_DS_STORE_SETUP_SCRIPT "${LAMMPS_DIR}/cmake/packaging/LAMMPS_DMG_Setup.scpt")
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
install(FILES ${LAMMPS_DIR/cmake/packaging/README.macos DESTINATION . RENAME README.txt)
endif()
include(CPack)
# extract Kokkos compilation settings # extract Kokkos compilation settings
get_cmake_property(_allvars VARIABLES) get_cmake_property(_allvars VARIABLES)
foreach(_var ${_allvars}) foreach(_var ${_allvars})

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

View File

@ -0,0 +1,58 @@
on run argv
set image_name to item 1 of argv
tell application "Finder"
tell disk image_name
-- wait for the image to finish mounting
set open_attempts to 0
repeat while open_attempts < 4
try
open
delay 1
set open_attempts to 5
close
on error errStr number errorNumber
set open_attempts to open_attempts + 1
delay 10
end try
end repeat
delay 5
-- open the image the first time and save a DS_Store with just
-- background and icon setup
open
set current view of container window to icon view
set theViewOptions to the icon view options of container window
set background picture of theViewOptions to file ".background:background.png"
set arrangement of theViewOptions to not arranged
set icon size of theViewOptions to 64
delay 5
close
-- next setup the position of the app and Applications symlink
-- plus hide all the window decoration
open
update without registering applications
tell container window
set sidebar width to 0
set statusbar visible to false
set toolbar visible to false
set the bounds to { 100, 40, 868, 640 }
set position of item "LAMMPS" to { 190, 216 }
set position of item "Applications" to { 576, 216 }
set position of item "README.txt" to { 190, 400 }
end tell
update without registering applications
delay 5
close
-- one last open and close so you can see everything looks correct
open
delay 5
close
end tell
delay 1
end tell
end run

View File

@ -0,0 +1,46 @@
LAMMPS and LAMMPS GUI universal binaries for macOS (arm64/x86_64)
=================================================================
This package provides universal binaries of LAMMPS and LAMMPS GUI that should
run on macOS systems running running macOS version 11 (Big Sur) or newer. Note
the binaries are compiled without MPI support and contain a compatible subset
of the available packages.
The following individual commands are included:
binary2txt lammps-gui lmp msi2lmp phana stl_bin2txt
After copying the lammps-gui folder into your Applications folder, please follow
these steps:
1. Open the Terminal app
2. Type the following command and press ENTER:
open ~/.zprofile
This will open a text editor for modifying the .zprofile file in your home
directory.
3. Add the following lines to the end of the file, save it, and close the editor
LAMMPS_INSTALL_DIR=/Applications/lammps-gui.app/Contents
LAMMPS_POTENTIALS=${LAMMPS_INSTALL_DIR}/share/lammps/potentials
LAMMPS_BENCH_DIR=${LAMMPS_INSTALL_DIR}/share/lammps/bench
MSI2LMP_LIBRARY=${LAMMPS_INSTALL_DIR}/share/lammps/frc_files
PATH=${LAMMPS_INSTALL_DIR}/bin:$PATH
export LAMMPS_POTENTIALS LAMMPS_BENCH_DIR PATH
4. In your existing terminal, type the following command make the settings active
source ~/.zprofile
Note, you don't have to type this in new terminals, since they will apply
the changes from .zprofile automatically.
5. Try running LAMMPS
lmp -in $LAMMPS_BENCH_DIR/in.lj
6. Try running LAMMPS GUI
lammps-gui $LAMMPS_BENCH_DIR/in.rhodo

View File

@ -0,0 +1,105 @@
#!/bin/bash
APP_NAME=lammps-gui
echo "Delete old files, if they exist"
rm -f ${APP_NAME}.dmg ${APP_NAME}-rw.dmg LAMMPS-macOS-multiarch.dmg
echo "Create initial dmg file with macdeployqt"
macdeployqt lammps-gui.app -always-overwrite -dmg
echo "Create writable dmg file"
hdiutil convert ${APP_NAME}.dmg -format UDRW -o ${APP_NAME}-rw.dmg
echo "Mount writeable DMG file in read-write mode. Keep track of device and volume names"
DEVICE=$(hdiutil attach -readwrite -noverify ${APP_NAME}-rw.dmg | grep '^/dev/' | sed 1q | awk '{print $1}')
VOLUME=$(df | grep ${DEVICE} | sed -e 's/^.*\(\/Volumes\/\)/\1/')
sleep 2
echo "Create link to Application folder and move README and background image files"
pushd "${VOLUME}"
ln -s /Applications .
mv ${APP_NAME}.app/Contents/Resources/README.txt .
mkdir .background
mv ${APP_NAME}.app/Contents/Resources/LAMMPS_DMG_Background.png .background/background.png
mv ${APP_NAME}.app LAMMPS.app
cd LAMMPS.app/Contents
echo "Attach icons to LAMMPS console and GUI executables"
echo "read 'icns' (-16455) \"Resources/lammps.icns\";" > icon.rsrc
Rez -a icon.rsrc -o bin/lmp
SetFile -a C bin/lmp
Rez -a icon.rsrc -o MacOS/lammps-gui
SetFile -a C MacOS/lammps-gui
rm icon.rsrc
popd
echo 'Tell the Finder to resize the window, set the background,'
echo 'change the icon size, place the icons in the right position, etc.'
echo '
tell application "Finder"
tell disk "'${APP_NAME}'"
-- wait for the image to finish mounting
set open_attempts to 0
repeat while open_attempts < 4
try
open
delay 1
set open_attempts to 5
close
on error errStr number errorNumber
set open_attempts to open_attempts + 1
delay 10
end try
end repeat
delay 5
-- open the image the first time and save a .DS_Store
-- just the background and icon setup
open
set current view of container window to icon view
set theViewOptions to the icon view options of container window
set background picture of theViewOptions to file ".background:background.png"
set arrangement of theViewOptions to not arranged
set icon size of theViewOptions to 64
delay 5
close
-- next set up the position of the app and Applications symlink
-- plus hide all window decorations
open
update without registering applications
tell container window
set sidebar width to 0
set statusbar visible to false
set toolbar visible to false
set the bounds to { 100, 40, 868, 640 }
set position of item "'LAMMPS'.app" to { 190, 216 }
set position of item "Applications" to { 576, 216 }
set position of item "README.txt" to { 190, 400 }
end tell
update without registering applications
delay 5
close
-- one last open and close to check the results
open
delay 5
close
end tell
delay 1
end tell
' | osascript
sync
echo "Unmount modified disk image and convert to compressed read-only image"
hdiutil detach "${DEVICE}"
hdiutil convert "${APP_NAME}-rw.dmg" -format UDZO -o "LAMMPS-macOS-multiarch.dmg"
echo "Delete temporary disk images"
rm -f "${APP_NAME}-rw.dmg"
rm -f "${APP_NAME}.dmg"
exit 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 KiB

BIN
cmake/packaging/lammps.icns Normal file

Binary file not shown.

30
cmake/packaging/png2iconset.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
if [ $# != 2 ]
then
echo "usage: $0 <pngfile> <iconset name>"
exit 1
fi
png="$1"
ico="$2"
if [ ! -f ${png} ]
then
echo "PNG Image $1 not found"
fi
rm -rf ${ico}.iconset
mkdir ${ico}.iconset
sips -z 16 16 ${png} --out ${ico}.iconset/icon_16x16.png
sips -z 32 32 ${png} --out ${ico}.iconset/icon_16x16@2x.png
sips -z 32 32 ${png} --out ${ico}.iconset/icon_32x32.png
sips -z 64 64 ${png} --out ${ico}.iconset/icon_32x32@2x.png
sips -z 128 128 ${png} --out ${ico}.iconset/icon_128x128.png
sips -z 256 256 ${png} --out ${ico}.iconset/icon_128x128@2x.png
sips -z 256 256 ${png} --out ${ico}.iconset/icon_256x256.png
sips -z 512 512 ${png} --out ${ico}.iconset/icon_256x256@2x.png
sips -z 512 512 ${png} --out ${ico}.iconset/icon_512x512.png
sips -z 1024 1024 ${png} --out ${ico}.iconset/icon_512x512@2x.png
iconutil -c icns ${ico}.iconset
rm -rf ${ico}.iconset

View File

@ -83,12 +83,11 @@ set(PROJECT_SOURCES
${PLUGIN_LOADER_SRC} ${PLUGIN_LOADER_SRC}
) )
qt_add_resources(PROJECT_SOURCES lammpsgui.qrc) qt_add_resources(PROJECT_SOURCES lammpsgui.qrc)
if(APPLE)
set(MACOSX_BUNDLE_BUNDLE_NAME lammps-gui) if(CPACK_GENERATOR STREQUAL "DragNDrop")
set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
set(MACOSX_BUNDLE_COPYRIGHT GPLv2) set(MACOSX_BUNDLE_COPYRIGHT GPLv2)
set(MACOSX_BUNDLE_GUI_IDENTIFIER org.lammps.gui) set(MACOSX_BUNDLE_GUI_IDENTIFIER org.lammps.gui)
set(MACOSX_BUNDLE_INFO_STRING "A Simple GUI for LAMMPS") set(MACOSX_BUNDLE_INFO_STRING "LAMMPS")
set(MACOSX_BUNDLE_LONG_VERSION_STRING 0.9) set(MACOSX_BUNDLE_LONG_VERSION_STRING 0.9)
set(MACOSX_BUNDLE_SHORT_VERSION_STRING 0.9.0) set(MACOSX_BUNDLE_SHORT_VERSION_STRING 0.9.0)
get_filename_component(MACOSX_BUNDLE_ICON_FILE ${MACOSX_ICON_FILE} NAME) get_filename_component(MACOSX_BUNDLE_ICON_FILE ${MACOSX_ICON_FILE} NAME)
@ -128,6 +127,10 @@ else()
endif() endif()
target_compile_definitions(lammps-gui PRIVATE LAMMPS_GUI_VERSION="${PROJECT_VERSION}") target_compile_definitions(lammps-gui PRIVATE LAMMPS_GUI_VERSION="${PROJECT_VERSION}")
target_link_libraries(lammps-gui PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) target_link_libraries(lammps-gui PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
if(BUILD_OMP)
find_package(OpenMP COMPONENTS CXX REQUIRED)
target_link_libraries(lammps-gui PRIVATE OpenMP::OpenMP_CXX)
endif()
set_target_properties(lammps-gui PROPERTIES set_target_properties(lammps-gui PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
@ -137,6 +140,12 @@ set_target_properties(lammps-gui PROPERTIES
WIN32_EXECUTABLE TRUE WIN32_EXECUTABLE TRUE
) )
if(CPACK_GENERATOR STREQUAL "DragNDrop")
install(TARGETS lammps-gui BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX})
else()
install(TARGETS lammps-gui DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if(QT_VERSION_MAJOR EQUAL 6) if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(lammps-gui) qt_finalize_executable(lammps-gui)
endif() endif()

View File

@ -62,12 +62,16 @@ LammpsGui::LammpsGui(QWidget *parent, const char *filename) :
recent_files.clear(); recent_files.clear();
lammps_args.clear(); lammps_args.clear();
lammps_args.push_back(mystrdup("LAMMPS GUI")); lammps_args.push_back(mystrdup("LAMMPS-GUI"));
lammps_args.push_back(mystrdup("-log")); lammps_args.push_back(mystrdup("-log"));
lammps_args.push_back(mystrdup("none")); lammps_args.push_back(mystrdup("none"));
setWindowIcon(QIcon(":/lammps-icon-128x128.png")); setWindowIcon(QIcon(":/lammps-icon-128x128.png"));
QFont text_font(":/monospace.ttf"); #if (__APPLE__)
QFont text_font("Menlo");
#else
QFont text_font(":/Monospace.ttf");
#endif
text_font.setStyleHint(QFont::TypeWriter); text_font.setStyleHint(QFont::TypeWriter);
ui->textEdit->document()->setDefaultFont(text_font); ui->textEdit->document()->setDefaultFont(text_font);
ui->textEdit->setMinimumSize(800, 600); ui->textEdit->setMinimumSize(800, 600);
@ -426,7 +430,11 @@ void LammpsGui::run_buffer()
logwindow->setWindowTitle("LAMMPS-GUI - Output from running LAMMPS on buffer - " + logwindow->setWindowTitle("LAMMPS-GUI - Output from running LAMMPS on buffer - " +
current_file); current_file);
logwindow->setWindowIcon(QIcon(":/lammps-icon-128x128.png")); logwindow->setWindowIcon(QIcon(":/lammps-icon-128x128.png"));
QFont text_font(":/monospace.ttf"); #if (__APPLE__)
QFont text_font("Menlo");
#else
QFont text_font(":/Monospace.ttf");
#endif
text_font.setStyleHint(QFont::TypeWriter); text_font.setStyleHint(QFont::TypeWriter);
logwindow->document()->setDefaultFont(text_font); logwindow->document()->setDefaultFont(text_font);
logwindow->setLineWrapMode(QPlainTextEdit::NoWrap); logwindow->setLineWrapMode(QPlainTextEdit::NoWrap);

View File

@ -1,6 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0"> <!DOCTYPE RCC><RCC version="1.0">
<qresource> <qresource>
<file alias="monospace.ttf">DejaVuSansMono.ttf</file> <file alias="Monospace.ttf">DejaVuSansMono.ttf</file>
<file>lammps-icon-128x128.png</file> <file>lammps-icon-128x128.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -85,6 +85,7 @@ if(USE_SPGLIB)
include(LAMMPSUtils) include(LAMMPSUtils)
GetFallbackURL(SPGLIB_URL SPGLIB_FALLBACK) GetFallbackURL(SPGLIB_URL SPGLIB_FALLBACK)
string(REPLACE ";" "$<SEMICOLON>" CMAKE_OSX_ARCHITECTURES_ "${CMAKE_OSX_ARCHITECTURES}")
include(ExternalProject) include(ExternalProject)
ExternalProject_Add(spglib_build ExternalProject_Add(spglib_build
URL ${SPGLIB_URL} ${SPGLIB_FALLBACK} URL ${SPGLIB_URL} ${SPGLIB_FALLBACK}
@ -96,6 +97,8 @@ if(USE_SPGLIB)
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_}
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
UPDATE_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.spglib ${CMAKE_CURRENT_BINARY_DIR}/spglib_build_ext/src/spglib_build/CMakeLists.txt UPDATE_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.spglib ${CMAKE_CURRENT_BINARY_DIR}/spglib_build_ext/src/spglib_build/CMakeLists.txt
INSTALL_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/spglib_build_ext/src/spglib_build-build --target install INSTALL_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/spglib_build_ext/src/spglib_build-build --target install
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/spglib_build_ext/lib/${CMAKE_STATIC_LIBRARY_PREFIX}symspg${CMAKE_STATIC_LIBRARY_SUFFIX}" BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/spglib_build_ext/lib/${CMAKE_STATIC_LIBRARY_PREFIX}symspg${CMAKE_STATIC_LIBRARY_SUFFIX}"