现有组件功能与Amesim组件比较对齐,补全功能;仿真服务启动环境检测,旧版json工程文件适配读取
This commit is contained in:
1 parent
b6c22a54f8
commit
6fc9afe41d
119 files changed
+260114
-351
No files matched your search
@@ -1,6 +1,15 @@
|
||||
#include "kernels.h"
|
||||
#include <math.h>
|
||||
|
||||
double native_dry_friction(double velocity, double static_share, double coulomb,
|
||||
double stiction, double stribeck_velocity, int stribeck,
|
||||
double mode) {
|
||||
if (fabs(mode)<.5) return -static_share;
|
||||
double resistance=coulomb;
|
||||
if (stribeck) resistance+=(stiction-coulomb)*exp(-3*fabs(velocity)/stribeck_velocity);
|
||||
return mode>0 ? -resistance : resistance;
|
||||
}
|
||||
|
||||
double native_contact(double penetration, double velocity, double stiffness,
|
||||
double damping, double pdis, int signed_force) {
|
||||
if (penetration <= 0) return 0;
|
||||
@@ -21,7 +30,5 @@ void native_stop_motion(double x, double v, double lower, double upper,
|
||||
|
||||
double native_limit_force(double penetration, double velocity, double stiffness,
|
||||
double damping, double depth, int signed_force) {
|
||||
if(penetration<=0) return 0;
|
||||
double force=stiffness*penetration+(depth>0?fmin(penetration/depth,1):1)*damping*velocity;
|
||||
return signed_force==1?force:fmax(force,0);
|
||||
return native_contact(penetration, velocity, stiffness, damping, depth, signed_force);
|
||||
}
|
||||
@@ -239,3 +239,17 @@ int native_medium_gas(const NativeMedium *medium, double m, double U, double V,
|
||||
int native_medium_gas_context(NativePropertyCache *cache,const NativeMedium *m,double mass,double U,double V,NativeGas *g) {
|
||||
int ok=native_medium_gas(m,mass,U,V,g);if(ok)remember_gas(cache,m,g);return ok;
|
||||
}
|
||||
|
||||
int native_polytropic_gas_context(NativePropertyCache *cache,const NativeMedium *m,
|
||||
double mass,double T,double V,NativeGas *g) {
|
||||
/* Amesim's polytropic storage uses ideal-gas mass even when the selected
|
||||
gas supplies real-fluid enthalpy/density to the connected resistances. */
|
||||
if(!(mass>0 && T>0 && V>0))return 0;
|
||||
g->T=T;g->p=mass*m->R*T/V;
|
||||
g->rho=native_density_context(cache,m,g->p,T);
|
||||
double dt=T-m->Tref;
|
||||
g->h=m->real_helium?h_ideal(T)+h_departure(g->p,T):m->cp*T+.5*m->slope*dt*dt;
|
||||
g->u=g->h-g->p/g->rho;
|
||||
if(!(g->p>0 && g->rho>0 && isfinite(g->p) && isfinite(g->h) && isfinite(g->u)))return 0;
|
||||
remember_gas(cache,m,g);return 1;
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
#include <math.h>
|
||||
|
||||
double native_signal(double t, double start, int stages, int cyclic, const double *data) {
|
||||
double elapsed = fmax(t-start,0), duration = 0, offset = 0;
|
||||
if (t < start) return data[0];
|
||||
double elapsed = t-start, duration = 0, offset = 0;
|
||||
for (int i=0;i<stages;i++) duration += data[16+i];
|
||||
if (cyclic && duration > 0) elapsed = fmod(elapsed,duration);
|
||||
else if (elapsed >= duration) return data[8+stages-1];
|
||||
for (int i=0;i<stages;i++) {
|
||||
double d = data[16+i];
|
||||
if (elapsed < offset+d || i == stages-1)
|
||||
@@ -18,7 +20,9 @@ double native_signal_break(double t, double end, double start, int stages,
|
||||
int cyclic, const double *data) {
|
||||
double duration=0, offset=0, result=end;
|
||||
for (int i=0;i<stages;i++) duration += data[16+i];
|
||||
for (int i=0;i<stages;i++) {
|
||||
/* A cyclic endpoint is already the next cycle's start. Listing both can
|
||||
create two nearly equal floating-point break times for one event. */
|
||||
for (int i=0;i<stages+(cyclic?0:1);i++) {
|
||||
double event=start+offset;
|
||||
if (cyclic && duration > 0 && event <= t) {
|
||||
double cycle=fmax(0,floor((t-event)/duration)+1);
|
||||
@@ -26,7 +30,7 @@ double native_signal_break(double t, double end, double start, int stages,
|
||||
if (event <= t) event += duration;
|
||||
}
|
||||
if (event > t) result=fmin(result,event);
|
||||
offset += data[16+i];
|
||||
if (i < stages) offset += data[16+i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user