• V1.6 6be38cd51b

    hliu092 released this 2026-11-24 07:13:25 +00:00 | 0 commits to main since this release

    The DOI of this source code: https://doi.org/10.58473/ChengZhuSci0003/06

    Introduction: This model designs a 3D numerical modeling of chemistry reaction rate by adopting the three-dimensional arrays. The [0,1] binary algorithm is used to simulate the probability of molecule occurrence in the spatial grids of this 3D model. Active chemistry bond is taken into consideration in the functions calculating the chemistry reaction rate.
       
    Development language: C++;

    All Rights Reserved.

    Reference: Liu Huan (2025). Fundamental mechanics: from classical mechanics to quantum mechanics and its application on quantum chemistry. Journal of Quantum Physics and Materials Chemistry (ISSN2958-4027). 2025 (09). https://doi.org/10.58473/JQPMC0014

    Copyrights Certificate Registered by Brock Chain Technology: Brock Chain ID. (5f33d940332da53ba65f2c1975ab960fc5e66fcf76e352848887a4a5ee03946d); Register Time: 2025-11-12 11:25.

    Source Code:
    //All rights reserved by Liu Huan; Source from: https://doi.org/10.58473/JQPMC0014

    #include <iostream>
    #include <random>
    #include <vector>
    #include <iomanip>
    #include <algorithm>

    using namespace std;

    const double E=0.005, F=0.003;
    vector<vector<vector>> generateArray(int I, int J, int K, double probability) {
    random_device rd;
    mt19937 gen(rd());
    uniform_real_distribution<> dis(0.0, 1.0);

    vector<vector<vector<int>>> arr(I, vector<vector<int>>(J, vector<int>(K)));
    for (int i = 0; i < I; i++) {
        for (int j = 0; j < J; j++) {
            for (int k = 0; k < K; k++) {
                arr[i][j][k] = (dis(gen) < probability) ? 1 : 0;
            }
        }
    }
    return arr;
    

    }

    int countOnes(const vector<vector<vector>>& arr) {
    int count = 0;
    for (const auto& layer : arr) {
    for (const auto& row : layer) {
    for (int val : row) {
    if (val == 1) count++;
    }
    }
    }
    return count;
    }

    void printArray(const vector<vector<vector>>& arr) {
    for (int i = 0; i < arr.size(); i++) {
    cout << "Layer " << i << ":" << endl;
    for (int j = 0; j < arr[0].size(); j++) {
    for (int k = 0; k < arr[0][0].size(); k++) {
    cout << arr[i][j][k] << " ";
    }
    cout << endl;
    }
    cout << endl;
    }
    }

    int main() {
    double Density1, Density2, P1, P2;
    int I, J, K, T;

    cout << "To input the decimal values (0.00) of Density1 and Density2 (leaving a space in the middle): ";
    cin >> Density1 >> Density2;
    cout << "To input the integral values of I, J, K (leaving a space among values): ";
    cin >> I >> J >> K;
    cout << "To input the time intervals T: ";
    cin >> T;
    cout << "To input the value of P1 and P2 (leaving a space in the middle): ";
    cin >> P1 >> P2;
    
    vector<vector<vector<int>>> final_c;
    int total_Reaction = 0;
    double final_Density1 = Density1, final_Density2 = Density2;
    
    for (int iter = 0; iter < T; iter++) {
        auto a = generateArray(I, J, K, P1 * Density1);
        auto b = generateArray(I, J, K, P2 * Density2);
        
        vector<vector<vector<int>>> c(I, vector<vector<int>>(J, vector<int>(K)));
        for (int i = 0; i < I; i++) {
            for (int j = 0; j < J; j++) {
                for (int k = 0; k < K; k++) {
                    c[i][j][k] = a[i][j][k] * b[i][j][k];
                }
            }
        } 
        
        int Reaction = countOnes(c);	
        total_Reaction += Reaction;
    	Density1 = std::max(0.0, Density1 - E * Reaction);
    	Density2 = std::max(0.0, Density2 - F * Reaction);
        
        if (iter == T - 1) {
            final_c = c;
            final_Density1 = Density1;
            final_Density2 = Density2;
        }
    }
    
    cout << "\nThe " << T << " Times cycle:" << endl;
    cout << "c[i][j][k]:" << endl;
    printArray(final_c);
    cout << "Total products (from the first time interval to the " << T << " times time interval): " << total_Reaction << endl;
    cout << "Updated Density1: " << fixed << setprecision(2) << final_Density1 << endl;
    cout << "Updated Density2: " << fixed << setprecision(2) << final_Density2 << endl;
    
    return 0;
    

    }

    Downloads