Skip to content

Instantly share code, notes, and snippets.

View DanWBR's full-sized avatar
🎯
Focusing

Daniel Wagner DanWBR

🎯
Focusing
View GitHub Profile
@DanWBR
DanWBR / dwsim_automation_sample2.py
Last active March 19, 2024 07:09
DWSIM Automation Sample in Python - Create a Flowsheet with a Distillation Column for Water/Acetone/Ethanol Separation (requires DWSIM v8.4.5 or newer)
# remove the following two lines to run on linux
import pythoncom
pythoncom.CoInitialize()
import clr
from System.IO import Directory, Path, File
from System import String, Environment
dwsimpath = "C:\\Users\\danie\\AppData\\Local\\DWSIM\\"
@DanWBR
DanWBR / pfr.py
Last active April 25, 2024 19:36
Creates a DWSIM Simulation with a Plug-Flow Reactor + Kinetic Reaction using Python
import pythoncom
pythoncom.CoInitialize()
import clr
from System.IO import Directory, Path, File
from System import String, Environment
from System.Collections.Generic import Dictionary
dwsimpath = "C:\\Users\\Daniel\\AppData\\Local\\DWSIM8\\"
clr.AddReference(dwsimpath + "CapeOpen.dll")
def display(msg):
print(msg)
dwsimpath = "/home/daniel/dwsimcore"
from clr_loader import get_coreclr
from pythonnet import set_runtime
set_runtime(get_coreclr(dwsimpath + "DWSIMCore.Tests.runtimeconfig.json"))
import clr
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ILGPU;
using ILGPU.Algorithms;
using ILGPU.Runtime;
using ILGPU.Runtime.Cuda;
@DanWBR
DanWBR / dtl_test2.py
Created November 6, 2020 20:02
Using DWSIM Standalone Thermodynamics Library in Python with Python.NET (High-Level API + Material Stream calls)
import clr, array
from System.IO import Directory, Path, File
from System import String, Double, Array, Reflection, Exception
dtlpath = "C:\\Users\\Daniel\\Source\\Repos\\DanWBR\\dwsim6\\DistPackages\\DTL\\"
clr.AddReference(dtlpath + "DWSIM.Thermodynamics.StandaloneLibrary.dll")
from DWSIM.Thermodynamics import Streams, PropertyPackages, CalculatorInterface
@DanWBR
DanWBR / dtl_test.py
Last active March 19, 2024 09:04
Using DWSIM Standalone Thermodynamics Library in Python with Python.NET (Low-Level Flash API + CAPE-OPEN-style calls)
import clr
from System.IO import Directory, Path, File
from System import String, Double, Array, Reflection, Exception
dtlpath = "C:\\Users\\Daniel\\Source\\Repos\\DanWBR\\dwsim6\\DistPackages\\DTL\\"
clr.AddReference(dtlpath + "DWSIM.Thermodynamics.StandaloneLibrary.dll")
from DWSIM.Thermodynamics import Streams, PropertyPackages, CalculatorInterface
@DanWBR
DanWBR / dwsim_automation.py
Last active June 6, 2024 13:55
Create, run and save a new DWSIM simulation in Python
import pythoncom
pythoncom.CoInitialize()
import clr
from System.IO import Directory, Path, File
from System import String, Environment
dwsimpath = "C:\\Users\\Daniel\\AppData\\Local\\DWSIM8\\"