Skip to content

Commit

Permalink
ENH: New structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanSkocic committed Jun 20, 2024
1 parent 8e26fb9 commit 6945932
Show file tree
Hide file tree
Showing 51 changed files with 479 additions and 1,026 deletions.
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.f90 linguist-language=fortran
*.fypp linguist-language=fortran

doc/** linguist-documentation
docs/** linguist-documentation
example/** linguist-vendored
include/** linguist-vendored
capi/** linguist-vendored
media/** linguist-vendored
pywrapper/** linguist-vendored
py/** linguist-vendored

58 changes: 33 additions & 25 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
*.o
#API: an (incompatible) API change
#BENCH: changes to the benchmark suite
#BLD: change related to building numpy
#BUG: bug fix
#DEP: deprecate something, or remove a deprecated object
#DEV: development tool or utility
#DOC: documentation
#ENH: enhancement
#MAINT: maintenance commit (refactoring, typos, etc.)
#REV: revert an earlier commit
#STY: style fix (whitespace, PEP8)
#TST: addition or modification of tests
#REL: related to releasing

.idea/
bin/
build/
docs/build/
dist/
local/
API-doc/
.vscode/
*.obj
*.exe
*.out
*.pyd
*.lib
*.cmake
*.o
*.mod
*.dylib
*.dll
*.pyd
*.dll.a
*.so
*.a
*.dll
*.so
*.dylib

.idea
.vscode

build/
*.egg-info

.DS_Store

dist/

__pycache__
*.so

generator*
.DS_Store

pywrapper/src/pyecx/ecx*.h
pywrapper/src/pyecx/*.dylib
pywrapper/src/pyecx/*.so
pywrapper/src/pyecx/*.dll
pywrapper/src/pyecx/*.dll.a
pywrapper/wheelhouse/
py/wheelhouse/
py/src/pyecx/bin/
py/src/pyecx/include/
py/src/pyecx/lib/
41 changes: 41 additions & 0 deletions API-doc-FORD-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
project: ecx
summary: ECX - Electrochemistry
project_github: https://github.com/MilanSkocic/ecx
project_download: https://github.com/MilanSkocic/ecx/releases
project_website: https://milanskocic.github.io/ecx/index.html
author: Milan Skocic
email: [email protected]
github: https://github.com/MilanSkocic
src_dir: ./src
include: ./include
media_dir: ./media
page_dir: ./doc
output_dir: API-doc
exclude_dir: ./example
./test
display: public
protected
source: true
proc_internals: true
sort: permission-alpha
print_creation_date: true
md_extensions: markdown.extensions.toc
markdown.extensions.smarty
fpp_extensions: fypp
preprocess: true
preprocessor: fypp
graph: true
graph_maxnodes: 250
graph_maxdepth: 5
coloured_edges: true
license: by-sa
favicon: media/logo.ico
---

![ecx](./media/logo.png)

[TOC]

{!README.md!}

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
* Documentation with sphinx.

Full changelog available at [github](https://github.com/MilanSkocic/ecx/releases)

**Note released yet**
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021-2024 Milan Skocic
Copyright (c) Milan Skocic

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
39 changes: 28 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ else
btype=release
endif

SRC_FYPP=$(wildcard ./src/*.fypp)

.PHONY: build doc docs

all: $(LIBNAME)

$(LIBNAME): build copy_a shared

.PHONY: build
build:
fpm build --profile=$(btype)

test: build
fpm test --profile=$(btype)

example: build
fpm run --profile=$(btype) --example example_in_f example_in_c
fpm run --profile=$(btype) --example example_in_f
fpm run --profile=$(btype) --example example_in_c

copy_a:
cp -f $(shell find ./build/gfortran* -type f -name $(LIBNAME).a) $(BUILD_DIR)
Expand All @@ -38,18 +42,14 @@ shared_darwin:
shared_windows:
$(FC) -shared $(FPM_LDFLAGS) -o $(BUILD_DIR)/$(LIBNAME).dll -Wl,--out-implib=$(BUILD_DIR)/$(LIBNAME).dll.a,--export-all-symbols,--enable-auto-import,--whole-archive $(BUILD_DIR)/$(LIBNAME).a -Wl,--no-whole-archive

clean:
fpm clean --all
rm -f src/*.mod

install: install_dirs install_$(PLATFORM)

install_dirs:
mkdir -p $(install_dir)/bin
mkdir -p $(install_dir)/include
mkdir -p $(install_dir)/lib
fpm install --prefix=$(install_dir)
cp -f ./include/*.h $(install_dir)/include
fpm install --prefix=$(install_dir) --profile=$(btype)
cp -f $(INCLUDE_DIR)/$(NAME)*.h $(install_dir)/include

install_linux:
cp -f $(BUILD_DIR)/$(LIBNAME).so $(install_dir)/lib
Expand All @@ -59,14 +59,31 @@ install_darwin:

install_windows:
cp -f $(BUILD_DIR)/$(LIBNAME).dll.a $(install_dir)/lib
cp -f $(BUILD_DIR)/$(LIBNAME).dll $(install_dir)/lib
cp -f $(BUILD_DIR)/$(LIBNAME).dll $(install_dir)/bin

uninstall:
rm -f $(install_dir)/include/$(HEADER_PREFIX)*.h
rm -f $(install_dir)/include/$(HEADER_PREFIX)*.mod
rm -f $(install_dir)/include/$(NAME)*.h
rm -f $(install_dir)/include/$(NAME)*.mod
rm -f $(install_dir)/lib/$(LIBNAME).a
rm -f $(install_dir)/lib/$(LIBNAME).so
rm -f $(install_dir)/lib/$(LIBNAME).dylib
rm -f $(install_dir)/lib/$(LIBNAME).dll.a
rm -f $(install_dir)/lib/$(LIBNAME).dll
rm -f $(install_dir)/bin/$(LIBNAME).dll

clean:
fpm clean --all
make -C py clean
rm -rf API-doc/*

doc:
ford API-doc-FORD-file.md

docs:
rm -rf docs/*
cp -rf API-doc/* ./docs/

logo:
make -C media

1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
24 changes: 21 additions & 3 deletions configure.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

LIBNAME="libecx"
HEADER_PREFIX="ecx"
NAME="ecx"
PYNAME="py$NAME"
PY_SRC="./src/$PYNAME"

# environment variables
FC=gfortran
Expand All @@ -10,21 +14,31 @@ FPM_CFLAGS="-std=c11 -pedantic -Wall -Wextra"
FPM_LDFLAGS=""
DEFAULT_INSTALL_DIR="$HOME/.local"
PLATFORM="linux"
EXT=".so"

if [[ "$OSTYPE" == "msys" ]]; then
DEFAULT_INSTALL_DIR="${APPDATA//\\//}/local"
PLATFORM="windows"
ROOT=$ROOTWINDOWS
EXT=".dll"
LIBS=( "${LIBSWINDOWS[@]}" )
fi

if [[ "$OSTYPE" == "darwin"* ]];then
PLATFORM="darwin"
ROOT=$ROOTDARWIN
EXT=".dylib"
LIBS=( "${LIBSDARWIN[@]}" )
fi

cp -f VERSION ./py/VERSION
cp -f LICENSE ./py/LICENSE

export LIBNAME
echo "LIBNAME=" $LIBNAME

export HEADER_PREFIX
echo "HEADER_PREFIX=" $HEADER_PREFIX
export NAME
echo "NAME=" $NAME

export PLATFORM
echo "PLATFORM=" $PLATFORM
Expand All @@ -47,5 +61,9 @@ echo "BUILD DIR=" $BUILD_DIR
export INCLUDE_DIR
echo "INCLUDE_DIR=" $INCLUDE_DIR

export PY_SRC
echo "PY_SRC=" $PY_SRC

export FC
echo "FC=" $FC

File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name = "ecx"
version = "0.1.0"
license = "GNU General Public License v3 (GPLv3)"
license = "MIT"
author = "Milan Skocic"
maintainer = "[email protected]"
copyright = "Copyright 2021-2024, Milan Skocic"
copyright = "Copyright, Milan Skocic"
categories =["Science"]
keywords = ["electrochemistry", "impedance", "photoelectrochemistry"]
homepage = "https://milanskocic.github.io/ecx/index.html"
Expand All @@ -28,11 +28,11 @@ library = true

[[example]]
name="example_in_f"
main="example_in_f.f90"
main="example.f90"

[[example]]
name="example_in_c"
main="example_in_c.c"
main="example.c"

[[test]]
name="test_core"
Expand Down
56 changes: 47 additions & 9 deletions include/ecx.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,53 @@
/**
* @file
* @brief C API - Main C header for the ecx library.
*/
#ifndef ECX_H
#define ECX_H
#include <complex.h>
#if _MSC_VER
#define ADD_IMPORT __declspec(dllimport)
typedef _Dcomplex ecx_cdouble;
#define ecx_cbuild(real, imag) (_Cbuild(real, imag))
#else
#define ADD_IMPORT
typedef double _Complex ecx_cdouble;
#define ecx_cbuild(real, imag) (real+I*imag)
#endif

extern char* ecx_get_version(void);


/* ---------------------------------------------------------------------------------------------- */
ADD_IMPORT extern const double ecx_core_PI;
ADD_IMPORT extern const double ecx_core_T_K;
void ecx_core_nm2eV(double *lambda, double *E, size_t n);
void ecx_core_kTe(double *U, double *kTE, size_t n);
/* ---------------------------------------------------------------------------------------------- */


/* ---------------------------------------------------------------------------------------------- */
extern double ecx_kinetics_capi_nernst(double E0, int z,
double *aox, double *vox, size_t nox,
double *ared, double *vred, size_t nred,
double T);

extern void ecx_kinetics_capi_sbv(double *U, double OCV, double j0,
double aa, double ac, double za, double zc,
double A, double T, double *i, size_t n);

extern void ecx_kinetics_capi_bv(double *U, double OCV, double j0, double jdla, double jdlc,
double aa, double ac, double za, double zc,
double A, double T, double *i, size_t n);
/* ---------------------------------------------------------------------------------------------- */


#include "ecx_core.h"
#include "ecx_eis.h"
#include "ecx_pec.h"
#include "ecx_kinetics.h"
#include "ecx_version.h"
/* ---------------------------------------------------------------------------------------------- */
extern void ecx_capi_zr(double *w, double R, size_t n, ecx_cdouble *Z);
extern void ecx_capi_zc(double *w, double C, size_t n, ecx_cdouble *Z);
extern void ecx_capi_zl(double *w, double L, size_t n, ecx_cdouble *Z);
extern void ecx_capi_zcpe(double *w, double Q, double a, size_t n, ecx_cdouble *Z);
extern void ecx_capi_zw(double *w, double s, size_t n, ecx_cdouble *Z);
extern void ecx_eis_z(double *p, double *w, ecx_cdouble *z,
char e, size_t k, size_t n,
int *errstat, char *(*errmsg));
/* ---------------------------------------------------------------------------------------------- */

#endif

Expand Down
18 changes: 0 additions & 18 deletions include/ecx_core.h

This file was deleted.

Loading

0 comments on commit 6945932

Please sign in to comment.