eisgenerator 2.1.x
componant.h
1//SPDX-License-Identifier: LGPL-3.0-or-later
2/* * eisgenerator - a shared libary and application to generate EIS spectra
3 * Copyright (C) 2022-2024 Carl Philipp Klemm <carl@uvos.xyz>
4 *
5 * This file is part of eisgenerator.
6 *
7 * eisgenerator is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * eisgenerator is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with eisgenerator. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22#include <complex>
23#include <iostream>
24#include <vector>
25#include <string>
26#include <kisstype/type.h>
27
28namespace eis
29{
30
32{
33 protected:
34 std::vector<eis::Range> ranges;
35 std::string uniqueName;
36 bool defaultedParameters = false;
37
38 // Parses paramStr into ranges and, when it does not carry a value for every
39 // parameter, falls back to the default parameters, recording that in
40 // defaultedParameters.
41 void initRanges(const std::string& paramStr, size_t count, bool defaultToRange);
42
43 public:
44 virtual std::complex<fvalue> execute(fvalue omega)
45 {
46 (void)omega;
47 std::cout<<"warning incompleat model\n";
48 return std::complex<fvalue> (1,0);
49 }
50
51 virtual void setParamRanges(const std::vector<eis::Range>& ranges);
52 virtual std::vector<eis::Range>& getParamRanges();
53 virtual std::vector<eis::Range> getParamRanges() const;
54 virtual std::vector<eis::Range> getDefaultParameters(bool range = true) const;
55 virtual size_t paramCount() const {return 0;};
56 virtual ~Componant() = default;
57 virtual char getComponantChar() const = 0;
65 virtual std::string getComponantString(bool currentValue = true, bool withCount = false) const;
66 virtual std::string componantName() const = 0;
67 virtual std::string getCode(std::vector<std::string>& parameters);
68 virtual std::string getTorchScript(std::vector<std::string>& parameters);
69 virtual bool compileable();
70
71 std::string getUniqueName();
72
81 bool hasDefaultedParameters() const { return defaultedParameters; }
82
83 static Componant* copy(Componant* componant);
84 static Componant* createNewComponant(char componant, std::string paramStr = "", size_t count = 1, bool defaultToRange = false);
85 static bool isValidComponantChar(char componant);
86};
87
88}
Definition componant.h:32
virtual std::string getComponantString(bool currentValue=true, bool withCount=false) const
Gets this componant as a model string.
bool hasDefaultedParameters() const
Checks if this componant had to use default parameters.
Definition componant.h:81
eisgenerator Copyright (C) 2021 Carl Klemm
Definition basicmath.h:26