Skip to content

Commit

Permalink
Release v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PKua007 committed Jun 21, 2023
2 parents 4b73b5e + 1c4afda commit 62e4fb1
Show file tree
Hide file tree
Showing 17 changed files with 301 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CMake

on:
push:
branches: [ "main" ]
branches: [ "main" , "develop" ]
pull_request:
branches: [ "main" ]
branches: [ "main" , "develop" ]

env:
BUILD_TYPE: Release
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ library (later, with Python bindings as well).

## [Unreleased]


## [1.1.0] - 2023-06-21

### Fixed

* Fixed typos in documentation and changelog.
* Fixed corrupted observables' output file when `--continue` is used.

### Added

* Added [v1] and [latest] tags.
* Added MinGW support.
* Added `randomize_rotation` lattice transformer.


## [1.0.0] - 2023-06-18
Expand All @@ -32,9 +37,10 @@ This is the initial stable release of the simulation software.

During the development stage (0.x versions) no changelog was maintained. The changes can be inferred from git history.

[Unreleased]: https://github.com/PKua007/rampack/compare/v1.0.0..HEAD
[Unreleased]: https://github.com/PKua007/rampack/compare/latest..develop
[latest]: https://github.com/PKua007/rampack/releases/tag/latest
[v1]: https://github.com/PKua007/rampack/releases/tag/v1
[1.1.0]: https://github.com/PKua007/rampack/releases/tag/v1.0.0
[1.0.0]: https://github.com/PKua007/rampack/releases/tag/v1.0.0


Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(rampack VERSION 1.0.0)
project(rampack VERSION 1.1.0)

# Available options
option(RAMPACK_STATIC_LINKING "Build no-dependency static executable" OFF)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ details. `bash` and `zsh` autocompletion scripts are bundled. They are installed
and are included in DEB/RPM packages.

We provided a few sample input files in the `sample_inputs` folder. They can be used to verify that the software is
working correctly and are a good learning materials. For example,
working correctly and are good learning materials. For example,

```shell
rampack casino -i integration.pyon
Expand Down
34 changes: 34 additions & 0 deletions doc/initial-arrangement.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This reference page describes all options for `arrangement` argument of [class `
* [Class `columnar`](#class-columnar)
* [Class `randomize_flip`](#class-randomize_flip)
* [Class `layer_rotate`](#class-layer_rotate)
* [Class `randomize_rotation`](#class-randomize_rotation)
* [Lattice populators](#lattice-populators)
* [Class `serial`](#class-serial)
* [Class `random`](#class-random)
Expand Down Expand Up @@ -512,6 +513,39 @@ Arguments:
will be rotated counterclockwise, and particle in odd layers clockwise.


### Class `randomize_rotation`

```python
randomize_rotation(
seed,
axis = "random",
)
```

* **Lattice requirements**: none
* **Resulting lattice**: irregular, normalized if was before

Randomizes rotations of particles. Rotations may be around a specific or random axis depending on the `axis` parameter.

* ***seed***

Seed of the RNG used to randomize rotations.

* ***axis*** (*= "random"*)

Axis of the rotation. The following values are accepted:
* ***"random"*** <br />
All shapes are rotated by a random angle around a random axis with a uniform probability of all rotations.
* Array of Floats (eg. `[1, 1, 0]`) <br />
Specific constant (lab) axis. Axis normalization is performed automatically. All shapes are rotated around the same
axis by random angles.
* ***"x"***, ***"y"***, ***"z"*** <br />
Shorthands for x, y and z lab axes. All shapes are rotated around the same axis by random angles.
* ***"primary"***, ***"secondary"***, ***"auxiliary"*** <br />
Rotation around a [shape axis](shapes.md#shape-axes) by a random angle. Rotation axis is not constant - shape axes
are defined in shape's coordinate system, thus the axis of rotation depends on the orientation of a shape.


## Lattice populators

Lattice populators determine the way the particles are skipped when using [`fill_partially` argument](#fill-partially)
Expand Down
23 changes: 13 additions & 10 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ This reference page gives installation instructions for all methods in all suppo

## Supported platforms

| | Linux | macOS (Intel, Apple Silicon) | Windows |
|----------------------------------------------------------------------|-------------------------|-----------------------------------------------------------------------------------------|------------------------------------------|
| [Source code compilation](#source-code-compilation) | - GCC 7+<br/>- Clang 7+ | Apple:<br/>- Clang 7+ (**no multithreading**)<br/>Homebrew:<br/>- GCC 7+<br/>- Clang 7+ | Cygwin/WSL:<br/>- GCC 7+<br/>- Clang 7+ |
| [Standalone binary](#standalone-binary)<br />(**no tab completion**) | &#9989; | &#10060; | &#10060; |
| [Packages](#packages) | DEB/RMP | &#10060; | &#10060; |
| | Linux | macOS (Intel, Apple Silicon) | Windows |
|----------------------------------------------------------------------|-------------------------|-----------------------------------------------------------------------------------------|-----------------------------------------------|
| [Source code compilation](#source-code-compilation) | - GCC 7+<br/>- Clang 7+ | Apple:<br/>- Clang 7+ (**no multithreading**)<br/>Homebrew:<br/>- GCC 7+<br/>- Clang 7+ | Cygwin/MinGW/WSL:<br/>- GCC 7+<br/>- Clang 7+ |
| [Standalone binary](#standalone-binary)<br />(**no tab completion**) | &#9989; | &#10060; | &#10060; |
| [Packages](#packages) | DEB/RMP | &#10060; | &#10060; |


## Source code compilation

Source code compilation is a recommended method of RAMPACK installation. It enables you to utilize native CPU
optimizations, which usually increase the performance by around 10%. To build the project, you need the following
optimizations, which usually increases the performance by around 10%. To build the project, you need the following
prerequisites:

- cmake 3.10+
Expand All @@ -37,9 +37,10 @@ All other dependencies are contained within the git repository as submodules. Th

- Linux
- macOS (Intel, Apple Silicon)
- Windows (Cygwin, WSL)
- Windows (Cygwin, MinGW, WSL)

First, unpack the source code archive (TAR.GZ / ZIP) or clone the project using `git`. If using `git`, the project
First, unpack the source code archive (`rampack-[version]-source.tar.gz` in
[Releases](https://github.com/PKua007/rampack/releases)) or clone the project using `git`. If using `git`, the project
should be cloned with `--recurse-submodules` option

```shell
Expand All @@ -52,7 +53,8 @@ or, if the project was already cloned without it, you should execute
git submodule update --init
```

Then issuing the following commands with install the program with tab completion scripts for `bash` and `zsh` shells
Then issuing the following commands in project's root directory will install the program with tab completion scripts for
`bash` and `zsh` shells.

```shell
mkdir build
Expand All @@ -72,7 +74,8 @@ rampack --version


### Advanced build option
There are also project-specific CMake options to customize the build:

There are also general and project-specific CMake options to customize the build:

* ***-DCMAKE_C_COMPILER=...*** (*= as detected by CMake*)<br />
***-DCMAKE_CXX_COMPILER=...*** (*= as detected by CMake*)
Expand Down
2 changes: 1 addition & 1 deletion sample_inputs/integration.pyon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rampack(
version = "1.0.0",
version = "1.1.0",
arrangement = lattice(cell=sc, box_dim=100, n_shapes=1000),
temperature = 1,
move_types = [translation(step=10)],
Expand Down
2 changes: 1 addition & 1 deletion sample_inputs/overlap_reduction.pyon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rampack(
version = "1.0.0",
version = "1.1.0",
arrangement = lattice(cell=sc, box_dim=7, n_shapes=512),
temperature = 1,
pressure = 20,
Expand Down
15 changes: 9 additions & 6 deletions src/core/ObservablesCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,16 @@ void ObservablesCollector::attachOnTheFlyOutput(std::unique_ptr<std::iostream> o
if (this->onTheFlyOut == nullptr)
return;

this->onTheFlyOut->seekp(0, std::ios::end);
if (this->onTheFlyOut->tellp() == 0) {
this->onTheFlyOut->seekg(0, std::ios::end);
if (this->onTheFlyOut->tellg() == 0) {
this->doPrintSnapshotHeader(*this->onTheFlyOut);
} else {
this->verifyOnTheFlyOutputHeader();
this->findOnTheFlyLastCycleNumber();
}

// After all checks, rewind the write head to the end
this->onTheFlyOut->seekp(0, std::ios::end);
}

void ObservablesCollector::verifyOnTheFlyOutputHeader() {
Expand All @@ -284,8 +287,8 @@ void ObservablesCollector::verifyOnTheFlyOutputHeader() {
std::ostringstream errorMsg;
errorMsg << "ObservablesCollector: On-the-fly observable output stream already stores different observables.";
errorMsg << std::endl;
errorMsg << "To be stored : " << expectedHeader << std::endl;
errorMsg << "Already present : " << actualHeader;
errorMsg << "To be stored : `" << expectedHeader << "`" << std::endl;
errorMsg << "Already present : `" << actualHeader << "`";
throw ValidationException(errorMsg.str());
}
}
Expand All @@ -306,12 +309,12 @@ void ObservablesCollector::findOnTheFlyLastCycleNumber() {
"ObservablesCollector: Could not read last cycle number - broken observable output stream");

// Only header is present
if (this->onTheFlyOut->tellp() == 0) {
if (this->onTheFlyOut->tellg() == 0) {
this->onTheFlyLastCycleNumber = 0;
return;
}

std::istringstream lineStream(line);
ValidateMsg(lineStream >> this->onTheFlyLastCycleNumber,
"ObservablesCollector: Could not read last cycle number: broken observable output stream");
"ObservablesCollector: Could not read last cycle number - broken observable output stream");
}
13 changes: 13 additions & 0 deletions src/core/ShapeGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,16 @@ Vector<3> ShapeGeometry::findFlipAxis(const Shape &shape) const {
Vector<3> flipAxis = primaryAxis ^ referenceDirection;
return (shape.getOrientation() * flipAxis).normalized();
}

Vector<3> ShapeGeometry::getAxis(const Shape &shape, ShapeGeometry::Axis axis) const {
switch(axis) {
case Axis::PRIMARY:
return this->getPrimaryAxis(shape);
case Axis::SECONDARY:
return this->getSecondaryAxis(shape);
case Axis::AUXILIARY:
return this->getAuxiliaryAxis(shape);
default:
AssertThrow("axis");
}
}
5 changes: 5 additions & 0 deletions src/core/ShapeGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ class ShapeGeometry {
return (this->getPrimaryAxis(shape) ^ this->getSecondaryAxis(shape)).normalized();
}

/**
* @brief Returns shape axis of type @a axis for shape @a shape.
*/
[[nodiscard]] Vector<3> getAxis(const Shape &shape, Axis axis) const;

/**
* @brief Returns the geometric origin a given @a shape (with respect to its centre) which is usually the center of
* its bounding box.
Expand Down
54 changes: 54 additions & 0 deletions src/core/lattice/RotationRandomizingTransformer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// Created by Piotr Kubala on 20/06/2023.
//

#include "RotationRandomizingTransformer.h"
#include "utils/Utils.h"


RotationRandomizingTransformer::RotationRandomizingTransformer(const Axis &axis, unsigned long seed)
: mt(seed), axis{axis}
{
if (std::holds_alternative<Vector<3>>(this->axis)) {
auto &vectorAxis = std::get<Vector<3>>(this->axis);

// Absolute values of components at least approx 1e-10
Expects(vectorAxis.norm2() > 1e-20);
vectorAxis = vectorAxis.normalized();
}
}

void RotationRandomizingTransformer::transform(Lattice &lattice, const ShapeTraits &shapeTraits) const {
auto dim = lattice.getDimensions();
for (std::size_t i{}; i < dim[0]; i++)
for (std::size_t j{}; j < dim[1]; j++)
for (std::size_t k{}; k < dim[2]; k++)
for (auto &shape : lattice.modifySpecificCellMolecules(i, j, k))
this->rotateRandomly(shape, shapeTraits.getGeometry());
}

void RotationRandomizingTransformer::rotateRandomly(Shape &shape, const ShapeGeometry &geometry) const {
auto getRotation = [this, &geometry, &shape](auto &&axisVariant) -> Matrix<3, 3> {
std::uniform_real_distribution<double> plusMinusOne(-1, 1);
std::uniform_real_distribution<double> zero2pi(0, 2*M_PI);

using T = std::decay_t<decltype(axisVariant)>;
if constexpr (std::is_same_v<T, Vector<3>>) {
return Matrix<3, 3>::rotation(axisVariant, zero2pi(this->mt));
} else if constexpr (std::is_same_v<T, ShapeGeometry::Axis>) {
auto theAxis = geometry.getAxis(shape, axisVariant).normalized();
return Matrix<3, 3>::rotation(theAxis, zero2pi(this->mt));
} else if constexpr (std::is_same_v<T, RandomAxisType>) {
// For Tait-Bryan angles, this gives a uniform probability of rotations
double angleX = zero2pi(this->mt);
double angleY = std::asin(plusMinusOne(this->mt));
double angleZ = zero2pi(this->mt);
return Matrix<3, 3>::rotation(angleX, angleY, angleZ);
} else {
static_assert(always_false<T>);
}
};
auto rotation = std::visit(getRotation, this->axis);

shape.rotate(rotation);
}
52 changes: 52 additions & 0 deletions src/core/lattice/RotationRandomizingTransformer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// Created by Piotr Kubala on 20/06/2023.
//

#ifndef RAMPACK_ROTATIONRANDOMIZINGTRANSFORMER_H
#define RAMPACK_ROTATIONRANDOMIZINGTRANSFORMER_H


#include <random>
#include <variant>

#include "LatticeTransformer.h"


/**
* @brief Lattice transformer which performs random rotations of particles around the selected axis.
*/
class RotationRandomizingTransformer : public LatticeTransformer {
public:
/**
* @brief Type for random axis tag.
*/
struct RandomAxisType {};

/**
* @brief Axis variant: extrinsic axis (Vector<3>), intrinsic axis (ShapeGeometry::Axis) or random axis
* (RotationRandomizingTransformer::RANDOM_AXIS).
*/
using Axis = std::variant<Vector<3>, ShapeGeometry::Axis, RandomAxisType>;

/**
* @brief Random axis tag.
*/
static constexpr RandomAxisType RANDOM_AXIS{};

private:
mutable std::mt19937 mt;
Axis axis;

void rotateRandomly(Shape &shape, const ShapeGeometry &geometry) const;

public:
/**
* @brief Setups the class for axis @a axis with RNG seed @a seed.
*/
RotationRandomizingTransformer(const Axis &axis, unsigned long seed);

void transform(Lattice &lattice, const ShapeTraits &shapeTraits) const override;
};


#endif //RAMPACK_ROTATIONRANDOMIZINGTRANSFORMER_H
Loading

0 comments on commit 62e4fb1

Please sign in to comment.