github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.3k stars 4.26k forks source link

Detection of LIGGGHTS scripts or various scripts used for simulation programs #5303

Closed adyotag closed 1 year ago

adyotag commented 3 years ago

Describe the enhancement

Many of us use DEM (discrete element method) to carry out simulations using engines like LIGGGHTS or LAMMPS. To run our simulations, we have to write some scripts. In the LIGGGHTS community, it's very customary to label our input scripts as "*.lmp". It would be a fun addition to add a language called "LIGGGHTS/LAMMPS Script" when it detects an input file of this sort of format. To make it more robust, one could also detect keywords like "atom_style", "boundary", etc. to better label it. An example script is the following:

#Particle packing by insertion and successive growing of particles

atom_style granular

atom_modify map array

boundary f f p newton off #echo both

dimension 2

communicate single vel yes

units si

read_data particles.dat

neighbor 0.002 bin neigh_modify delay 0

# MATERIAL PROPERTIES FOR PAIR STYLE

fix m1 all property/global youngsModulus peratomtype 1.e9 1.e9 fix m2 all property/global poissonsRatio peratomtype 0.2 0.2 fix m3 all property/global coefficientRestitution peratomtypepair 2 0.1 0.1 0.1 0.1 fix m4 all property/global coefficientFriction peratomtypepair 2 0.4 0.0 0.0 0.0

# DEFINE PAIRTSTYLE pair_style gran model hertz tangential history #Hertzian without cohesion pair_coeff

# TIMESTEP timestep 0.001

Nixinova commented 3 years ago

What is the file extension/name?

lildude commented 3 years ago

What is the file extension/name?

If I understand the OP correctly...

it's very customary to label our input scripts as "in.XXXXX".

... the files are named in.XXXXX where the Xs represent some other random characters. If this is the case, this isn't currently possible with Linguist as it works purely on full identifiable filenames, eg Makefile and extensions, eg .php. It doesn't cater for fixed prefixes and changing extensions/suffixes.

This is the same thing that affects having Linguist identify Dockerfile.foobar as detailed in https://github.com/github/linguist/issues/4566

If "LIGGGHTS/LAMMPS" as a language has a fixed filename or extension, and has wide enough usage on GitHub.com, we'd certainly welcome a PR. Once the language is known, users can then use an override to force the language of these in.* files.