diff --git a/OPIMaker.cpp b/OPIMaker.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e7c56f39f18958163811ef4ab6db9853443a9400 --- /dev/null +++ b/OPIMaker.cpp @@ -0,0 +1,64 @@ + +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +#include <algorithm> +#include <map> + + +int main(int argc, char *argv[]) +{ + std::fstream opiin; + std::fstream opiout; + std::fstream input; + opiin.open (argv[1], std::fstream::in); + input.open (argv[2], std::fstream::in); + opiout.open (argv[3], std::fstream::out | std::fstream::trunc); + std::map<std::string,std::string> replacement_values; + std::string line; + while (std::getline(input, line)) + { + std::istringstream ss(line); + std::string s = ss.str(); + std::replace(s.begin(), s.end(), '-', ' '); + std::replace(s.begin(), s.end(), ':', ' '); + ss.str(s); + + std::string name; + std::string value; + + ss >> name >> value; + std::cout << name << value << std::endl << std::endl; + replacement_values[name] = value; + } + while(std::getline(opiin,line)) + { + std::string name; + std::string value; + bool found = false; + for (auto it = replacement_values.begin(); it != replacement_values.end(); ++it) + { + std::string _token_str = "$" + it->first + " "; + size_t _pos = line.find(_token_str); + if ( std::string::npos != _pos && !found) + { + name = _token_str; + value = it->second; + found = true; + } + } + if (found) + { + opiout << name << " : " << value << std::endl; + } + else + { + opiout << line << std::endl; + } + } + opiin.close(); + opiout.close(); + input.close(); +} + diff --git a/OpenPhase.ipynb b/OpenPhase.ipynb index dcabdb665170c68d6c7d80ceeee6f98eee30ec80..89592a5da0fb22c550e0c4acd0a9d16a2882e743 100644 --- a/OpenPhase.ipynb +++ b/OpenPhase.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 67, "id": "67dd6769", "metadata": {}, "outputs": [ @@ -10,8 +10,55 @@ "name": "stdout", "output_type": "stream", "text": [ - "The job Martensite was saved and received the ID: 92\n" + "The job Martensite was saved and received the ID: 92\n", + "Output collection not implement yet.\n" ] + }, + { + "data": { + "text/html": [ + "<div>\n", + "<style scoped>\n", + " .dataframe tbody tr th:only-of-type {\n", + " vertical-align: middle;\n", + " }\n", + "\n", + " .dataframe tbody tr th {\n", + " vertical-align: top;\n", + " }\n", + "\n", + " .dataframe thead th {\n", + " text-align: right;\n", + " }\n", + "</style>\n", + "<table border=\"1\" class=\"dataframe\">\n", + " <thead>\n", + " <tr style=\"text-align: right;\">\n", + " <th></th>\n", + " <th>time</th>\n", + " <th>austenite</th>\n", + " <th>martensite</th>\n", + " </tr>\n", + " </thead>\n", + " <tbody>\n", + " <tr>\n", + " <th>0</th>\n", + " <td>0.0</td>\n", + " <td>100.0</td>\n", + " <td>0.0</td>\n", + " </tr>\n", + " </tbody>\n", + "</table>\n", + "</div>" + ], + "text/plain": [ + " time austenite martensite\n", + "0 0.0 100.0 0.0" + ] + }, + "execution_count": 67, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ @@ -26,17 +73,35 @@ "\n", "class OpenPhase_RTC:\n", " def __init__(self):\n", - " self.input = GenericParameters(table_name=\"input\")\n", - " self._dt = 1e-6\n", + " self.input = DataContainer(table_name=\"input\")\n", + " self._dt = 1\n", + " self._timesteps = 1\n", + " self._openmp = 1\n", " self._path = None\n", "\n", " @property\n", - " def value(self):\n", + " def dt(self):\n", " return self._dt\n", "\n", - " @value.setter\n", - " def value(self, dt):\n", + " @dt.setter\n", + " def dt(self, dt):\n", " self._dt = dt\n", + " \n", + " @property\n", + " def timesteps(self):\n", + " return self._timesteps\n", + "\n", + " @timesteps.setter\n", + " def timesteps(self, timesteps):\n", + " self._timesteps = timesteps \n", + " \n", + " @property\n", + " def openmp(self):\n", + " return self._openmp\n", + "\n", + " @openmp.setter\n", + " def openmp(self, openmp):\n", + " self._openmp = openmp \n", "\n", " def read(self, path, wrap=True):\n", " self._dt = self._dt.read(file_name=path, wrap=wrap)\n", @@ -45,19 +110,66 @@ " def config_material(self):\n", " pass\n", "\n", - " def write(self,path):\n", + " def getdata(self):\n", " self.input['dt'] = self._dt\n", - " self.input.write_file( \n", - " file_name=\"input\",\n", - " cwd=path\n", - " )\n", + " self.input['nSteps'] = self._timesteps\n", + " self.input['nOMP'] = self._openmp\n", + " return self.input\n", + " \n", + "class OpenPhase_Grid:\n", + " def __init__(self):\n", + " self.input = DataContainer(table_name=\"input\")\n", + " self._dx = 1\n", + " self._SizeX = 1\n", + " self._SizeY = 1\n", + " self._SizeZ = 1\n", + " self._path = None\n", + "\n", + " @property\n", + " def SizeX(self):\n", + " return self._SizeX\n", + "\n", + " @SizeX.setter\n", + " def SizeX(self, SizeX):\n", + " self._SizeX = SizeX\n", + " \n", + " @property\n", + " def SizeY(self):\n", + " return self._SizeY\n", + "\n", + " @SizeY.setter\n", + " def SizeY(self, SizeY):\n", + " self._SizeY = SizeY \n", + " \n", + " @property\n", + " def SizeZ(self):\n", + " return self._SizeZ\n", + "\n", + " @SizeX.setter\n", + " def SizeZ(self, SizeZ):\n", + " self._SizeZ = SizeZ\n", + " \n", + " def read(self, path, wrap=True):\n", + " self._dx = self._dt.read(file_name=path, wrap=wrap)\n", + " self._path = path\n", + "\n", + " def config_material(self):\n", + " pass\n", + "\n", + " def getdata(self):\n", + " self.input['dx'] = self._dx\n", + " self.input['Nx'] = self._SizeX\n", + " self.input['Ny'] = self._SizeY\n", + " self.input['Nz'] = self._SizeZ\n", + " return self.input\n", " \n", "class OpenPhase(GenericJob):\n", " def __init__(self, project, job_name):\n", " super().__init__(project, job_name) \n", - " #self.input = GenericParameters(table_name=\"input\")\n", - " self.executable = \"/home/marvin/pyiron/projects/OpenPhase.sh input > output\"\n", + " self.input = DataContainer(table_name=\"input\")\n", + " self.executable = Martensite.working_directory + \"/../../../OpenPhase.sh input.yml > output\"\n", " self._RTC = OpenPhase_RTC() \n", + " self._Grid = OpenPhase_Grid() \n", " \n", " @property\n", " def RTC(self):\n", @@ -65,10 +177,21 @@ "\n", " @RTC.setter\n", " def RTC(self, value):\n", - " self._RTC = value \n", + " self._RTC = value \n", + " \n", + " @property\n", + " def Grid(self):\n", + " return self._Grid\n", + "\n", + " @Grid.setter\n", + " def Grid(self, value):\n", + " self._Grid = value \n", " \n", " def write_input(self): \n", - " self._RTC.write(self.working_directory)\n", + " self.input.clear()\n", + " self.input.append(self._RTC.getdata())\n", + " self.input.append(self._Grid.getdata())\n", + " self.input.write(Martensite.working_directory + \"/input.yml\")\n", "\n", " def collect_output(self):\n", " print(\"Output collection not implement yet.\")\n", @@ -91,11 +214,19 @@ " \n", "from pyiron import Project\n", "qRTC = OpenPhase_RTC()\n", + "qRTC.dt = 1e-4\n", + "qRTC.timesteps = 100\n", + "qGrid = OpenPhase_Grid()\n", + "qGrid.dx = 1e-6\n", + "qGrid.SizeX = 100\n", + "qGrid.SizeY = 1\n", + "qGrid.SizeZ = 100\n", "pr = Project(path='Martensite')\n", "Martensite = pr.create_job(OpenPhase, 'Martensite',delete_existing_job=True)\n", "Martensite.RTC = qRTC\n", + "Martensite.Grid = qGrid\n", "Martensite.run()\n", - "csv_file = \"/home/marvin/pyiron/projects/OpenPhase/output_Results/TextData/Volumes.opd\"\n", + "csv_file = Martensite.working_directory + \"/../../../OpenPhase/output_Results/TextData/Volumes.opd\"\n", "\n", "# Read csv file into dataframe\n", "df = pd.read_csv(csv_file, names=['time','austenite','martensite'], skiprows=[0],delimiter=\" \",engine='python')\n", diff --git a/OpenPhase.sh b/OpenPhase.sh new file mode 100755 index 0000000000000000000000000000000000000000..afa1edd5f759e56d75b237d21bb874885dd500bc --- /dev/null +++ b/OpenPhase.sh @@ -0,0 +1,4 @@ +#!/bin/bash +/home/marvin/pyiron/projects/OpenPhase/OPIMaker /home/marvin/pyiron/projects/OpenPhase/preset_Martensite.opi $1 /home/marvin/pyiron/projects/OpenPhase/output +/home/marvin/pyiron/projects/OpenPhase/Studio.exe /home/marvin/pyiron/projects/OpenPhase/output +exit 0 diff --git a/preset_Martensite.opi b/preset_Martensite.opi new file mode 100644 index 0000000000000000000000000000000000000000..c5c2ee28176f1b6d9a7b4830cdb8eac5cce7545a --- /dev/null +++ b/preset_Martensite.opi @@ -0,0 +1,337 @@ +@Description + +$Description : +Key modules +Elasticity + +This preset illustrates martensitic transformation. + +@Initialization + +$InitType Initialization Type: Single +$Rotation Rotation mode of initialization: none +$PhaseIndex Phase: 0 +$Variant Symmetry Variant: -1 + + +@Modules + +$PhaseField PhaseField selected: Yes +$Chemistry Chemistry selected: No +$VacancyDiffusion VacancyDiffusion selected: No +$ThermodynamicModel Thermodynamic model: None +$IntfAnisotropy Interface anisotropy Cubic/Hex: $Nucleation Nucleation selected: Yes +$Mechanics Mechanics selected: Yes +$Plasticity Plasticity model: No +$Damage Damage selected: No +$HeatDiffusion HeatDiffusion selected: No +$Flow Flow selected: No +$UserDrivingForce UserDrivingForce selected: Yes +$1Dsimulation Dedicated 1D output :No + + +@Composition + +$DiffusionModel Diffusion model: None +$RefElement_0 Name of reference element phase 0: FE +$RefElement_1 Name of reference element phase 1: FE +$State_0 State of phase 0: Solid +$State_1 State of phase 1: Solid +$Cmin_0_FE Minimum mole fractions: 0.0 +$Cmin_1_FE Minimum mole fractions: 0.0 +$Cmax_0_FE Maximum mole fractions: 1.0 +$Cmax_1_FE Maximum mole fractions: 1.0 + + +@BoundaryConditions + +$BC0X X axis boundary condition: Periodic +$BCNX X axis far end boundary condition: Periodic +$BC0Y Y axis boundary condition: Periodic +$BCNY Y axis far end boundary condition: Periodic +$BC0Z Z axis boundary condition: Periodic +$BCNZ Z axis far end boundary condition: Periodic + + + + + +@DrivingForce + +$Average Driving force averaging: Yes +$CutOff Driving force cutoff: 0.95 +$NoiseMode Noise: Zero +$Noise_0_0 Noise Intensity: 0.0 +$Noise_0_1 Noise Intensity: 0.0 +$Noise_1_1 Noise Intensity: 0.0 +$Stabilization Phase-field stabilization enabled: No + + + + + +@ElasticProperties + +$StrainAccuracy Strain Accuracy: 1.0e-6 +$MAXIterations Maximum Iterations: 100 +$EModel Elasticity Model: KHACHATURYAN +$SMODE Strain Mode: GREENLAGRANGE +$BCX Boundary Conditions X: FreeBoundaries +$BCY Boundary Conditions Y: FreeBoundaries +$BCZ Boundary Conditions Z: FreeBoundaries +$BCXY Boundary Conditions XY: FreeBoundaries +$BCYZ Boundary Conditions YZ: FreeBoundaries +$BCXZ Boundary Conditions XZ: FreeBoundaries +$BCValueX BC Value X: 0 +$BCValueY BC Value Y: 0 +$BCValueZ BC Value Z: 0 +$BCValueXY BC Value XY: 0 +$BCValueYZ BC Value YZ: 0 +$BCValueXZ BC Value XZ: 0 +$Restrict Restrict: ASPECTRATIO +$ElasticConstantMode Elastic Constant Mode: TENSOR +$C_0 : +237e9 117e9 117e9 0 0 0 +117e9 237e9 117e9 0 0 0 +117e9 117e9 237e9 0 0 0 +0 0 0 60e9 0 0 +0 0 0 0 60e9 0 +0 0 0 0 0 60e9 + +$C_1 : +1.87455e+11 1.11165e+11 1.06547e+11 9.20007e+08 1.90713e+10 -6.01830e+09 +1.11165e+11 1.81999e+11 1.11072e+11 7.61985e+09 -5.13189e+08 7.62600e+09 +1.06547e+11 1.11072e+11 2.26978e+11 -5.44643e+09 -1.16758e+10 -1.08325e+09 +9.20007e+08 7.61985e+09 -5.44643e+09 9.27720e+10 -1.08325e+09 -5.13193e+08 +1.90713e+10 -5.13189e+08 -1.16758e+10 -1.08325e+09 8.82470e+10 9.20007e+08 +-6.01830e+09 7.62600e+09 -1.08325e+09 -5.13193e+08 9.20007e+08 9.28654e+10 + +$K_0 Bulk modulus: 0 +$K_1 Bulk modulus: 0 +$E_0 Young's modulus: 0 +$E_1 Young's modulus: 0 +$L_0 First Lame: 0 +$L_1 First Lame: 0 +$G_0 Shear modulus: 0 +$G_1 Shear modulus: 0 +$Nu_0 Poisson's ratio: 0 +$Nu_1 Poisson's ratio: 0 +$M_0 P-wave modulus: 0 +$M_1 P-wave modulus: 0 +$U_0 : +1.0 0.0 0.0 +0.0 1.0 0.0 +0.0 0.0 1.0 + +$U_1 : +1.1137500 -0.0734422 0.132834 +0.0599654 1.1272300 0.059707 +-0.1933730 -0.0734419 0.783581 + +$ConsiderExternalForces Consider External Forces: No +$ChemoMechanicalCoupling Chemo-Mechanical coupling: No +$Cref_0_FE Reference concentration: 0.0 +$Cref_1_FE Reference concentration: 0.0 +$Kappa_0_FE : +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 + +$Kappa_1_FE : +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 + +$Lambda_0_FE : +0 0 0 +0 0 0 +0 0 0 + +$Lambda_1_FE : +0 0 0 +0 0 0 +0 0 0 + +$ThermoMechanicalCoupling Thermo-Mechanical coupling: No +$Tref_0 Reference temperature: 0.0 +$Tref_1 Reference temperature: 0.0 +$Gamma_0 : +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 + +$Gamma_1 : +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 + +$Alpha_0 : +0 0 0 +0 0 0 +0 0 0 + +$Alpha_1 : +0 0 0 +0 0 0 +0 0 0 + +$NeuberCorrection_0 Neuber correction: Yes +$NeuberCorrection_1 Neuber correction: Yes +$YoungsModulus_0 Neuber Young's modulus: 160e9 +$YoungsModulus_1 Neuber Young's modulus: 200e9 +$YieldStrength_0 Neuber Yield strength: 156e6 +$YieldStrength_1 Neuber Yield strength: 900e6 +$Hardening_0 Neuber hardening: 7 +$Hardening_1 Neuber hardening: 7 + + + + + +@InterfaceProperties + +$EnergyModel_0_0 Stiffness Model: ISO +$EnergyModel_0_1 Stiffness Model: ISO +$EnergyModel_1_1 Stiffness Model: ISO +$Sigma_0_0 Interface energy: 0.5 +$Sigma_0_1 Interface energy: 0.5 +$Sigma_1_1 Interface energy: 0.5 +$MobilityModel_0_0 Mobility Model: ISO +$MobilityModel_0_1 Mobility Model: ISO +$MobilityModel_1_1 Mobility Model: ISO +$Mu_0_0 Interface mobility: 1.0e-13 +$Mu_0_1 Interface mobility: 1.0e-13 +$Mu_1_1 Interface mobility: 1.0e-13 +$Q_0_0 Activation energy: 0.0 +$Q_0_1 Activation energy: 0.0 +$Q_1_1 Activation energy: 0.0 + + + + + +@Nucleation + +$Allowed_0_0 Nucleation of nucleating phase in matrix phase: No +$Allowed_0_1 Nucleation of nucleating phase in matrix phase: No +$Allowed_1_0 Nucleation of nucleating phase in matrix phase: Yes +$Allowed_1_1 Nucleation of nucleating phase in matrix phase: No +$Density_0_0 Particle density: 2.0e14 +$Density_0_1 Particle density: 2.0e14 +$Density_1_0 Particle density: 0.75e+18 +$Density_1_1 Particle density: 2.0e14 +$Tmin_0_0 Minimum temperature: 0.0 +$Tmin_0_1 Minimum temperature: 0.0 +$Tmin_1_0 Minimum temperature: 0 +$Tmin_1_1 Minimum temperature: 0.0 +$Tmax_0_0 Maximum temperature: 10000.0 +$Tmax_0_1 Maximum temperature: 10000.0 +$Tmax_1_0 Maximum temperature: 1000 +$Tmax_1_1 Maximum temperature: 10000.0 +$Orientation_0_0 Grain orientation mode: Parent +$Orientation_0_1 Grain orientation mode: Parent +$Orientation_1_0 Grain orientation mode: Parent +$Orientation_1_1 Grain orientation mode: Parent +$MobilityReduction Mobility reduction for nucleus stability: 1.0 +$Shielding_0_0 Minimum distance between nuclei: 10.0 +$Shielding_0_1 Minimum distance between nuclei: 10.0 +$Shielding_1_0 Minimum distance between nuclei: 10.0 +$Shielding_1_1 Minimum distance between nuclei: 10.0 +$RelDensity_0_0 Nucleation density relative to phase volume: Yes +$RelDensity_0_1 Nucleation density relative to phase volume: Yes +$RelDensity_1_0 Nucleation density relative to phase volume: Yes +$RelDensity_1_1 Nucleation density relative to phase volume: Yes +$NucleateEvery Nucleation interval in timesteps: 1 + + + + + +@RunTimeControl + +$SimTtl Simulation Title: Martensite C=0.1 wt.% +$nSteps Number of timesteps: 1000000 +$FTime Output to disk every: 100 +$STime Output to screen every: 100 +$dt Timestep: 5e-4 +$nOMP OpenMP threads: 1 +$tRstrt Restart output every: 1000 +$Restrt Restart switch (Yes or No): No +$tStart Restart timestep: 0 +$SynchronizeTimeSteps Synchronize timesteps: No +$PhaseFieldTimeFactor Refinement of phase field step: 1 +$DiffusionTimeFactor Refinement of diffusion step: 1 +$HeatDiffusionFactor Refinement of heat diffusion step: 1 + + + + + +@Settings + +$Comp_0 Name of Component 0: FE +$Phase_0 Name of Phase 0: AUSTENITE +$Phase_1 Name of Phase 1: MARTENSITE +$dx Grid spacing (dx): 1e-7 +$Nx System size in X direction: 64 +$Ny System size in Y direction: 64 +$Nz System size in Z direction: 64 +$IWidth Interface width: 5.0 +$MoveFrameDirection Move frame direction: No +$MoveFramePosition Move frame position: 0 +$MoveFramePhase Move frame phase: 0 + + + + + +@SymmetryVariants + + + + + +$Nvariants_0 : 0 + +$Nvariants_1 : 0 + + +@Temperature + +$ReadfromFile Obtain temperature curve from file: No +$DataFile Data file containing temperature curve: *.opit +$T0 Initial System Temperature: 940.0 +$R0X X coordinate of the reference point: 0.0 +$R0Y Y coordinate of the reference point: 0.0 +$R0Z Z coordinate of the reference point: 0.0 +$DT_DRX X component of the temp. gradient: 0.0 +$DT_DRY Y component of the temp. gradient: 0 +$DT_DRZ Z component of the temp. gradient: 0 +$DT_Dt Cooling(-) or heating(+) rate: -100.0 +$LatentHeat Latent heat mode: No +$LAT_HEAT_0_0 Latent heat: 0.0 +$LAT_HEAT_0_1 Latent heat: 0.0 +$LAT_HEAT_1_1 Latent heat: 0.0 + + + + + +@UserDrivingForce + +$UDF_Mode_0_1 : FORMULA +$UDF_LatentHeat_0_1 Latent Heat: 9.03e8 +$UDF_Teq_0_1 Equilibrium Temperature: 990 +