Skip to content

Commit 71241bf

Browse files
committed
fix RLC calculation
1 parent 3a81df5 commit 71241bf

File tree

13 files changed

+185
-6
lines changed

13 files changed

+185
-6
lines changed

smith_chart/js/smith_tool.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,14 @@ function update_schem_component(freq_here, save_impedance, sch_index) {
450450
im_here = (schematic[sch_index].abs[0] * scaler[0] * 2 * Math.PI * freq_here) / zo;
451451
break;
452452
case "rlc_par":
453-
re_here = (schematic[sch_index].abs[0] * scaler[0]) / zo;
454-
im_here =
453+
var re_temp = schematic[sch_index].abs[0] * scaler[0];
454+
var im_temp =
455455
1 /
456-
zo /
457456
(1 / (schematic[sch_index].abs[1] * scaler[1] * 2 * Math.PI * freq_here) -
458457
schematic[sch_index].abs[2] * scaler[2] * 2 * Math.PI * freq_here);
458+
re_here = (im_temp * im_temp * re_temp) / (re_temp * re_temp + im_temp * im_temp) / zo;
459+
im_here = (re_temp * re_temp * im_temp) / (re_temp * re_temp + im_temp * im_temp) / zo;
460+
// console.log('bp1', re_temp, im_temp, re_here, im_here, scaler)
459461
break;
460462
case "rlc":
461463
re_here = (schematic[sch_index].abs[0] * scaler[0]) / zo;
@@ -840,10 +842,10 @@ function update_smith_chart() {
840842

841843
//Update the impedance box
842844
var txt = '<div class="text_box">';
843-
txt += (real_old * zo).toPrecision(3);
845+
txt += (real_old * zo).toFixed(1);
844846
if (imag_old < 0) txt += " - ";
845847
else txt += " + ";
846-
txt += Math.abs(imag_old * zo).toPrecision(3) + "j</div>";
848+
txt += Math.abs(imag_old * zo).toFixed(1) + "j</div>";
847849
document.getElementById("current_impedance").innerHTML = txt;
848850

849851
//Calculate the admittance
@@ -1397,7 +1399,6 @@ function update_smith_chart() {
13971399

13981400
Plotly.react("SParamPlot", data, sParamLayout, config);
13991401
Plotly.react("SParamPlot_s21", data21, sParamLayout, config);
1400-
console.log("data21", data21);
14011402

14021403
//update the HTML tables
14031404
drawMakerTable();

sport_event/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

sport_event/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# React + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

sport_event/bun.lockb

139 KB
Binary file not shown.

sport_event/eslint.config.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import react from 'eslint-plugin-react'
4+
import reactHooks from 'eslint-plugin-react-hooks'
5+
import reactRefresh from 'eslint-plugin-react-refresh'
6+
7+
export default [
8+
{ ignores: ['dist'] },
9+
{
10+
files: ['**/*.{js,jsx}'],
11+
languageOptions: {
12+
ecmaVersion: 2020,
13+
globals: globals.browser,
14+
parserOptions: {
15+
ecmaVersion: 'latest',
16+
ecmaFeatures: { jsx: true },
17+
sourceType: 'module',
18+
},
19+
},
20+
settings: { react: { version: '18.3' } },
21+
plugins: {
22+
react,
23+
'react-hooks': reactHooks,
24+
'react-refresh': reactRefresh,
25+
},
26+
rules: {
27+
...js.configs.recommended.rules,
28+
...react.configs.recommended.rules,
29+
...react.configs['jsx-runtime'].rules,
30+
...reactHooks.configs.recommended.rules,
31+
'react/jsx-no-target-blank': 'off',
32+
'react-refresh/only-export-components': [
33+
'warn',
34+
{ allowConstantExport: true },
35+
],
36+
},
37+
},
38+
]

sport_event/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.jsx"></script>
12+
</body>
13+
</html>

sport_event/package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "sport_event",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vite build",
9+
"lint": "eslint .",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"@emotion/react": "^11.14.0",
14+
"@emotion/styled": "^11.14.0",
15+
"@mui/material": "^6.3.0",
16+
"install": "^0.13.0",
17+
"react": "^18.3.1",
18+
"react-dom": "^18.3.1"
19+
},
20+
"devDependencies": {
21+
"@eslint/js": "^9.17.0",
22+
"@types/react": "^18.3.18",
23+
"@types/react-dom": "^18.3.5",
24+
"@vitejs/plugin-react": "^4.3.4",
25+
"eslint": "^9.17.0",
26+
"eslint-plugin-react": "^7.37.2",
27+
"eslint-plugin-react-hooks": "^5.0.0",
28+
"eslint-plugin-react-refresh": "^0.4.16",
29+
"globals": "^15.14.0",
30+
"vite": "^6.0.5"
31+
}
32+
}

sport_event/public/vite.svg

Lines changed: 1 addition & 0 deletions
Loading

sport_event/src/App.css

Whitespace-only changes.

sport_event/src/App.jsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { useState } from 'react'
2+
import { styled } from '@mui/material/styles';
3+
import Box from '@mui/material/Box';
4+
import Paper from '@mui/material/Paper';
5+
import Grid from '@mui/material/Grid2';
6+
import Container from '@mui/material/Container';
7+
8+
const Item = styled(Paper)(({ theme }) => ({
9+
textAlign: 'center'}));
10+
11+
export default function App() {
12+
return (
13+
<Container maxWidth="xl">
14+
<Grid container spacing={2}>
15+
<Grid size={8}>
16+
<Item>size=8</Item>
17+
</Grid>
18+
<Grid size={4}>
19+
<Item>size=4</Item>
20+
</Grid>
21+
<Grid size={4}>
22+
<Item>size=4</Item>
23+
</Grid>
24+
<Grid size={8}>
25+
<Item>size=8</Item>
26+
</Grid>
27+
</Grid>
28+
</Container>
29+
);
30+
}
31+

0 commit comments

Comments
 (0)