class Lammps < Formula desc "Molecular Dynamics Simulator" homepage "https://docs.lammps.org/" url "https://github.com/lammps/lammps/archive/refs/tags/stable_22Jul2025_update4.tar.gz" # lammps releases are named after their release date. We transform it to # YYYY-MM-DD (year-month-day) so that we get a sane version numbering. # We only track stable releases as announced on the LAMMPS homepage. version "20250722-update4" sha256 "411088d9c03339e025f6a975e0a5741bb9e3f351cc39eda220ab22ac318fe2fb" license "GPL-2.0-only" # The `strategy` block below is used to massage upstream tags into the # YYYY-MM-DD format we use in the `version`. This is necessary for livecheck # to be able to do proper `Version` comparison. livecheck do url :stable regex(/^stable[._-](\d{1,2}\w+\d{2,4})(?:[._-](update\d*))?$/i) strategy :git do |tags, regex| tags.map do |tag| match = tag.match(regex) next if match.blank? || match[1].blank? date_str = Date.parse(match[1]).strftime("%Y%m%d") match[2].present? ? "#{date_str}-#{match[2]}" : date_str end end end no_autobump! because: :incompatible_version_format bottle do sha256 cellar: :any, arm64_tahoe: "631170e3d3136cec64ce4bce3f6dd9a5a9c26276cb93fbe4e06a99834ccc4a3b" sha256 cellar: :any, arm64_sequoia: "565e1b7546fdad6c167b1606654d19c1995ca6d66d37acaea40614f058e325ab" sha256 cellar: :any, arm64_sonoma: "c4cfa0dc4a222511f3fe9f294968f15a0d472f48955e6214e0a176ba0502449f" sha256 cellar: :any, sonoma: "6a680035bd987dd6d0fb3f2ba105b4c71165c62b89b0ff264f9b3048c9a42cb3" sha256 cellar: :any_skip_relocation, arm64_linux: "6a71f8951b35659b56b15a8edbbe176b0aa63f49099ecb45afc33dc3838990ed" sha256 cellar: :any_skip_relocation, x86_64_linux: "3d2a3019f1d730e2bfb4de7dae3514d27694536966c72d27461039667eb98a78" end depends_on "cmake" => :build depends_on "pkgconf" => :build depends_on "voro++" => :build depends_on "fftw" depends_on "jpeg-turbo" depends_on "kim-api" depends_on "libpng" depends_on "open-mpi" uses_from_macos "curl" uses_from_macos "python" on_macos do depends_on "libomp" end def install %w[serial mpi].each do |variant| args = [ "-S", "cmake", "-B", "build_#{variant}", "-C", "cmake/presets/all_on.cmake", "-C", "cmake/presets/nolib.cmake", "-DPKG_INTEL=no", "-DPKG_KIM=yes", "-DPKG_VORONOI=yes", "-DLAMMPS_MACHINE=#{variant}", "-DBUILD_MPI=#{(variant == "mpi") ? "yes" : "no"}", "-DBUILD_OMP=#{(variant == "serial") ? "no" : "yes"}", "-DBUILD_SHARED_LIBS=yes", "-DFFT=FFTW3", "-DWITH_GZIP=yes", "-DWITH_JPEG=yes", "-DWITH_PNG=yes", "-DCMAKE_INSTALL_RPATH=#{rpath}" ] args << "-DOpenMP_CXX_FLAGS=-I#{Formula["libomp"].opt_include}" if OS.mac? system "cmake", *args, *std_cmake_args system "cmake", "--build", "build_#{variant}" system "cmake", "--install", "build_#{variant}" end pkgshare.install %w[doc tools bench examples] end test do system bin/"lmp_serial", "-in", pkgshare/"bench/in.lj" output = shell_output("#{bin}/lmp_serial -h") %w[KSPACE POEMS VORONOI].each do |pkg| assert_match pkg, output end end end