diff --git a/CMakeLists.txt b/CMakeLists.txt
index 90b37ad6c31e7523f64b1d371fba2a40e0ff4584..90aeb49409e827e7a86812fb7c1e6dc037ec17b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,12 +23,12 @@ set(SRC_FILES
 	componant/constantphase.cpp
 	componant/warburg.cpp
 	componant/paralellseriel.cpp
-	componant/finitetr.cpp
+	componant/tro.cpp
+	componant/trc.cpp
 	model.cpp
 	log.cpp
 	normalize.cpp
 	basicmath.cpp
-	log.cpp
 	normalize.cpp
 	basicmath.cpp
 	eistype.cpp
@@ -49,7 +49,8 @@ set(API_HEADERS_CPP
 	${API_HEADERS_CPP_DIR}/componant/constantphase.h
 	${API_HEADERS_CPP_DIR}/componant/warburg.h
 	${API_HEADERS_CPP_DIR}/componant/inductor.h
-	${API_HEADERS_CPP_DIR}/componant/finitetr.h
+	${API_HEADERS_CPP_DIR}/componant/tro.h
+	${API_HEADERS_CPP_DIR}/componant/trc.h
 	${API_HEADERS_CPP_DIR}/componant/paralellseriel.h
 	${API_HEADERS_CPP_DIR}/model.h
 	${API_HEADERS_CPP_DIR}/log.h
diff --git a/componant/componant.cpp b/componant/componant.cpp
index e51760803f81c777a1019f3213c919045a21b0a5..c9f1af7ed62568e0a6e48680d49fac3d5047de05 100644
--- a/componant/componant.cpp
+++ b/componant/componant.cpp
@@ -25,10 +25,12 @@
 #include "componant/resistor.h"
 #include "componant/cap.h"
 #include "componant/constantphase.h"
+#include "componant/trc.h"
 #include "componant/warburg.h"
 #include "log.h"
 #include "componant/inductor.h"
-#include "componant/finitetr.h"
+#include "componant/tro.h"
+#include "componant/trc.h"
 #include "randomgen.h"
 
 using namespace eis;
@@ -127,8 +129,10 @@ Componant* Componant::copy(Componant* componant)
 			return new Cpe(*dynamic_cast<Cpe*>(componant));
 		case Warburg::staticGetComponantChar():
 			return new Warburg(*dynamic_cast<Warburg*>(componant));
-		case FiniteTransmitionline::staticGetComponantChar():
-			return new FiniteTransmitionline(*dynamic_cast<FiniteTransmitionline*>(componant));
+		case TransmissionLineOpen::staticGetComponantChar():
+			return new TransmissionLineOpen(*dynamic_cast<TransmissionLineOpen*>(componant));
+		case TransmissionLineClosed::staticGetComponantChar():
+			return new TransmissionLineClosed(*dynamic_cast<TransmissionLineClosed*>(componant));
 		case Parallel::staticGetComponantChar():
 			return new Parallel(*dynamic_cast<Parallel*>(componant));
 		case Serial::staticGetComponantChar():
@@ -155,8 +159,10 @@ Componant* Componant::createNewComponant(char componant, std::string paramStr, s
 			return new Cpe(paramStr, count, defaultToRange);
 		case Warburg::staticGetComponantChar():
 			return new Warburg(paramStr, count, defaultToRange);
-		case FiniteTransmitionline::staticGetComponantChar():
-			return new FiniteTransmitionline(paramStr, count, defaultToRange);
+		case TransmissionLineOpen::staticGetComponantChar():
+			return new TransmissionLineOpen(paramStr, count, defaultToRange);
+		case TransmissionLineClosed::staticGetComponantChar():
+			return new TransmissionLineClosed(paramStr, count, defaultToRange);
 		default:
 			return nullptr;
 	}
@@ -171,7 +177,8 @@ bool Componant::isValidComponantChar(char componantCh)
 		case Inductor::staticGetComponantChar():
 		case Cpe::staticGetComponantChar():
 		case Warburg::staticGetComponantChar():
-		case FiniteTransmitionline::staticGetComponantChar():
+		case TransmissionLineOpen::staticGetComponantChar():
+		case TransmissionLineClosed::staticGetComponantChar():
 			return true;
 		default:
 			return false;
diff --git a/componant/finitetr.cpp b/componant/finitetr.cpp
deleted file mode 100644
index 18dae95b50dd02b054ba2da016755f8dad7f7c7c..0000000000000000000000000000000000000000
--- a/componant/finitetr.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-//
-// eisgenerator - a shared libary and application to generate EIS spectra
-// Copyright (C) 2022-2024 Carl Philipp Klemm <carl@uvos.xyz>
-//
-// This file is part of eisgenerator.
-//
-// eisgenerator is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// eisgenerator is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with eisgenerator.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include "componant/finitetr.h"
-#include <cstdlib>
-#include <math.h>
-
-#include "componant/componant.h"
-#include "componant/paralellseriel.h"
-#include "componant/resistor.h"
-#include "componant/cap.h"
-#include "log.h"
-
-using namespace eis;
-
-FiniteTransmitionline::FiniteTransmitionline(fvalue c, fvalue r, unsigned int n): _C(c), _R(r), _n(n)
-{
-	if(n < 1)
-	{
-		Log(Log::WARN)<<__func__<<" n must be > 0 setting n to 4";
-		_n = 4;
-	}
-
-	ranges.clear();
-	ranges.push_back(Range(_C, _C, 1));
-	ranges.push_back(Range(_R, _R, 1));
-	ranges.push_back(Range(_n, _n, 1));
-
-	subComponant = createTransmitionLine(_C, _R, _n);
-}
-
-void FiniteTransmitionline::setDefaultParam(size_t count, bool defaultToRange)
-{
-	_C = 1e-6;
-	_R = 1000;
-	_n = 4;
-
-	ranges = getDefaultParameters(defaultToRange);
-
-	if(defaultToRange)
-	{
-		for(eis::Range& range : ranges)
-			range.count = count;
-	}
-}
-
-std::vector<eis::Range> FiniteTransmitionline::getDefaultParameters(bool range) const
-{
-	const fvalue C = 1e-6;
-	const fvalue R = 1000;
-	const fvalue n = 4;
-
-	std::vector<eis::Range> out(paramCount());
-
-	if(range)
-	{
-		out[0] = Range(1e-10, 1e-4, 2, true);
-		out[1] = Range(1, 1e4, 2, true);
-		out[2] = Range(n, n, 1);
-	}
-	else
-	{
-		out[0] = Range(C, C, 1);
-		out[1] = Range(R, R, 1);
-		out[2] = Range(n, n, 1);
-	}
-
-	assert(out.size() == paramCount());
-	return out;
-}
-
-FiniteTransmitionline::FiniteTransmitionline(std::string paramStr, size_t count, bool defaultToRange)
-{
-	ranges = Range::rangesFromParamString(paramStr, count);
-
-	if(ranges.size() != paramCount())
-	{
-		setDefaultParam(count, defaultToRange);
-		Log(Log::WARN)<<__func__<<" default range of "<<getComponantString(false)<<" will be used";
-	}
-
-	updateValues();
-	if(!subComponant)
-		subComponant = createTransmitionLine(_C, _R, _n);
-}
-
-FiniteTransmitionline::FiniteTransmitionline(const FiniteTransmitionline& in)
-{
-	ranges = in.ranges;
-	_R = in._R;
-	_C = in._C;
-	_n = in._n;
-	if(subComponant)
-		delete subComponant;
-	subComponant = createTransmitionLine(_C, _R, _n);
-}
-
-std::complex<fvalue> FiniteTransmitionline::execute(fvalue omega)
-{
-	if(subComponant)
-	{
-		updateValues();
-		return subComponant->execute(omega);
-	}
-	else
-	{
-		Log(Log::WARN)<<"Invalid transmitionline used";
-		return std::complex<fvalue>(1, 0);
-	}
-}
-
-char FiniteTransmitionline::getComponantChar() const
-{
-	return FiniteTransmitionline::staticGetComponantChar();
-}
-
-size_t FiniteTransmitionline::paramCount() const
-{
-	return 3;
-}
-
-Componant* FiniteTransmitionline::createTransmitionLine(fvalue c, fvalue r, unsigned int n)
-{
-	Parallel* par = new Parallel;
-	par->componants.push_back(new Cap(c));
-	par->componants.push_back(new Resistor(r));
-
-	for(unsigned int i = 0; i < n; ++i)
-	{
-		Serial* ser = new Serial;
-		ser->componants.push_back(new Resistor(r));
-		ser->componants.push_back(par);
-
-		par = new Parallel;
-		par->componants.push_back(ser);
-		par->componants.push_back(new Cap(c));
-	}
-
-	return par;
-}
-
-FiniteTransmitionline::~FiniteTransmitionline()
-{
-	if(subComponant)
-		delete subComponant;
-}
-
-void FiniteTransmitionline::updateValues()
-{
-	assert(ranges.size() == paramCount());
-	if(ranges[0].stepValue() != _C || ranges[1].stepValue() != _R || static_cast<size_t>(ranges[2].stepValue()) != _n)
-	{
-		_C = ranges[0].stepValue();
-		_R = ranges[1].stepValue();
-		_n = ranges[2].stepValue();
-		if(subComponant)
-			delete subComponant;
-		subComponant = createTransmitionLine(_C, _R, _n);
-	}
-}
diff --git a/componant/trc.cpp b/componant/trc.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..600d93d96673c87113a113caa3067b79c64111d3
--- /dev/null
+++ b/componant/trc.cpp
@@ -0,0 +1,129 @@
+//
+// eisgenerator - a shared libary and application to generate EIS spectra
+// Copyright (C) 2022-2024 Carl Philipp Klemm <carl@uvos.xyz>
+//
+// This file is part of eisgenerator.
+//
+// eisgenerator is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// eisgenerator is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with eisgenerator.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+#include "componant/trc.h"
+#include <cstdlib>
+#include <math.h>
+
+#include "log.h"
+
+using namespace eis;
+
+TransmissionLineClosed::TransmissionLineClosed(fvalue r, fvalue q, fvalue a, fvalue l)
+{
+	ranges.clear();
+	ranges.reserve(4);
+	ranges.push_back(Range(r, r, 1));
+	ranges.push_back(Range(q, q, 1));
+	ranges.push_back(Range(a, a, 1));
+	ranges.push_back(Range(l, l, 1));
+}
+
+TransmissionLineClosed::TransmissionLineClosed(std::string paramStr, size_t count, bool defaultToRange)
+{
+	if(!paramStr.empty())
+		ranges = Range::rangesFromParamString(paramStr, count);
+
+	if(ranges.size() != paramCount())
+	{
+		ranges = getDefaultParameters(defaultToRange);
+		Log(Log::WARN)<<__func__<<" default range of "<<getComponantString(false)<<" will be used";
+	}
+}
+
+std::vector<eis::Range> TransmissionLineClosed::getDefaultParameters(bool range) const
+{
+	std::vector<eis::Range> out;
+	out.reserve(4);
+
+	if(range) {
+		out.push_back(Range(1, 1e4, 2, true));
+		out.push_back(Range(1e-10, 1e-4, 2, true));
+		out.push_back(Range(0.15, 1, 2, true));
+		out.push_back(Range(0.01, 1000, 2, true));
+	}
+	else {
+		out.push_back(Range(50, 50, 1));
+		out.push_back(Range(1e-6, 1e-6, 1));
+		out.push_back(Range(1, 1, 1));
+		out.push_back(Range(1, 1, 1));
+	}
+
+	assert(out.size() == paramCount());
+	return out;
+}
+
+TransmissionLineClosed::TransmissionLineClosed(const TransmissionLineClosed& in)
+{
+	ranges = in.ranges;
+}
+
+std::complex<fvalue> TransmissionLineClosed::execute(fvalue omega)
+{
+	fvalue r = ranges[0].stepValue();
+	fvalue q = ranges[1].stepValue();
+	fvalue a = ranges[2].stepValue();
+	fvalue l = ranges[3].stepValue();
+
+	return std::sqrt(r/(q*std::pow(std::complex<fvalue>(0, omega), a)))*std::tanh(l*std::sqrt(std::pow(std::complex<fvalue>(0, omega), a)*r*q));
+}
+
+std::string TransmissionLineClosed::getCode(std::vector<std::string>& parameters)
+{
+	std::string r = getUniqueName() + "_0";
+	std::string q = getUniqueName() + "_1";
+	std::string a = getUniqueName() + "_2";
+	std::string l = getUniqueName() + "_3";
+	parameters.push_back(r);
+	parameters.push_back(q);
+	parameters.push_back(a);
+	parameters.push_back(l);
+
+	std::string first = "(std::sqrt("+r+"/("+q+"*std::pow(std::complex<fvalue>(0, omega), "+a+")))*";
+	std::string second = "std::tanh("+l+"*std::sqrt(std::pow(std::complex<fvalue>(0, omega), "+a+")*"+r+"*"+q+")))";
+	return first+second;
+}
+
+std::string TransmissionLineClosed::getTorchScript(std::vector<std::string>& parameters)
+{
+	std::string hpi = std::to_string(M_PI/2);
+	std::string firstParameter = getUniqueName() + "_0";
+	std::string secondParameter = getUniqueName() + "_1";
+	parameters.push_back(firstParameter);
+	parameters.push_back(secondParameter);
+	std::string real = "(1/(" + firstParameter + "*torch.pow(omegas,"+ secondParameter +")))*torch.cos("+ hpi +"*" + secondParameter + ")";
+	std::string imag = "(1/(" + firstParameter + "*torch.pow(omegas,"+ secondParameter +")))*torch.sin("+ hpi +"*" + secondParameter + ")";
+	std::string out = real + '-' + imag + "*1j";
+	return out;
+}
+
+char TransmissionLineClosed::getComponantChar() const
+{
+	return TransmissionLineClosed::staticGetComponantChar();
+}
+
+size_t TransmissionLineClosed::paramCount() const
+{
+	return 4;
+}
+
+TransmissionLineClosed::~TransmissionLineClosed()
+{
+}
diff --git a/componant/tro.cpp b/componant/tro.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..59e0bdb311e1a7e1b86f8f2b71c71f2573235178
--- /dev/null
+++ b/componant/tro.cpp
@@ -0,0 +1,116 @@
+//
+// eisgenerator - a shared libary and application to generate EIS spectra
+// Copyright (C) 2022-2024 Carl Philipp Klemm <carl@uvos.xyz>
+//
+// This file is part of eisgenerator.
+//
+// eisgenerator is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// eisgenerator is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with eisgenerator.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+#include "componant/tro.h"
+#include <cstdlib>
+#include <math.h>
+
+#include "log.h"
+
+using namespace eis;
+
+TransmissionLineOpen::TransmissionLineOpen(fvalue r, fvalue q, fvalue a, fvalue l)
+{
+	ranges.clear();
+	ranges.reserve(4);
+	ranges.push_back(Range(r, r, 1));
+	ranges.push_back(Range(q, q, 1));
+	ranges.push_back(Range(a, a, 1));
+	ranges.push_back(Range(l, l, 1));
+}
+
+TransmissionLineOpen::TransmissionLineOpen(std::string paramStr, size_t count, bool defaultToRange)
+{
+	if(!paramStr.empty())
+		ranges = Range::rangesFromParamString(paramStr, count);
+
+	if(ranges.size() != paramCount())
+	{
+		ranges = getDefaultParameters(defaultToRange);
+		Log(Log::WARN)<<__func__<<" default range of "<<getComponantString(false)<<" will be used";
+	}
+}
+
+std::vector<eis::Range> TransmissionLineOpen::getDefaultParameters(bool range) const
+{
+	std::vector<eis::Range> out;
+	out.reserve(4);
+
+	if(range) {
+		out.push_back(Range(1, 1e4, 2, true));
+		out.push_back(Range(1e-10, 1e-4, 2, true));
+		out.push_back(Range(0.15, 1, 2, true));
+		out.push_back(Range(0.01, 1000, 2, true));
+	}
+	else {
+		out.push_back(Range(50, 50, 1));
+		out.push_back(Range(1e-6, 1e-6, 1));
+		out.push_back(Range(1, 1, 1));
+		out.push_back(Range(1, 1, 1));
+	}
+
+	assert(out.size() == paramCount());
+	return out;
+}
+
+TransmissionLineOpen::TransmissionLineOpen(const TransmissionLineOpen& in)
+{
+	ranges = in.ranges;
+}
+
+std::complex<fvalue> TransmissionLineOpen::execute(fvalue omega)
+{
+	fvalue r = ranges[0].stepValue();
+	fvalue q = ranges[1].stepValue();
+	fvalue a = ranges[2].stepValue();
+	fvalue l = ranges[3].stepValue();
+
+	return std::sqrt(r/(q*std::pow(std::complex<fvalue>(0, omega), a)))*std::pow(std::tanh(l*std::sqrt(std::pow(std::complex<fvalue>(0, omega), a)*r*q)), -1);
+}
+
+std::string TransmissionLineOpen::getCode(std::vector<std::string>& parameters)
+{
+	std::string r = getUniqueName() + "_0";
+	std::string q = getUniqueName() + "_1";
+	std::string a = getUniqueName() + "_2";
+	std::string l = getUniqueName() + "_3";
+	parameters.push_back(r);
+	parameters.push_back(q);
+	parameters.push_back(a);
+	parameters.push_back(l);
+
+	std::string first = "(std::sqrt("+r+"/("+q+"*std::pow(std::complex<fvalue>(0, omega), "+a+")))*";
+	std::string second = "std::pow(std::tanh("+l+"*std::sqrt(std::pow(std::complex<fvalue>(0, omega), "+a+")*"+r+"*"+q+")), -1))";
+	return first+second;
+}
+
+char TransmissionLineOpen::getComponantChar() const
+{
+	return TransmissionLineOpen::staticGetComponantChar();
+}
+
+size_t TransmissionLineOpen::paramCount() const
+{
+	return 4;
+}
+
+TransmissionLineOpen::~TransmissionLineOpen()
+{
+}
diff --git a/eisgenerator/componant/finitetr.h b/eisgenerator/componant/trc.h
similarity index 67%
rename from eisgenerator/componant/finitetr.h
rename to eisgenerator/componant/trc.h
index 0f94a387e9254f3b1298e1ec61abe345cd07c0d6..634abcaa2d896516e0d7a040f60efa2c347e0676 100644
--- a/eisgenerator/componant/finitetr.h
+++ b/eisgenerator/componant/trc.h
@@ -24,28 +24,21 @@
 namespace eis
 {
 
-class FiniteTransmitionline: public Componant
+class TransmissionLineClosed: public Componant
 {
-	fvalue _C;
-	fvalue _R;
-	unsigned int _n;
-
-	Componant* subComponant = nullptr;
-
-	static Componant* createTransmitionLine(fvalue c, fvalue r, unsigned int n);
-	void updateValues();
-	void setDefaultParam(size_t count, bool defaultToRange);
 
 public:
-	FiniteTransmitionline(fvalue c, fvalue r, unsigned int n);
-	FiniteTransmitionline(std::string paramStr, size_t count = 10, bool defaultToRange = false);
-	FiniteTransmitionline(const FiniteTransmitionline& in);
+	TransmissionLineClosed(fvalue r, fvalue q, fvalue a, fvalue l);
+	TransmissionLineClosed(std::string paramStr, size_t count = 10, bool defaultToRange = false);
+	TransmissionLineClosed(const TransmissionLineClosed& in);
 	virtual std::complex<fvalue> execute(fvalue omega) override;
 	virtual size_t paramCount() const override;
 	virtual std::vector<eis::Range> getDefaultParameters(bool range = true) const override;
-	virtual ~FiniteTransmitionline();
+	virtual ~TransmissionLineClosed();
 	virtual char getComponantChar() const override;
-	virtual std::string componantName() const override {return "FiniteTransmitionline";}
+	virtual std::string getCode(std::vector<std::string>& parameters) override;
+	virtual std::string getTorchScript(std::vector<std::string>& parameters) override;
+	virtual std::string componantName() const override {return "TransmissionLineClosed";}
 	static constexpr char staticGetComponantChar(){return 't';}
 };
 
diff --git a/eisgenerator/componant/tro.h b/eisgenerator/componant/tro.h
new file mode 100644
index 0000000000000000000000000000000000000000..c4fcf2ed2bb094e1eff340a6d18a531d320f69a4
--- /dev/null
+++ b/eisgenerator/componant/tro.h
@@ -0,0 +1,45 @@
+//SPDX-License-Identifier:         LGPL-3.0-or-later
+/* * eisgenerator - a shared libary and application to generate EIS spectra
+ * Copyright (C) 2022-2024 Carl Philipp Klemm <carl@uvos.xyz>
+ *
+ * This file is part of eisgenerator.
+ *
+ * eisgenerator is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * eisgenerator is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with eisgenerator.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+#include "componant.h"
+
+namespace eis
+{
+
+class TransmissionLineOpen: public Componant
+{
+
+public:
+	TransmissionLineOpen(fvalue r, fvalue q, fvalue a, fvalue l);
+	TransmissionLineOpen(std::string paramStr, size_t count = 10, bool defaultToRange = false);
+	TransmissionLineOpen(const TransmissionLineOpen& in);
+	virtual std::complex<fvalue> execute(fvalue omega) override;
+	virtual size_t paramCount() const override;
+	virtual std::vector<eis::Range> getDefaultParameters(bool range = true) const override;
+	virtual ~TransmissionLineOpen();
+	virtual char getComponantChar() const override;
+	virtual std::string getCode(std::vector<std::string>& parameters) override;
+	virtual std::string getTorchScript(std::vector<std::string>& parameters) override;
+	virtual std::string componantName() const override {return "TransmissionLineOpen";}
+	static constexpr char staticGetComponantChar(){return 'o';}
+};
+
+}
diff --git a/main.cpp b/main.cpp
index baee7629f86138355b00b54e573d8a8c16dbbd82..2609ba97c20a2f66c37317e3e160a053740b7304 100644
--- a/main.cpp
+++ b/main.cpp
@@ -403,11 +403,23 @@ int main(int argc, char** argv)
 		}
 		else if(config.mode == MODE_CODE)
 		{
-			std::cout<<model.getCode();
+			std::string code = model.getCode();
+			if(code.empty())
+			{
+				std::cerr<<"Can not get code for this model\n";
+				return 2;
+			}
+			std::cout<<code;
 		}
 		else if(config.mode == MODE_TORCH_SCRIPT)
 		{
-			std::cout<<model.getTorchScript();
+			std::string code = model.getTorchScript();
+			if(code.empty())
+			{
+				std::cerr<<"Can not get a torch script for this model\n";
+				return 2;
+			}
+			std::cout<<code;
 		}
 		else
 		{
diff --git a/test.cpp b/test.cpp
index 44fe8585f3a7a48f6d60684e6475423ac66cc3df..60a4ebf0ea319d730148a0fa2371ab5bd22a063d 100644
--- a/test.cpp
+++ b/test.cpp
@@ -76,7 +76,7 @@ std::vector<eis::DataPoint> getSine()
 	for(size_t i = 0; i < 20; ++i)
 	{
 		eis::DataPoint point;
-		point.im = std::complex<fvalue>((sin(i/10.0)/static_cast<double>((i+16)/16))*10, (sin(i/10.0)/static_cast<double>((i+16)/16))*10);
+		point.im = std::complex<fvalue>((sin(i/10.0)/static_cast<double>((i+16.0)/16.0))*10, (sin(i/10.0)/static_cast<double>((i+16.0)/16.0))*10);
 		point.omega = i;
 		data.push_back(point);
 	}
@@ -492,6 +492,21 @@ static bool testLoader(const char* file, const size_t expectedLength, const size
 	return true;
 }
 
+bool testCompiledConsistancy(const std::string& modelstr)
+{
+	const fvalue omega = 1e5;
+	eis::Model model(modelstr, 100, false);
+	std::complex<fvalue> a = model.execute(omega).im;
+	model.compile();
+	std::complex<fvalue> b = model.execute(omega).im;
+	if(!eis::fvalueEq(a.imag(), b.imag()) || !eis::fvalueEq(a.real(), b.real()))
+	{
+		eis::Log(eis::Log::ERROR)<<__func__<<" Compiled model "<<modelstr<<" returns "<<b<<" but uncompiled model returns "<<a;
+		return false;
+	}
+	return true;
+}
+
 int main(int argc, char** argv)
 {
 	eis::Log::headers = true;
@@ -533,11 +548,29 @@ int main(int argc, char** argv)
 	if(!testMadapParams())
 		return 12;
 
-	if(!testLoader(testEisSpectraFile10, 6, 5, "r-cr-cr"))
+	if(!testCompiledConsistancy("r{100}"))
 		return 13;
 
-	if(!testLoader(testEisSpectraFile11, 6, 12, "Unkown", true))
+	if(!testCompiledConsistancy("c{1e-5}"))
 		return 14;
 
+	if(!testCompiledConsistancy("l{1e-5}"))
+		return 15;
+
+	if(!testCompiledConsistancy("p{1e-5, 0.5}"))
+		return 16;
+
+	if(!testCompiledConsistancy("w{1000}"))
+		return 17;
+
+	if(!testCompiledConsistancy("o{50, 1e-6, 0.5, 0.5}"))
+		return 18;
+
+	if(!testCompiledConsistancy("t{50, 1e-6, 0.5, 0.5}"))
+		return 19;
+
+	if(!testCompiledConsistancy("r{50}-r{1000}p{1e-5, 0.9}"))
+		return 20;
+
 	return 0;
 }